comparison lisp/simple.el @ 5812:1959e5c4a563

(push-mark): Don't push on global-mark-ring if its car is a marker in the current buffer.
author Roland McGrath <roland@gnu.org>
date Mon, 07 Feb 1994 04:48:18 +0000
parents 7cc27fc3c661
children 2de9426a38bf
comparison
equal deleted inserted replaced
5811:7cc27fc3c661 5812:1959e5c4a563
1336 (goto-char (mark t)) 1336 (goto-char (mark t))
1337 (pop-mark)))) 1337 (pop-mark))))
1338 1338
1339 (defun push-mark (&optional location nomsg activate) 1339 (defun push-mark (&optional location nomsg activate)
1340 "Set mark at LOCATION (point, by default) and push old mark on mark ring. 1340 "Set mark at LOCATION (point, by default) and push old mark on mark ring.
1341 Also push LOCATION on the global mark ring. 1341 If the last global mark pushed was not in the current buffer,
1342 also push LOCATION on the global mark ring.
1342 Display `Mark set' unless the optional second arg NOMSG is non-nil. 1343 Display `Mark set' unless the optional second arg NOMSG is non-nil.
1343 In Transient Mark mode, activate mark if optional third arg ACTIVATE non-nil. 1344 In Transient Mark mode, activate mark if optional third arg ACTIVATE non-nil.
1344 1345
1345 Novice Emacs Lisp programmers often try to use the mark for the wrong 1346 Novice Emacs Lisp programmers often try to use the mark for the wrong
1346 purposes. See the documentation of `set-mark' for more information. 1347 purposes. See the documentation of `set-mark' for more information.
1353 (progn 1354 (progn
1354 (move-marker (car (nthcdr mark-ring-max mark-ring)) nil) 1355 (move-marker (car (nthcdr mark-ring-max mark-ring)) nil)
1355 (setcdr (nthcdr (1- mark-ring-max) mark-ring) nil)))) 1356 (setcdr (nthcdr (1- mark-ring-max) mark-ring) nil))))
1356 (set-marker (mark-marker) (or location (point)) (current-buffer)) 1357 (set-marker (mark-marker) (or location (point)) (current-buffer))
1357 ;; Now push the mark on the global mark ring. 1358 ;; Now push the mark on the global mark ring.
1358 (setq global-mark-ring (cons (copy-marker (mark-marker)) global-mark-ring)) 1359 (if (and global-mark-ring
1360 (eq (marker-buffer (car global-mark-ring) (current-buffer))))
1361 ;; The last global mark pushed was in this same buffer.
1362 ;; Don't push another one.
1363 nil
1364 (setq global-mark-ring (cons (copy-marker (mark-marker)) global-mark-ring))
1359 (if (> (length global-mark-ring) global-mark-ring-max) 1365 (if (> (length global-mark-ring) global-mark-ring-max)
1360 (progn 1366 (progn
1361 (move-marker (car (nthcdr global-mark-ring-max global-mark-ring)) 1367 (move-marker (car (nthcdr global-mark-ring-max global-mark-ring))
1362 nil) 1368 nil)
1363 (setcdr (nthcdr (1- global-mark-ring-max) global-mark-ring) nil))) 1369 (setcdr (nthcdr (1- global-mark-ring-max) global-mark-ring) nil))))
1364 (or nomsg executing-macro (> (minibuffer-depth) 0) 1370 (or nomsg executing-macro (> (minibuffer-depth) 0)
1365 (message "Mark set")) 1371 (message "Mark set"))
1366 (if (or activate (not transient-mark-mode)) 1372 (if (or activate (not transient-mark-mode))
1367 (set-mark (mark t))) 1373 (set-mark (mark t)))
1368 nil) 1374 nil)