From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.devel Subject: Re: new buffer - should its mode reflect its name when the name matches auto-mode-alist? Date: Fri, 25 Sep 2009 00:32:18 +0300 Organization: JURTA Message-ID: <87iqf8qact.fsf@mail.jurta.org> References: <7b501d5c0909220747m71565340m36be3026f91f5db8@mail.gmail.com> <230CB35D6D9A419EB943F0A276A78B72@us.oracle.com> <2460C0DD06EE4E898D61D81BA77529C4@us.oracle.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1253830151 3619 80.91.229.12 (24 Sep 2009 22:09:11 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 24 Sep 2009 22:09:11 +0000 (UTC) Cc: 'Kevin Rodgers' , emacs-devel@gnu.org To: "Drew Adams" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Sep 25 00:09:04 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 1MqwUp-0005qE-Mx for ged-emacs-devel@m.gmane.org; Fri, 25 Sep 2009 00:09:03 +0200 Original-Received: from localhost ([127.0.0.1]:57109 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MqwIL-0002ij-Hc for ged-emacs-devel@m.gmane.org; Thu, 24 Sep 2009 17:56:09 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MqwIG-0002gj-0u for emacs-devel@gnu.org; Thu, 24 Sep 2009 17:56:04 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MqwIB-0002Zg-Ba for emacs-devel@gnu.org; Thu, 24 Sep 2009 17:56:03 -0400 Original-Received: from [199.232.76.173] (port=51595 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MqwIB-0002ZY-74 for emacs-devel@gnu.org; Thu, 24 Sep 2009 17:55:59 -0400 Original-Received: from smtp-out2.starman.ee ([85.253.0.4]:43039 helo=mx2.starman.ee) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MqwIA-000426-HM for emacs-devel@gnu.org; Thu, 24 Sep 2009 17:55:58 -0400 X-Virus-Scanned: by Amavisd-New at mx2.starman.ee Original-Received: from mail.starman.ee (82.131.70.149.cable.starman.ee [82.131.70.149]) by mx2.starman.ee (Postfix) with ESMTP id EB49F3F415A; Fri, 25 Sep 2009 00:55:52 +0300 (EEST) In-Reply-To: <2460C0DD06EE4E898D61D81BA77529C4@us.oracle.com> (Drew Adams's message of "Wed, 23 Sep 2009 20:14:14 -0700") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (x86_64-pc-linux-gnu) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) 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:115597 Archived-At: >> (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. > > Yes, you did - I see it now. You posted it on 2009-11-18, with Subject "emacs > mode line suggestions". Do you mean "You will post it on 2009-11-18"? Well, until it's posted I'd like to present a way to do this without defadvice: Index: lisp/files.el =================================================================== RCS file: /sources/emacs/emacs/lisp/files.el,v retrieving revision 1.1083 diff -c -r1.1083 files.el *** lisp/files.el 21 Sep 2009 22:12:30 -0000 1.1083 --- lisp/files.el 24 Sep 2009 21:30:34 -0000 *************** *** 1190,1197 **** (set (make-local-variable 'icomplete-with-completion-tables) (cons rbts-completion-table icomplete-with-completion-tables)))) ! (read-buffer prompt (other-buffer (current-buffer)) ! (confirm-nonexistent-file-or-buffer))))) (defun switch-to-buffer-other-window (buffer-or-name &optional norecord) "Select the buffer specified by BUFFER-OR-NAME in another window. --- 1190,1202 ---- (set (make-local-variable 'icomplete-with-completion-tables) (cons rbts-completion-table icomplete-with-completion-tables)))) ! (let ((buffer (read-buffer prompt (other-buffer (current-buffer)) ! (confirm-nonexistent-file-or-buffer)))) ! (unless (get-buffer buffer) ! (with-current-buffer (get-buffer-create buffer) ! (let ((buffer-file-name (buffer-name))) ! (normal-mode)))) ! buffer)))) (defun switch-to-buffer-other-window (buffer-or-name &optional norecord) "Select the buffer specified by BUFFER-OR-NAME in another window. -- Juri Linkov http://www.jurta.org/emacs/