emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: the_wurfkreuz <the_wurfkreuz@proton.me>
To: "emacs-orgmode@gnu.org" <emacs-orgmode@gnu.org>
Subject: [BUG] Incorrect cursor on using undo inside a source block [9.7.10 (release_9.7.10 @ /home/wurfkreuz/.source/emacs/lisp/org/)]
Date: Mon, 19 Aug 2024 19:33:57 +0000	[thread overview]
Message-ID: <YNeVxB9TocieYAE3M4Labg_4vN9HYPhdCHCGyAZ9Refyzj7cDU21enigQbRvm4YiOSBiKVuQBTFfpLd5NLFGYFqROAGJxj4177Laod9rClc=@proton.me> (raw)


[-- 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


             reply	other threads:[~2024-08-19 19:35 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-19 19:33 the_wurfkreuz [this message]
2024-08-19 19:54 ` [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-20 18:31 ` Ihor Radchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='YNeVxB9TocieYAE3M4Labg_4vN9HYPhdCHCGyAZ9Refyzj7cDU21enigQbRvm4YiOSBiKVuQBTFfpLd5NLFGYFqROAGJxj4177Laod9rClc=@proton.me' \
    --to=the_wurfkreuz@proton.me \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).