[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: Sun, 3 May 2020 07:37:07 -0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.1

On 5/2/20 5:15 PM, Emanuel Berg via Users list for the GNU Emacs text editor wrote:
Tim Johnson wrote:

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
Yeah? This is stored somewhere? I don't like that...

I am using the 'session package, it creates a file called .session that lives in .emacs.d, thus the environment of the last session is saved, and subsequently restored when emacs is restarted.

Sorry, should have mentioned that.

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))
You keep track of what's already there? Maybe it's
the first hit that gets executed. But I suppose one
don't tell that .el files should be
`emacs-lisp-mode'. What mode do they turn up in?
If you just create a test.el, I mean?

I do this, it is more clear IMO:

;;; -*- lexical-binding: t -*-
;;; this file:

(let ((modes (list
      '("\\.bal\\'" . balance-mode)
      '("\\.gpi\\'" . gnuplot-mode)
      '("\\.lu\\'"  . lua-mode)
      '("\\.nqp\\'" . perl-mode)
      '("\\.php\\'" . html-mode)
      '("\\.pic\\'" . nroff-mode)
      '("\\.pl\\'"  . prolog-mode)
      '("\\.tex\\'" . latex-mode)
      '("\\.xr\\'"  . conf-xdefaults-mode)
      '("*"         . text-mode) )))
   (setf auto-mode-alist (nconc modes auto-mode-alist)) )

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.
No, that stinks, that should be automated.
I'm unfamiliar with this automatically opened
principle tho and if I have it (I don't think so)
I would like it inhibited, pretty please?

I think what Emanuel is saying is that the 'session package should have a configuration that consults with auto-mode-alist.

Emanuel, what are you using - if any - that handles session management.


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.
Sure you can iterate all the buffers and apply
commands but this is just doing it manually in
a sense (only faster and with less effort). B/c the
files should turn up in the desired mode w/o
any intervention!


reply via email to

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