From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Antoine Levitt Newsgroups: gmane.emacs.devel Subject: Re: other-buffer advice on kill-buffer Date: Tue, 02 Aug 2011 01:19:46 +0200 Message-ID: <87d3go4t4d.fsf@gmail.com> References: <8662mgg2ea.fsf@gmail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: dough.gmane.org 1312240827 24452 80.91.229.12 (1 Aug 2011 23:20:27 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 1 Aug 2011 23:20:27 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Aug 02 01:20:23 2011 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Qo1mV-00078V-Rp for ged-emacs-devel@m.gmane.org; Tue, 02 Aug 2011 01:20:20 +0200 Original-Received: from localhost ([::1]:41077 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qo1mV-0004PQ-98 for ged-emacs-devel@m.gmane.org; Mon, 01 Aug 2011 19:20:19 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:58978) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qo1mS-0004P5-1k for emacs-devel@gnu.org; Mon, 01 Aug 2011 19:20:16 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Qo1mQ-0004Pu-Ab for emacs-devel@gnu.org; Mon, 01 Aug 2011 19:20:15 -0400 Original-Received: from lo.gmane.org ([80.91.229.12]:37824) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qo1mQ-0004Pc-1h for emacs-devel@gnu.org; Mon, 01 Aug 2011 19:20:14 -0400 Original-Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1Qo1mN-00076g-IS for emacs-devel@gnu.org; Tue, 02 Aug 2011 01:20:11 +0200 Original-Received: from uni14-1-82-233-220-106.fbx.proxad.net ([82.233.220.106]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 02 Aug 2011 01:20:11 +0200 Original-Received: from antoine.levitt by uni14-1-82-233-220-106.fbx.proxad.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 02 Aug 2011 01:20:11 +0200 X-Injected-Via-Gmane: http://gmane.org/ Mail-Followup-To: emacs-devel@gnu.org Original-Lines: 35 Original-X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: uni14-1-82-233-220-106.fbx.proxad.net Mail-Copies-To: never User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 80.91.229.12 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:142650 Archived-At: 02/08/11 01:03, Jérémy Compostella > All, > > I'm trying to modify the behavior of the kill-buffer function to fit my > needs. I would like to limit the list of eligible buffers used to select > the buffer which will be displayed in place of the killed buffer. > > I have tried to advice the other-buffer function which seems called > (Cf. buffer.c) but my advice is never called in this case. Indeed, my > other-buffer advice is correctly called on switch-to-buffer call but > never on kill-buffer call. > > So am I missing something ? > Is there a restriction on advices for C implemented function ? > How the kill-buffer function select the new displayed buffer ? Could I > really modify its behavior and how ? > > Thanks for your help. > > Jeremy Hi Jeremy, I believe you can't advice a C function (not sure). In any case, advice is generally best left as last resort. What's keeping you from defining your own my-kill-buffer that'd call kill-buffer (which would switch to the most recent buffer) and then do some buffer switching of your own? Also see the docstring of kill-buffer. In particular, the docstring tells you than it calls replace-buffer-in-windows, and then the source code for replace-buffer-in-windows tells you that it calls switch-to-prev-buffer. So if you must advice or redefine an emacs function, these two look like better access points. Just out of curiosity, what buffers are you trying to exclude?