[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Set major mode for all visited files by extension

From: Tim Johnson
Subject: Re: Set major mode for all visited files by extension
Date: Mon, 4 May 2020 13:33:04 -0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0

On 5/2/20 5:00 PM, Tim Johnson wrote:
Using GNU Emacs 26.3, X toolkit

With my configuration, when I open emacs and load a session, it appears that a modified auto-mode-alist entry is consulted *after* the associated major-mode from the previous session is used and is therefore ignored.

A practical application is if I have been using the built-in elisp mode for .el files and then implement xah-elisp-mode, even if I code

(add-to-list 'auto-mode-alist '("\\.el$" . xah-elisp-mode))

in my init.el, the previously visited buffers that are automatically opened when I start emacs will still be in elisp-mode. The fix, of course is to invoke xah-elisp-mode from the minibuffer. This is certainly doable, even with multiple elisp buffers opened, but I'm always looking to eliminate redundancies.

It would be handy if there were a command that would set all visited buffers ending in a specific file extension to a specific mode. If such were available, it would come in handy for experimenting with alternative major modes.

Is there such a feature?
Since there does not appear to be such a feature, a simple fix is to reload init.el, or if testing, evaluate a temporary modification in scratch buffer
and run the following function which I have in my "general library"
(defun reload-buffer ()
  "Reload the current buffer"
  (let ((curfile (buffer-file-name)))
(find-file curfile)))

Which has a key binding, so all buffers can be updated fairly quickly.
Not to add to Emanuel's protestations, but the 'desktop package has the same issues.
Oh, well, case closed ...



reply via email to

[Prev in Thread] Current Thread [Next in Thread]