changeset 76653:ec11e047c06e

(viper-non-hook-settings): Handle mouse clicks in describe-key and describe-key-briefly advice a little better.
author Chong Yidong <cyd@stupidchicken.com>
date Wed, 21 Mar 2007 16:18:25 +0000
parents 4a84a019a748
children f8e66b19be2c
files lisp/emulation/viper.el
diffstat 1 files changed, 36 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/emulation/viper.el	Wed Mar 21 16:18:16 2007 +0000
+++ b/lisp/emulation/viper.el	Wed Mar 21 16:18:25 2007 +0000
@@ -1027,14 +1027,46 @@
 
   (defadvice describe-key (before viper-describe-key-ad protect activate)
     "Force to read key via `viper-read-key-sequence'."
-    (interactive (list (viper-read-key-sequence "Describe key: "))
-		 ))
+    (interactive (let (key)
+		   (setq key (viper-read-key-sequence
+			      "Describe key (or click or menu item): "))
+		   (list key
+			 (prefix-numeric-value current-prefix-arg)
+			 ;; If KEY is a down-event, read also the
+			 ;; corresponding up-event.
+			 (and (vectorp key)
+			      (let ((last-idx (1- (length key))))
+				(and (eventp (aref key last-idx))
+				     (memq 'down (event-modifiers
+						  (aref key last-idx)))))
+			      (or (and (eventp (aref key 0))
+				       (memq 'down (event-modifiers
+						    (aref key 0)))
+				       ;; For the C-down-mouse-2 popup
+				       ;; menu, there is no subsequent up-event.
+				       (= (length key) 1))
+				  (and (> (length key) 1)
+				       (eventp (aref key 1))
+				       (memq 'down (event-modifiers (aref key 1)))))
+			      (read-event))))))
 
   (defadvice describe-key-briefly
     (before viper-describe-key-briefly-ad protect activate)
     "Force to read key via `viper-read-key-sequence'."
-    (interactive (list (viper-read-key-sequence "Describe key briefly: "))))
-
+    (interactive (let (key)
+		   (setq key (viper-read-key-sequence
+			      "Describe key (or click or menu item): "))
+		   ;; If KEY is a down-event, read and discard the
+		   ;; corresponding up-event.
+		   (and (vectorp key)
+			(let ((last-idx (1- (length key))))
+			  (and (eventp (aref key last-idx))
+			       (memq 'down (event-modifiers (aref key last-idx)))))
+			(read-event))
+		   (list key
+			 (if current-prefix-arg
+			     (prefix-numeric-value current-prefix-arg))
+			 1))))
 
   (defadvice find-file (before viper-add-suffix-advice activate)
     "Use `read-file-name' for reading arguments."