all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Kevin Rodgers <kevin.d.rodgers@gmail.com>
To: emacs-devel@gnu.org
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	[thread overview]
Message-ID: <h9elm9$dk6$1@ger.gmane.org> (raw)
In-Reply-To: <230CB35D6D9A419EB943F0A276A78B72@us.oracle.com>

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





  parent reply	other threads:[~2009-09-24  2:31 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 [this message]
2009-09-24  3:14       ` Drew Adams
2009-09-24 21:32         ` Juri Linkov
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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='h9elm9$dk6$1@ger.gmane.org' \
    --to=kevin.d.rodgers@gmail.com \
    --cc=emacs-devel@gnu.org \
    /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 external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.