aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1998-04-17 00:43:15 +0000
committerRichard M. Stallman1998-04-17 00:43:15 +0000
commit89ec7f07d158767b83ad4f7ed70e1729a25d64e4 (patch)
tree032620c74c6ad074c16f95e6186a5150bf7d6a2f
parent002ae4f99cb9a08a92da5d38d4f5d7f1c8d989a4 (diff)
downloademacs-89ec7f07d158767b83ad4f7ed70e1729a25d64e4.tar.gz
emacs-89ec7f07d158767b83ad4f7ed70e1729a25d64e4.zip
(find-function-on-key):
If definition is a list, don't call find-function-other-window. Handle mouse events (code copied from describe-key-briefly). (find-function-do-it): Doc fix. (find-function-noselect): Doc fix.
-rw-r--r--lisp/emacs-lisp/find-func.el42
1 files changed, 34 insertions, 8 deletions
diff --git a/lisp/emacs-lisp/find-func.el b/lisp/emacs-lisp/find-func.el
index e12d5c6cc61..026a3ad7bf8 100644
--- a/lisp/emacs-lisp/find-func.el
+++ b/lisp/emacs-lisp/find-func.el
@@ -82,7 +82,7 @@ default."
82;;; Functions: 82;;; Functions:
83 83
84(defun find-function-noselect (function &optional path) 84(defun find-function-noselect (function &optional path)
85 "Returns list `(buffer point)' pointing to the definition of FUNCTION. 85 "Returns list (BUFFER POINT) pointing to the definition of FUNCTION.
86 86
87Finds the Emacs Lisp library containing the definition of FUNCTION 87Finds the Emacs Lisp library containing the definition of FUNCTION
88in a buffer and places point before the definition. The buffer is 88in a buffer and places point before the definition. The buffer is
@@ -189,7 +189,7 @@ default function."
189 fn (intern val))))) 189 fn (intern val)))))
190 190
191(defun find-function-do-it (function path switch-fn) 191(defun find-function-do-it (function path switch-fn)
192 "find elisp FUNCTION in PATH and display it with SWITCH-FN. 192 "Find Emacs Lisp FUNCTION in PATH and display it with SWITCH-FN.
193Point is saved if FUNCTION is in the current buffer." 193Point is saved if FUNCTION is in the current buffer."
194 (let ((orig-point (point)) 194 (let ((orig-point (point))
195 (buffer-point (find-function-noselect function path))) 195 (buffer-point (find-function-noselect function path)))
@@ -248,12 +248,38 @@ defined is searched in PATH instead of `load-path'"
248 "Find the function that KEY invokes. KEY is a string. 248 "Find the function that KEY invokes. KEY is a string.
249Point is saved if FUNCTION is in the current buffer." 249Point is saved if FUNCTION is in the current buffer."
250 (interactive "kFind function on key: ") 250 (interactive "kFind function on key: ")
251 (let ((defn (key-binding key))) 251 ;; If this key seq ends with a down event, discard the
252 (if (or (null defn) (integerp defn)) 252 ;; following click or drag event. Otherwise that would
253 (message "%s is undefined" (key-description key)) 253 ;; erase an eventual message.
254 (if (and (consp defn) (not (eq 'lambda (car-safe defn)))) 254 (let ((type (aref key (1- (length key)))))
255 (message "runs %s" (prin1-to-string defn)) 255 (if (listp type) (setq type (car type)))
256 (find-function-other-window defn))))) 256 (and (symbolp type)
257 (memq 'down (event-modifiers type))
258 (read-event)))
259 (save-excursion
260 (let ((modifiers (event-modifiers (aref key 0)))
261 window position)
262 ;; For a mouse button event, go to the button it applies to
263 ;; to get the right key bindings. And go to the right place
264 ;; in case the keymap depends on where you clicked.
265 (if (or (memq 'click modifiers) (memq 'down modifiers)
266 (memq 'drag modifiers))
267 (setq window (posn-window (event-start (aref key 0)))
268 position (posn-point (event-start (aref key 0)))))
269 (if (windowp window)
270 (progn
271 (set-buffer (window-buffer window))
272 (goto-char position)))
273 ;; Ok, now look up the key and name the command.
274 (let ((defn (key-binding key)))
275 (if (or (null defn) (integerp defn))
276 (message "%s is undefined" (key-description key))
277 (if (consp defn)
278 (message (if (windowp window)
279 "%s at that spot runs %s"
280 "%s runs %s")
281 (key-description key) (prin1-to-string defn))
282 (find-function-other-window defn)))))))
257 283
258(provide 'find-func) 284(provide 'find-func)
259 285