From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Kevin Rodgers Newsgroups: gmane.emacs.devel Subject: Re: new buffer - should its mode reflect its name when the name matches auto-mode-alist? Date: Wed, 23 Sep 2009 20:31:45 -0600 Message-ID: References: <7b501d5c0909220747m71565340m36be3026f91f5db8@mail.gmail.com> <230CB35D6D9A419EB943F0A276A78B72@us.oracle.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1253759533 14042 80.91.229.12 (24 Sep 2009 02:32:13 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 24 Sep 2009 02:32:13 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Sep 24 04:32:06 2009 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1Mqe7p-0007uy-U1 for ged-emacs-devel@m.gmane.org; Thu, 24 Sep 2009 04:32:06 +0200 Original-Received: from localhost ([127.0.0.1]:38961 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Mqe7p-0004OZ-Ab for ged-emacs-devel@m.gmane.org; Wed, 23 Sep 2009 22:32:05 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Mqe7j-0004OP-4j for emacs-devel@gnu.org; Wed, 23 Sep 2009 22:31:59 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Mqe7e-0004No-K2 for emacs-devel@gnu.org; Wed, 23 Sep 2009 22:31:58 -0400 Original-Received: from [199.232.76.173] (port=40238 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Mqe7e-0004Nl-E3 for emacs-devel@gnu.org; Wed, 23 Sep 2009 22:31:54 -0400 Original-Received: from lo.gmane.org ([80.91.229.12]:35166) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Mqe7e-0003tv-1S for emacs-devel@gnu.org; Wed, 23 Sep 2009 22:31:54 -0400 Original-Received: from list by lo.gmane.org with local (Exim 4.50) id 1Mqe7c-0007sJ-AW for emacs-devel@gnu.org; Thu, 24 Sep 2009 04:31:52 +0200 Original-Received: from c-71-237-24-138.hsd1.co.comcast.net ([71.237.24.138]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 24 Sep 2009 04:31:52 +0200 Original-Received: from kevin.d.rodgers by c-71-237-24-138.hsd1.co.comcast.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 24 Sep 2009 04:31:52 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 40 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: c-71-237-24-138.hsd1.co.comcast.net User-Agent: Thunderbird 2.0.0.23 (Macintosh/20090812) In-Reply-To: <230CB35D6D9A419EB943F0A276A78B72@us.oracle.com> X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:115571 Archived-At: Drew Adams wrote: >>> Haven't thought about this before, but I wonder if the mode >>> should respect auto-mode-alist when you create a new buffer? >>> There's no doubt a good reason or >>> two why we don't do this - just wondering. >>> >>> E.g. `C-x b foo.el', where there is no existing buffer >>> foo.el. The mode is >>> Fundamental; should it be Emacs-Lisp instead? >>> >>> (I realize that a new buffer need not be intended to be >>> saved as a file.) >>> >> As an end-user and not having contributed anything to Emacs myself, I >> would expect the buffer to "respect" auto-mode-alist, i.e. set the >> mode depending on the buffer name. However, I think the default >> behavior when creating buffers non-interactively should *not* respect >> auto-mode-alist. > > Yes, I meant interactively only, but should have made that clear. Thx. I think I posted this in response to a request on gnu.emacs.help, back around 2008-11-18, but I can't find it via Google: (defadvice switch-to-buffer (around interactive-normal-mode activate) "When called interactively to create a new buffer not visiting a file, temporarily bind `buffer-file-name' and call `normal-mode'." (let ((existing-buffer (get-buffer (ad-get-arg 0)))) ad-do-it (when (and (interactive-p) (null existing-buffer) (null buffer-file-name)) (let ((buffer-file-name (expand-file-name (buffer-name)))) (normal-mode))))) Not appropriate for src/buffer.c of course, but you get the idea. -- Kevin Rodgers Denver, Colorado, USA