From 0cee2fbc7db279c8e2a0e5719b1bc14b6cbb420b Mon Sep 17 00:00:00 2001 From: Dmitry Gutov Date: Mon, 22 Jun 2015 03:23:38 +0300 Subject: [PATCH] Make find-function-on-key use the current window * lisp/emacs-lisp/find-func.el (find-function-on-key-do-it): Extract from `find-function-on-key', add a second argument. (find-function-on-key): Use it (bug#19679). (find-function-on-key-other-window) (find-function-on-key-other-frame): New commands. --- lisp/emacs-lisp/find-func.el | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/lisp/emacs-lisp/find-func.el b/lisp/emacs-lisp/find-func.el index 54f8340862d..cd23cd77f4a 100644 --- a/lisp/emacs-lisp/find-func.el +++ b/lisp/emacs-lisp/find-func.el @@ -550,11 +550,11 @@ See also `find-function-recenter-line' and `find-function-after-hook'." (interactive (find-function-read 'defface)) (find-function-do-it face 'defface 'switch-to-buffer)) -;;;###autoload -(defun find-function-on-key (key) +(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." - (interactive "kFind function on key: ") +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. @@ -575,7 +575,28 @@ Set mark before moving, if the buffer already existed." (message "%s is unbound" key-desc) (if (consp defn) (message "%s runs %s" key-desc (prin1-to-string defn)) - (find-function-other-window defn)))))) + (funcall find-fn defn)))))) + +;;;###autoload +(defun find-function-on-key (key) + "Find the function that KEY invokes. KEY is a string. +Set mark before moving, if the buffer already existed." + (interactive "kFind function on key: ") + (find-function-on-key-do-it key #'find-function)) + +;;;###autoload +(defun find-function-on-key-other-window (key) + "Find, in the other window, the function that KEY invokes. +See `find-function-on-key'." + (interactive "kFind function on key: ") + (find-function-on-key-do-it key #'find-function-other-window)) + +;;;###autoload +(defun find-function-on-key-other-frame (key) + "Find, in the other frame, the function that KEY invokes. +See `find-function-on-key'." + (interactive "kFind function on key: ") + (find-function-on-key-do-it key #'find-function-other-frame)) ;;;###autoload (defun find-function-at-point () @@ -600,6 +621,8 @@ Set mark before moving, if the buffer already existed." (define-key ctl-x-4-map "F" 'find-function-other-window) (define-key ctl-x-5-map "F" 'find-function-other-frame) (define-key ctl-x-map "K" 'find-function-on-key) + (define-key ctl-x-4-map "K" 'find-function-on-key-other-window) + (define-key ctl-x-5-map "K" 'find-function-on-key-other-frame) (define-key ctl-x-map "V" 'find-variable) (define-key ctl-x-4-map "V" 'find-variable-other-window) (define-key ctl-x-5-map "V" 'find-variable-other-frame)) -- 2.39.2