summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <mail@nicolasgoaziou.fr>2018-02-27 01:02:22 +0100
committerNicolas Goaziou <mail@nicolasgoaziou.fr>2018-02-27 01:02:22 +0100
commit6a56ae53f21720db9c97f557d0b6ab807c1855b4 (patch)
tree2794e58de53acf42975f186ea28a5b05a2cba692
parent8e70f5d02d4cd2afc4a83730fe36733d0f578e03 (diff)
downloadorg-mode-6a56ae53f21720db9c97f557d0b6ab807c1855b4.tar.gz
`org-mark-ring-push' also populates Emacs mark ring
* lisp/org.el (org-mark-ring-push): Also populate Emacs mark ring. Fixes: Bug#23745
-rw-r--r--lisp/org.el34
1 files changed, 20 insertions, 14 deletions
diff --git a/lisp/org.el b/lisp/org.el
index ec4f0d0..f0cc311 100644
--- a/lisp/org.el
+++ b/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.