emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [BUG] Incorrect cursor on using undo inside a source block [9.7.10 (release_9.7.10 @ /home/wurfkreuz/.source/emacs/lisp/org/)]
@ 2024-08-19 19:33 the_wurfkreuz
  2024-08-19 19:54 ` the_wurfkreuz
  2024-08-20 18:31 ` Ihor Radchenko
  0 siblings, 2 replies; 3+ messages in thread
From: the_wurfkreuz @ 2024-08-19 19:33 UTC (permalink / raw)
  To: emacs-orgmode@gnu.org


[-- Attachment #1.1: Type: text/plain, Size: 394 bytes --]

Reproduction is in the attachment file.

Also, i've already written a similar report like a month and a half ago and after the fix the bug disappeared. And now it's apparently here again.
Emacs : GNU Emacs 30.0.60 (build 4, x86_64-pc-linux-gnu, GTK+ Version 3.24.43, cairo version 1.18.0)
of 2024-08-19
Package: Org mode version 9.7.10 (release_9.7.10 @ /home/wurfkreuz/.source/emacs/lisp/org/)

[-- Attachment #1.2: Type: text/html, Size: 698 bytes --]

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: bug-report.org --]
[-- Type: text/org; name=bug-report.org, Size: 5721 bytes --]

If i uncomment the commented code and then press 'U' the pointer jumps back to
the start of the block

#+begin_src emacs-lisp

(defvar
  eshell-toggle-window-configuration nil
  "Variable to store the window configuration before opening eshell.")

(defvar eshell-toggle-selected-window nil
  "Variable to store the selected window before opening eshell.")

(defun SpawnEshellSplitBelow ()
  "Open a shell in a small split below or toggle it if already open."
  (interactive)
  (if (eq major-mode 'eshell-mode)
      (progn
        (when eshell-toggle-window-configuration
          (set-window-configuration eshell-toggle-window-configuration)
          (setq eshell-toggle-window-configuration nil))
        (when eshell-toggle-selected-window
          (select-window eshell-toggle-selected-window)
          (setq eshell-toggle-selected-window nil)))
    (setq eshell-toggle-window-configuration (current-window-configuration))
    (setq eshell-toggle-selected-window (selected-window))
    ;; Calculate one third of the total window height
    (let ((one-third-height (/ (window-total-height) 3)))
      ;; Ensure the height is at least 1 to avoid errors
      (setq one-third-height (max one-third-height 1))
      (split-window-below (- one-third-height))
      (other-window 1)
      (open-eshell-in-current-directory))))

(defun open-eshell-in-current-directory ()
  "Open eshell in the directory of the current buffer.
    If an eshell buffer for the directory already exists, switch to it."
  (interactive)
  (let* ((buffer-dir (if (buffer-file-name)
                         (file-name-directory (buffer-file-name))
                       default-directory))
         (eshell-buffer-name (concat "*eshell:" buffer-dir "*"))
         (existing-eshell-buffer (get-buffer eshell-buffer-name)))
    (if existing-eshell-buffer
        (switch-to-buffer existing-eshell-buffer)
      (let ((eshell-buffer (eshell 'N)))
        (with-current-buffer eshell-buffer
          (rename-buffer eshell-buffer-name)
          (eshell/cd buffer-dir))))))

(with-eval-after-load 'evil
  (define-key evil-normal-state-map (kbd "M-e") 'SpawnEshellSplitBelow)
  (define-key evil-insert-state-map (kbd "M-e") 'SpawnEshellSplitBelow))
;; (define-key evil-normal-state-map (kbd "M-e") 'open-eshell-in-current-directory))

(defun SpawnEshellInProjectRoot ()
  "Open eshell in the project's root directory or toggle it if already open."
  (interactive)
  (if (eq major-mode 'eshell-mode)
      (progn
        (when eshell-toggle-window-configuration
          (set-window-configuration eshell-toggle-window-configuration)
          (setq eshell-toggle-window-configuration nil))
        (when eshell-toggle-selected-window
          (select-window eshell-toggle-selected-window)
          (setq eshell-toggle-selected-window nil)))
    (setq eshell-toggle-window-configuration (current-window-configuration))
    (setq eshell-toggle-selected-window (selected-window))
    ;; Calculate one third of the total window height
    (let ((one-third-height (/ (window-total-height) 3)))
      ;; Ensure the height is at least 1 to avoid errors
      (setq one-third-height (max one-third-height 1))
      (split-window-below (- one-third-height))
      (other-window 1)
      (let ((project-root (projectile-project-root)))
        (open-eshell-in-directory project-root)))))

(defun open-eshell-in-directory (dir)
  "Open eshell in the specified directory DIR.
If an eshell buffer for the directory already exists, switch to it."
  (interactive "DDirectory: ")
  (let* ((eshell-buffer-name (concat "*eshell:" dir "*"))
         (existing-eshell-buffer (get-buffer eshell-buffer-name)))
    (if existing-eshell-buffer
        (switch-to-buffer existing-eshell-buffer)
      (let ((eshell-buffer (eshell 'N)))
        (with-current-buffer eshell-buffer
          (rename-buffer eshell-buffer-name)
          (eshell/cd dir))))))

(with-eval-after-load 'evil
  (define-key evil-normal-state-map (kbd "M-p") 'SpawnEshellInProjectRoot))

(defun kill-all-eshell-buffers ()
  "Kill all Eshell buffers."
  (interactive)
  (dolist (buffer (buffer-list))
    (when (string-match-p "^\\*eshell\\*" (buffer-name buffer))
      (kill-buffer buffer))))


;; (defvar my-saved-window-configuration nil
;;   "Variable to store the saved window configuration.")

;; (defun my-eshell-fullscreen ()
;;   "Replace the current window layout with a fullscreen Eshell."
;;   (interactive)
;;   (setq my-saved-window-configuration (current-window-configuration))
;;   (delete-other-windows)
;;   (eshell))

;; (defun my-restore-window-configuration ()
;;   "Restore the previously saved window configuration."
;;   (interactive)
;;   (when my-saved-window-configuration
;;     (set-window-configuration my-saved-window-configuration)))

(defvar my-saved-tab-configurations (make-hash-table :test 'equal)
  "Hash table to store the saved window configurations per tab.")

(defun my-current-tab-name ()
  "Get the current tab's name."
  (alist-get 'name (car (funcall tab-bar-tabs-function))))

(defun my-eshell-fullscreen ()
  "Replace the current window layout with a fullscreen Eshell for the current tab."
  (interactive)
  (let ((tab-name (my-current-tab-name)))
    (puthash tab-name (current-window-configuration) my-saved-tab-configurations)
    (delete-other-windows)
    (eshell)))

(defun my-restore-window-configuration ()
  "Restore the previously saved window configuration for the current tab."
  (interactive)
  (let* ((tab-name (my-current-tab-name))
         (config (gethash tab-name my-saved-tab-configurations)))
    (if config
        (set-window-configuration config)
      (message "No saved window configuration for this tab."))))

#+end_src


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [BUG] Incorrect cursor on using undo inside a source block [9.7.10 (release_9.7.10 @ /home/wurfkreuz/.source/emacs/lisp/org/)]
  2024-08-19 19:33 [BUG] Incorrect cursor on using undo inside a source block [9.7.10 (release_9.7.10 @ /home/wurfkreuz/.source/emacs/lisp/org/)] the_wurfkreuz
@ 2024-08-19 19:54 ` the_wurfkreuz
  2024-08-20 18:31 ` Ihor Radchenko
  1 sibling, 0 replies; 3+ messages in thread
From: the_wurfkreuz @ 2024-08-19 19:54 UTC (permalink / raw)
  To: emacs-orgmode@gnu.org

[-- Attachment #1: Type: text/plain, Size: 722 bytes --]

Accidentally have written the wrong reproduction instructions.

So the text commented code should uncommented with 'uncomment region' and then and 'undo' should be used.

Sent with [Proton Mail](https://proton.me/) secure email.

On Monday, August 19th, 2024 at 22:33, the_wurfkreuz <the_wurfkreuz@proton.me> wrote:

> Reproduction is in the attachment file.
>
> Also, i've already written a similar report like a month and a half ago and after the fix the bug disappeared. And now it's apparently here again.
> Emacs : GNU Emacs 30.0.60 (build 4, x86_64-pc-linux-gnu, GTK+ Version 3.24.43, cairo version 1.18.0)
> of 2024-08-19
> Package: Org mode version 9.7.10 (release_9.7.10 @ /home/wurfkreuz/.source/emacs/lisp/org/)

[-- Attachment #2: Type: text/html, Size: 1732 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [BUG] Incorrect cursor on using undo inside a source block [9.7.10 (release_9.7.10 @ /home/wurfkreuz/.source/emacs/lisp/org/)]
  2024-08-19 19:33 [BUG] Incorrect cursor on using undo inside a source block [9.7.10 (release_9.7.10 @ /home/wurfkreuz/.source/emacs/lisp/org/)] the_wurfkreuz
  2024-08-19 19:54 ` the_wurfkreuz
@ 2024-08-20 18:31 ` Ihor Radchenko
  1 sibling, 0 replies; 3+ messages in thread
From: Ihor Radchenko @ 2024-08-20 18:31 UTC (permalink / raw)
  To: the_wurfkreuz; +Cc: emacs-orgmode@gnu.org

the_wurfkreuz <the_wurfkreuz@proton.me> writes:

> Reproduction is in the attachment file.
>
> Also, i've already written a similar report like a month and a half ago and after the fix the bug disappeared. And now it's apparently here again.
> Emacs : GNU Emacs 30.0.60 (build 4, x86_64-pc-linux-gnu, GTK+ Version 3.24.43, cairo version 1.18.0)
> of 2024-08-19
> Package: Org mode version 9.7.10 (release_9.7.10 @ /home/wurfkreuz/.source/emacs/lisp/org/)
> If i uncomment the commented code and then press 'U' the pointer jumps back to
> the start of the block

This bug has been fixed on the development branch (Org 9.8-pre), not on
the release branch (which Org 9.7.10).

I am unable to reproduce on the latest main (development version).

Canceled.

Previous report: https://list.orgmode.org/orgmode/XF_7mLNCUN8XKtnd7G-NUoAF5Vq0DDafaDdF0v53eFlhQ35N-H3bPA0VkYyDrbEWE-0PEQg8iiyB7NatUtvPEQe6SQyJaTE5vW0CwoUKzqs=@proton.me/

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-08-20 18:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-19 19:33 [BUG] Incorrect cursor on using undo inside a source block [9.7.10 (release_9.7.10 @ /home/wurfkreuz/.source/emacs/lisp/org/)] the_wurfkreuz
2024-08-19 19:54 ` the_wurfkreuz
2024-08-20 18:31 ` Ihor Radchenko

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).