--- lisp/simple.el +++ lisp/simple.el @@ -3455,7 +3455,11 @@ old mark position on local mark ring. Also push the old mark on global mark ring, if the previous mark was set in another buffer. -Immediately repeating this command activates `transient-mark-mode' temporarily. +When `transient-mark-mode' is off, immediately repeating this command +activates `transient-mark-mode' temporarily, immediately repeating it +again deactivates that temporary activation and the mark. When +`transient-mark-mode' is on, immediately repeating this command +deactivates the mark (mark having been activated by the preceding). With prefix argument \(e.g., \\[universal-argument] \\[set-mark-command]\), \ jump to the mark, and set the mark from @@ -3474,6 +3478,7 @@ Novice Emacs Lisp programmers often try to use the mark for the wrong purposes. See the documentation of `set-mark' for more information." (interactive "P") + (let ((last-transient-mark-mode transient-mark-mode)) (if (eq transient-mark-mode 'lambda) (setq transient-mark-mode nil)) (cond @@ -3496,11 +3501,20 @@ (setq this-command 'pop-to-mark-command) (pop-to-mark-command)) ((and (eq last-command 'set-mark-command) + mark-active (eq 'lambda last-transient-mark-mode)) + (deactivate-mark) + (setq transient-mark-mode nil) + (message "Disabled temporarily enabled Transient-mark-mode")) + ((and (eq last-command 'set-mark-command) mark-active (null transient-mark-mode)) (setq transient-mark-mode 'lambda) (message "Transient-mark-mode temporarily enabled")) + ((and (eq last-command 'set-mark-command) + mark-active (eq t transient-mark-mode)) + (deactivate-mark) + (message "Mark deactivated")) (t - (push-mark-command nil)))) + (push-mark-command nil))))) (defun push-mark (&optional location nomsg activate) "Set mark at LOCATION (point, by default) and push old mark on mark ring.