From: Stefan Monnier Date: Tue, 11 Mar 2014 17:10:07 +0000 (-0400) Subject: * lisp/simple.el (set-mark): Ensure mark-active is nil if the mark is nil. X-Git-Tag: emacs-24.3.90~217 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=536a17e3c6e808e34f4a9477025f4000b7975fd5;p=emacs.git * lisp/simple.el (set-mark): Ensure mark-active is nil if the mark is nil. Deactivate the mark before setting it to nil. (activate-mark): Do nothing if region is already active. Fixes: debbugs:16975 --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 9accb51587e..1155b8a2533 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,9 @@ +2014-03-11 Stefan Monnier + + * simple.el (set-mark): Ensure mark-active is nil if the mark is nil + (bug#16975). Deactivate the mark before setting it to nil. + (activate-mark): Do nothing if region is already active. + 2014-03-11 Juanma Barranquero * frameset.el (frameset--target-display): Remove definition; declare. @@ -42,8 +48,8 @@ 2014-03-10 Leo Liu - * emacs-lisp/eldoc.el (eldoc-minibuffer-message): Clear - eldoc-last-message. (Bug#16920) + * emacs-lisp/eldoc.el (eldoc-minibuffer-message): + Clear eldoc-last-message. (Bug#16920) 2014-03-10 Stefan Monnier diff --git a/lisp/simple.el b/lisp/simple.el index f9447b1fff4..881a633f972 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -4392,12 +4392,12 @@ run `deactivate-mark-hook'." "Activate the mark. If NO-TMM is non-nil, leave `transient-mark-mode' alone." (when (mark t) - (unless (and mark-active transient-mark-mode) - (force-mode-line-update)) ;Refresh toolbar (bug#16382). - (setq mark-active t) - (unless (or transient-mark-mode no-tmm) - (setq transient-mark-mode 'lambda)) - (run-hooks 'activate-mark-hook))) + (unless (region-active-p) + (force-mode-line-update) ;Refresh toolbar (bug#16382). + (setq mark-active t) + (unless (or transient-mark-mode no-tmm) + (setq transient-mark-mode 'lambda)) + (run-hooks 'activate-mark-hook)))) (defun set-mark (pos) "Set this buffer's mark to POS. Don't use this function! @@ -4415,14 +4415,18 @@ To remember a location for internal use in the Lisp program, store it in a Lisp variable. Example: (let ((beg (point))) (forward-line 1) (delete-region beg (point)))." - - (set-marker (mark-marker) pos (current-buffer)) (if pos - (activate-mark 'no-tmm) + (progn + (set-marker (mark-marker) pos (current-buffer)) + (activate-mark 'no-tmm)) ;; Normally we never clear mark-active except in Transient Mark mode. ;; But when we actually clear out the mark value too, we must ;; clear mark-active in any mode. - (deactivate-mark t))) + (deactivate-mark t) + ;; `deactivate-mark' sometimes leaves mark-active non-nil, but + ;; it should never be nil if the mark is nil. + (setq mark-active nil) + (set-marker (mark-marker) nil))) (defcustom use-empty-active-region nil "Whether \"region-aware\" commands should act on empty regions.