From: Tak Kunihiro <tkk@misasa.okayama-u.ac.jp>
To: 35487@debbugs.gnu.org
Cc: tkk@misasa.okayama-u.ac.jp
Subject: bug#35487: Make visiting function from help-mode more customizable
Date: Mon, 29 Apr 2019 21:30:14 +0900 (JST) [thread overview]
Message-ID: <20190429.213014.526232842075202623.tkk@misasa.okayama-u.ac.jp> (raw)
* Message
I often want to visit function from help-mode in `this window' in
stead of `other window'. To do so, I found that to revise
help-function in help-function-def works.
I propose to (1) move help-function described as lambda function out
of button definition and (2) make function to visit function from
help-mode customizable.
After the revision, I can visit function from help-mode in `this
windows' as shown below.
#+begin_src emacs-lisp
(define-key help-mode-map (kbd "f")
(lambda ()
(interactive)
(let ((help-switch-buffer-function 'switch-to-buffer))
(push-button))))
#+end_src
I attach commit log and patch.
* Commit log
Author: Tak Kunihiro <tkk@misasa.okayama-u.ac.jp>
Make visiting function from help-mode more customizable
* lisp/help-mode.el
(define-button-type): Move definition of help-function out.
(help-switch-buffer-function): Function to display buffer in help-mode.
(help-find-function): Define help-function using a new variable
`help-switch-buffer-function'.
* Patch
diff --git a/lisp/help-mode.el b/lisp/help-mode.el
index 6cc3f0d4f7..4e01e73181 100644
--- a/lisp/help-mode.el
+++ b/lisp/help-mode.el
@@ -192,32 +192,39 @@ 'help-customize-face
(define-button-type 'help-function-def
:supertype 'help-xref
- 'help-function (lambda (fun &optional file type)
- (or file
- (setq file (find-lisp-object-file-name fun type)))
- (if (not file)
- (message "Unable to find defining file")
- (require 'find-func)
- (when (eq file 'C-source)
- (setq file
- (help-C-file-name (indirect-function fun) 'fun)))
- ;; Don't use find-function-noselect because it follows
- ;; aliases (which fails for built-in functions).
- (let* ((location
- (find-function-search-for-symbol fun type file))
- (position (cdr location)))
- (pop-to-buffer (car location))
- (run-hooks 'find-function-after-hook)
- (if position
- (progn
- ;; Widen the buffer if necessary to go to this position.
- (when (or (< position (point-min))
- (> position (point-max)))
- (widen))
- (goto-char position))
- (message "Unable to find location in file")))))
+ 'help-function 'help-find-function
'help-echo (purecopy "mouse-2, RET: find function's definition"))
+(defvar help-switch-buffer-function 'pop-to-buffer
+ "Function to display buffer in help-mode.")
+
+(defun help-find-function (fun &optional file type)
+ "Find object shown in help-mode."
+ (or file
+ (setq file (find-lisp-object-file-name fun type)))
+ (if (not file)
+ (message "Unable to find defining file")
+ (require 'find-func)
+ (when (eq file 'C-source)
+ (setq file
+ (help-C-file-name (indirect-function fun) 'fun)))
+ ;; Don't use find-function-noselect because it follows
+ ;; aliases (which fails for built-in functions).
+ (let* ((location
+ (find-function-search-for-symbol fun type file))
+ (position (cdr location)))
+ ;; (pop-to-buffer (car location))
+ (funcall help-switch-buffer-function (car location))
+ (run-hooks 'find-function-after-hook)
+ (if position
+ (progn
+ ;; Widen the buffer if necessary to go to this position.
+ (when (or (< position (point-min))
+ (> position (point-max)))
+ (widen))
+ (goto-char position))
+ (message "Unable to find location in file")))))
+
(define-button-type 'help-function-cmacro ; FIXME: Obsolete since 24.4.
:supertype 'help-xref
'help-function (lambda (fun file)
next reply other threads:[~2019-04-29 12:30 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-29 12:30 Tak Kunihiro [this message]
2019-04-29 19:54 ` bug#35487: Make visiting function from help-mode more customizable Juri Linkov
2019-05-09 23:10 ` Tak Kunihiro
2019-05-10 8:00 ` martin rudalics
2019-05-11 20:42 ` Juri Linkov
2019-05-16 8:52 ` Tak Kunihiro
2019-05-16 20:25 ` Stefan Monnier
2019-05-17 10:03 ` Tak Kunihiro
2019-05-28 21:09 ` Juri Linkov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190429.213014.526232842075202623.tkk@misasa.okayama-u.ac.jp \
--to=tkk@misasa.okayama-u.ac.jp \
--cc=35487@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.