emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/visual-fill-column 48a3690b01 091/137: Add more bindings f


From: ELPA Syncer
Subject: [nongnu] elpa/visual-fill-column 48a3690b01 091/137: Add more bindings for mouse events in the margins.
Date: Sun, 2 Jan 2022 22:59:14 -0500 (EST)

branch: elpa/visual-fill-column
commit 48a3690b01c6dc414dc3a9a27b5d9046edf7b233
Author: Joost Kremers <joostkremers@fastmail.fm>
Commit: Joost Kremers <joostkremers@fastmail.fm>

    Add more bindings for mouse events in the margins.
    
    Suggested in Github issue #44.
---
 README.md             |  1 +
 visual-fill-column.el | 42 +++++++++++++++++++++++++++++++++---------
 2 files changed, 34 insertions(+), 9 deletions(-)

diff --git a/README.md b/README.md
index e03f52286a..a4b44bf58a 100644
--- a/README.md
+++ b/README.md
@@ -65,3 +65,4 @@ The customisation group `visual-fill-column` has three 
options (beside `global-v
 
 All three options are buffer-local, so the values you set in your init file 
are default values. They can also be set in mode hooks or directory or file 
local variables in order to customise particular files or file types.
 
+`visual-fill-column-mode` also binds several mouse events for the left and 
right margins, so that scrolling or clicking on the margins does what you'd 
expect (rather than cause an "event not bound" error). If you wish to adjust 
these bindings, you should do so in `visual-fill-column-mode-map`.
diff --git a/visual-fill-column.el b/visual-fill-column.el
index 1aa27a1fa5..d7bb77846b 100644
--- a/visual-fill-column.el
+++ b/visual-fill-column.el
@@ -66,19 +66,43 @@ this option is set to a value, it is used instead."
 (make-variable-buffer-local 'visual-fill-column-center-text)
 (put 'visual-fill-column-center-text 'safe-local-variable 'symbolp)
 
+(defvar visual-fill-column-mode-map
+  (let ((map (make-sparse-keymap)))
+    (define-key map [right-margin mouse-1] (global-key-binding [mouse-1])) ; 
#'mouse-set-point
+    (define-key map [right-margin mouse-2] (global-key-binding [mouse-2])) ; 
#'mouse-yank-primary
+    (define-key map [right-margin mouse-3] (global-key-binding [mouse-3])) ; 
#'mouse-save-then-kill
+    (define-key map [right-margin drag-mouse-1] #'ignore)
+    (define-key map [right-margin drag-mouse-2] #'ignore)
+    (define-key map [right-margin drag-mouse-3] #'ignore)
+    (define-key map [right-margin double-mouse-1] #'ignore)
+    (define-key map [right-margin double-mouse-2] #'ignore)
+    (define-key map [right-margin double-mouse-3] #'ignore)
+    (define-key map [right-margin triple-mouse-1] #'ignore)
+    (define-key map [right-margin triple-mouse-2] #'ignore)
+    (define-key map [right-margin triple-mouse-3] #'ignore)
+    (define-key map [left-margin mouse-1] (global-key-binding [mouse-1])) ; 
#'mouse-set-point
+    (define-key map [left-margin mouse-2] (global-key-binding [mouse-2])) ; 
#'mouse-yank-primary
+    (define-key map [left-margin mouse-3] (global-key-binding [mouse-3])) ; 
#'mouse-save-then-kill
+    (define-key map [left-margin drag-mouse-1] #'ignore)
+    (define-key map [left-margin drag-mouse-2] #'ignore)
+    (define-key map [left-margin drag-mouse-3] #'ignore)
+    (define-key map [left-margin double-mouse-1] #'ignore)
+    (define-key map [left-margin double-mouse-2] #'ignore)
+    (define-key map [left-margin double-mouse-3] #'ignore)
+    (define-key map [left-margin triple-mouse-1] #'ignore)
+    (define-key map [left-margin triple-mouse-2] #'ignore)
+    (define-key map [left-margin triple-mouse-3] #'ignore)
+    (when (bound-and-true-p mouse-wheel-mode)
+      (define-key map [right-margin mouse-wheel-down-event] #'mwheel-scroll)
+      (define-key map [right-margin mouse-wheel-up-event] #'mwheel-scroll)
+      (define-key map [left-margin mouse-wheel-down-event] #'mwheel-scroll)
+      (define-key map [left-margin mouse-wheel-up-event] #'mwheel-scroll))
+    map))
+
 ;;;###autoload
 (define-minor-mode visual-fill-column-mode
   "Wrap lines according to `fill-column' in `visual-line-mode'."
   :init-value nil :lighter nil :global nil
-  :keymap
-  (let ((map (make-sparse-keymap)))
-    (when (bound-and-true-p mouse-wheel-mode)
-      (progn
-        (define-key map (vector 'left-margin mouse-wheel-down-event) 
'mwheel-scroll)
-        (define-key map (vector 'left-margin mouse-wheel-up-event) 
'mwheel-scroll)
-        (define-key map (vector 'right-margin mouse-wheel-down-event) 
'mwheel-scroll)
-        (define-key map (vector 'right-margin mouse-wheel-up-event) 
'mwheel-scroll))
-      map))
   (if visual-fill-column-mode
       (visual-fill-column-mode--enable)
     (visual-fill-column-mode--disable)))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]