From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Michael Heerdegen Newsgroups: gmane.emacs.help Subject: Re: I wish list-buffers used my current window when it listed my buffers Date: Thu, 15 Aug 2013 14:32:11 +0200 Message-ID: <87y5839ltg.fsf@web.de> References: <871u5vlfjr.fsf@ericabrahamsen.net> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1376570003 9435 80.91.229.3 (15 Aug 2013 12:33:23 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 15 Aug 2013 12:33:23 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Aug 15 14:33:22 2013 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1V9wjr-00045X-F2 for geh-help-gnu-emacs@m.gmane.org; Thu, 15 Aug 2013 14:33:15 +0200 Original-Received: from localhost ([::1]:53010 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V9wjr-0001Nb-3k for geh-help-gnu-emacs@m.gmane.org; Thu, 15 Aug 2013 08:33:15 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:54408) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V9wjb-0001ER-Sw for help-gnu-emacs@gnu.org; Thu, 15 Aug 2013 08:33:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V9wjU-00066h-7t for help-gnu-emacs@gnu.org; Thu, 15 Aug 2013 08:32:59 -0400 Original-Received: from plane.gmane.org ([80.91.229.3]:33153) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V9wjU-00066V-0n for help-gnu-emacs@gnu.org; Thu, 15 Aug 2013 08:32:52 -0400 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1V9wjN-0003ZE-Tv for help-gnu-emacs@gnu.org; Thu, 15 Aug 2013 14:32:45 +0200 Original-Received: from ip-90-186-10-202.web.vodafone.de ([90.186.10.202]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 15 Aug 2013 14:32:45 +0200 Original-Received: from michael_heerdegen by ip-90-186-10-202.web.vodafone.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 15 Aug 2013 14:32:45 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 89 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: ip-90-186-10-202.web.vodafone.de User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) Cancel-Lock: sha1:VIvFwHFfTPgapJP2V8f2wAbRL5k= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:92901 Archived-At: Eric Abrahamsen writes: > Rustom Mody 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.