]> git.eshelyaron.com Git - emacs.git/commitdiff
Allow region-related context menu to be used on selected region with one click
authorJuri Linkov <juri@linkov.net>
Sun, 12 Sep 2021 17:55:57 +0000 (20:55 +0300)
committerJuri Linkov <juri@linkov.net>
Sun, 12 Sep 2021 17:55:57 +0000 (20:55 +0300)
* lisp/mouse.el (mouse-drag-track): Don't deactivate the mark for
the context menu invoked by down-mouse-3.

https://lists.gnu.org/archive/html/emacs-devel/2021-08/msg01577.html

lisp/mouse.el

index bd11ec50d57fab0ed9a878bb6d5606edd9ac8669..c107322815af9bb6409c15c9eb276b16ce8543eb 100644 (file)
@@ -1583,8 +1583,15 @@ The region will be defined with mark and point."
      t (lambda ()
          (setq track-mouse old-track-mouse)
          (setq auto-hscroll-mode auto-hscroll-mode-saved)
-         (deactivate-mark)
-         (pop-mark)))))
+         ;; Don't deactivate the mark when the context menu was invoked
+         ;; by down-mouse-3 immediately after down-mouse-1 and without
+         ;; releasing the mouse button with mouse-1. This allows to use
+         ;; region-related context menu to operate on the selected region.
+         (unless (and context-menu-mode
+                      (eq (car-safe (aref (this-command-keys-vector) 0))
+                          'down-mouse-3))
+           (deactivate-mark)
+           (pop-mark))))))
 
 (defun mouse--drag-set-mark-and-point (start click click-count)
   (let* ((range (mouse-start-end start click click-count))