From: Juri Linkov <juri@jurta.org>
To: "Drew Adams" <drew.adams@oracle.com>
Cc: 'Kevin Rodgers' <kevin.d.rodgers@gmail.com>, emacs-devel@gnu.org
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 [thread overview]
Message-ID: <87iqf8qact.fsf@mail.jurta.org> (raw)
In-Reply-To: <2460C0DD06EE4E898D61D81BA77529C4@us.oracle.com> (Drew Adams's message of "Wed, 23 Sep 2009 20:14:14 -0700")
>> (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/
next prev parent reply other threads:[~2009-09-24 21:32 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-09-22 14:31 new buffer - should its mode reflect its name when the name matches auto-mode-alist? Drew Adams
2009-09-22 14:47 ` Deniz Dogan
2009-09-22 15:07 ` Drew Adams
2009-09-23 20:50 ` Mathias Dahl
2009-09-24 21:07 ` Juri Linkov
2009-09-24 2:31 ` Kevin Rodgers
2009-09-24 3:14 ` Drew Adams
2009-09-24 21:32 ` Juri Linkov [this message]
2009-09-24 22:01 ` Drew Adams
2009-09-25 0:38 ` Stefan Monnier
2009-09-25 9:04 ` Juri Linkov
2009-09-25 14:16 ` Stefan Monnier
2009-09-29 23:11 ` Juri Linkov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87iqf8qact.fsf@mail.jurta.org \
--to=juri@jurta.org \
--cc=drew.adams@oracle.com \
--cc=emacs-devel@gnu.org \
--cc=kevin.d.rodgers@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).