Function: find-function-on-key-do-it

find-function-on-key-do-it is a byte-compiled function defined in find-func.el.gz.

Signature

(find-function-on-key-do-it KEY FIND-FN)

Documentation

Find the function that KEY invokes. KEY is a string.

Set mark before moving, if the buffer already existed.

FIND-FN is the function to call to navigate to the function.

Source Code

;; Defined in /usr/src/emacs/lisp/emacs-lisp/find-func.el.gz
(defun find-function-on-key-do-it (key find-fn)
  "Find the function that KEY invokes.  KEY is a string.
Set mark before moving, if the buffer already existed.

FIND-FN is the function to call to navigate to the function."
  (let (defn)
    (save-excursion
      (let* ((event (and (eventp key) (aref key 0))) ; Null event OK below.
	     (start (event-start event))
	     (modifiers (event-modifiers event))
	     (window (and (or (memq 'click modifiers) (memq 'down modifiers)
			      (memq 'drag modifiers))
			  (posn-window start))))
	;; For a mouse button event, go to the button it applies to
	;; to get the right key bindings.  And go to the right place
	;; in case the keymap depends on where you clicked.
	(when (windowp window)
	  (set-buffer (window-buffer window))
	  (goto-char (posn-point start)))
	(setq defn (key-binding key))))
    (let ((key-desc (key-description key)))
      (if (or (null defn) (integerp defn))
	  (message "%s is unbound" key-desc)
	(if (consp defn)
	    (message "%s runs %s" key-desc (prin1-to-string defn))
	  (funcall find-fn defn))))))