From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eric Abrahamsen Newsgroups: gmane.emacs.help Subject: Re: I wish list-buffers used my current window when it listed my buffers Date: Thu, 15 Aug 2013 20:59:56 +0800 Message-ID: <87ioz7jeib.fsf@ericabrahamsen.net> References: <871u5vlfjr.fsf@ericabrahamsen.net> <87y5839ltg.fsf@web.de> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1376571599 28089 80.91.229.3 (15 Aug 2013 12:59:59 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 15 Aug 2013 12:59:59 +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 15:00:01 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 1V9x9k-0004r8-Om for geh-help-gnu-emacs@m.gmane.org; Thu, 15 Aug 2013 15:00:00 +0200 Original-Received: from localhost ([::1]:53146 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V9x9k-00053d-BX for geh-help-gnu-emacs@m.gmane.org; Thu, 15 Aug 2013 09:00:00 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:60294) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V9x9S-00052B-SS for help-gnu-emacs@gnu.org; Thu, 15 Aug 2013 08:59:49 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V9x9K-00088N-Tj for help-gnu-emacs@gnu.org; Thu, 15 Aug 2013 08:59:42 -0400 Original-Received: from plane.gmane.org ([80.91.229.3]:44034) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V9x9K-000886-NE for help-gnu-emacs@gnu.org; Thu, 15 Aug 2013 08:59:34 -0400 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1V9x9G-0004MN-8c for help-gnu-emacs@gnu.org; Thu, 15 Aug 2013 14:59:30 +0200 Original-Received: from 114.250.134.34 ([114.250.134.34]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 15 Aug 2013 14:59:30 +0200 Original-Received: from eric by 114.250.134.34 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 15 Aug 2013 14:59:30 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 92 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 114.250.134.34 User-Agent: Gnus/5.130008 (Ma Gnus v0.8) Emacs/24.3 (gnu/linux) Cancel-Lock: sha1:8tZvTug7ovtNbhuInbEqxcc1Kdo= 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:92903 Archived-At: Michael Heerdegen writes: > 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: > > (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