|
From: | Kevin Rodgers |
Subject: | Re: emacs mode line suggestions |
Date: | Tue, 18 Nov 2008 02:32:00 -0700 |
User-agent: | Thunderbird 2.0.0.17 (Macintosh/20080914) |
Alan Mackenzie wrote:
Usually, creating a new file with C-x C-f already switches on the right mode. And even if Emacs somehow gets this wrong, it's a one-time event for that buffer.However, if I create a new buffer with C-x C-b foo.c, it starts in Fundamental Mode, not C Mode. Is there a good reason for this, or did it just happen? It irritates me quite a bit, but not quite enough to bring me to fixing it. ;-)
I think the reason is that auto-mode-alist applies only to file names. I suppose it is arguable whether that is a good reason or not, but "fixing" it to apply to buffer names would be a pretty far-reaching change. Maybe this would work for you: (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))))) -- Kevin Rodgers Denver, Colorado, USA
[Prev in Thread] | Current Thread | [Next in Thread] |