From: Michael Heerdegen <michael_heerdegen@web.de>
To: help-gnu-emacs@gnu.org
Subject: Re: I wish list-buffers used my current window when it listed my buffers
Date: Thu, 15 Aug 2013 14:32:11 +0200 [thread overview]
Message-ID: <87y5839ltg.fsf@web.de> (raw)
In-Reply-To: 871u5vlfjr.fsf@ericabrahamsen.net
Eric Abrahamsen <eric@ericabrahamsen.net> writes:
> Rustom Mody <rustompmody@gmail.com> writes:
>
> > On Thursday, August 15, 2013 7:32:50 AM UTC+5:30, Jay Cotton wrote:
> >> I've always wished list-buffers used my current window when it
> >> listed my
> >> buffers. I don't know why, but this rubbed me the wrong way
> >> immediately when
> >> I learned the command, and I've never been able to shake it.
> >
> > Does this work?
> >
> > (add-to-list 'same-window-buffer-names "*Buffer List*")
>
> Hey I was just thinking something similar about the *Help* buffer: I
> often look up docs for functions and variables, and then end up TAB-bing
> to the source file link and hitting return to see the definition.
>
> I like that the *Help* buffer itself opens a new window, but once I've
> got that new window I want the source file in question to re-use it,
> rather than going back and clobbering the window I was in.
>
> That's not quite the same thing as the OP's question, but it seems like
> a close cousin. I eventually found `display-buffer-alist' (I'm on 24.3),
> but the docstring for that is as confusing as any emacs docs I've ever
> read.
`display-buffer-alist': yes, it's not easy, and the docstring is not a
tutorial. Please read
(info "(elisp) Display Action Functions")
where it is explained well.
> Has anyone accomplished what I'm after?
I'm afraid that the buffer switching function is hardcoded in the button
definition in help-mode.el:
--8<---------------cut here---------------start------------->8---
(define-button-type 'help-function-def
:supertype 'help-xref
'help-function (lambda (fun 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 nil file)))
(pop-to-buffer (car location)) ; <--------------------
(if (cdr location)
(goto-char (cdr location))
(message "Unable to find location in file"))))
'help-echo (purecopy "mouse-2, RET: find function's definition"))
--8<---------------cut here---------------end--------------->8---
To change the behavior, you have to redefine the button, replacing
`pop-to-buffer' with your own function.
Personally, I use this:
--8<---------------cut here---------------start------------->8---
(with-eval-after-load 'help
(define-button-type 'help-function-def
:supertype 'help-xref
'help-function (lambda (fun 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 nil file)))
(my-find-symbol-switch-to-buffer (car location))
(if (cdr location)
(goto-char (cdr location))
(message "Unable to find location in file"))))
'help-echo (purecopy "mouse-2, RET: find function's definition")))
--8<---------------cut here---------------end--------------->8---
where `my-find-symbol-switch-to-buffer' does what I want (i use it also
for "find-func.el" stuff).
Michael.
next prev parent reply other threads:[~2013-08-15 12:32 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <mailman.11.1376532793.10748.help-gnu-emacs@gnu.org>
2013-08-15 3:42 ` I wish list-buffers used my current window when it listed my buffers Rustom Mody
2013-08-15 4:54 ` Eric Abrahamsen
2013-08-15 7:31 ` Thorsten Jolitz
2013-08-15 12:32 ` Michael Heerdegen [this message]
2013-08-15 12:59 ` Eric Abrahamsen
2013-08-15 2:02 Jay Cotton
2013-08-15 4:56 ` Bob Proulx
[not found] ` <mailman.16.1376542594.10748.help-gnu-emacs@gnu.org>
2013-08-15 12:45 ` Dan Espen
2013-08-15 23:23 ` Jay Cotton
2013-08-16 13:33 ` Michael Heerdegen
2013-08-16 13:33 ` Michael Heerdegen
2013-08-16 22:12 ` Jay Cotton
2013-08-16 23:24 ` Michael Heerdegen
[not found] ` <mailman.163.1376660121.10748.help-gnu-emacs@gnu.org>
2013-08-16 14:03 ` Dan Espen
2013-08-16 22:33 ` Jay Cotton
2013-08-16 22:51 ` Bob Proulx
2013-08-16 23:38 ` Jay Cotton
2013-08-20 23:07 ` Stefan Monnier
[not found] ` <mailman.447.1377040083.10748.help-gnu-emacs@gnu.org>
2013-08-21 4:51 ` Rustom Mody
2013-08-21 22:55 ` Bob Proulx
[not found] ` <mailman.532.1377125749.10748.help-gnu-emacs@gnu.org>
2013-08-22 4:44 ` Rustom Mody
2013-08-16 23:08 ` Michael Heerdegen
2013-08-16 23:44 ` Jay Cotton
2013-08-16 23:51 ` Jay Cotton
[not found] ` <mailman.210.1376693505.10748.help-gnu-emacs@gnu.org>
2013-08-16 23:14 ` Dan Espen
2013-08-19 3:41 ` Samuel Wales
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87y5839ltg.fsf@web.de \
--to=michael_heerdegen@web.de \
--cc=help-gnu-emacs@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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).