help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: I wish list-buffers used my current window when it listed my buffers


From: Eric Abrahamsen
Subject: Re: I wish list-buffers used my current window when it listed my buffers
Date: Thu, 15 Aug 2013 20:59:56 +0800
User-agent: Gnus/5.130008 (Ma Gnus v0.8) Emacs/24.3 (gnu/linux)

Michael Heerdegen <michael_heerdegen@web.de> writes:

> 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:
>
> (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"))
>
> To change the behavior, you have to redefine the button, replacing
> `pop-to-buffer' with your own function.
>
> Personally, I use this:
>
> (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")))
>
> where `my-find-symbol-switch-to-buffer' does what I want (i use it also
> for "find-func.el" stuff).
>
>
> Michael.

Excellent, thanks very much both for the doc link and the code snippet!
I'll give this a whirl.

E




reply via email to

[Prev in Thread] Current Thread [Next in Thread]