Browse Source

`org-mark-ring-push' also populates Emacs mark ring

* lisp/org.el (org-mark-ring-push): Also populate Emacs mark ring.

Fixes: Bug#23745
Nicolas Goaziou 2 years ago
parent
commit
6a56ae53f2
1 changed files with 20 additions and 14 deletions
  1. 20 14
      lisp/org.el

+ 20 - 14
lisp/org.el

@@ -10541,31 +10541,37 @@ to read."
       (goto-char (point-min))
       (select-window cwin))))
 
-;;; The mark ring for links jumps
+
+;;; The Mark Ring
 
 (defvar org-mark-ring nil
   "Mark ring for positions before jumps in Org mode.")
+
 (defvar org-mark-ring-last-goto nil
   "Last position in the mark ring used to go back.")
+
 ;; Fill and close the ring
-(setq org-mark-ring nil org-mark-ring-last-goto nil) ;; in case file is reloaded
-(dotimes (_ org-mark-ring-length)
-  (push (make-marker) org-mark-ring))
+(setq org-mark-ring nil)
+(setq org-mark-ring-last-goto nil) ;in case file is reloaded
+
+(dotimes (_ org-mark-ring-length) (push (make-marker) org-mark-ring))
 (setcdr (nthcdr (1- org-mark-ring-length) org-mark-ring)
 	org-mark-ring)
 
 (defun org-mark-ring-push (&optional pos buffer)
-  "Put the current position or POS into the mark ring and rotate it."
+  "Put the current position into the mark ring and rotate it.
+Also push position into the Emacs mark ring.  If optional
+argument POS and BUFFER are not nil, mark this location instead."
   (interactive)
-  (setq pos (or pos (point)))
-  (setq org-mark-ring (nthcdr (1- org-mark-ring-length) org-mark-ring))
-  (move-marker (car org-mark-ring)
-	       (or pos (point))
-	       (or buffer (current-buffer)))
-  (message "%s"
-	   (substitute-command-keys
-	    "Position saved to mark ring, go back with \
-`\\[org-mark-ring-goto]'.")))
+  (let ((pos (or pos (point)))
+	(buffer (or buffer (current-buffer))))
+    (with-current-buffer buffer
+      (org-with-point-at pos (push-mark nil t)))
+    (setq org-mark-ring (nthcdr (1- org-mark-ring-length) org-mark-ring))
+    (move-marker (car org-mark-ring) pos buffer))
+  (message
+   (substitute-command-keys
+    "Position saved to mark ring, go back with `\\[org-mark-ring-goto]'.")))
 
 (defun org-mark-ring-goto (&optional n)
   "Jump to the previous position in the mark ring.