* Set major mode for all visited files by extension
@ 2020-05-03 1:00 Tim Johnson
2020-05-03 1:15 ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-05-04 21:33 ` Set major mode for all visited files by extension Tim Johnson
0 siblings, 2 replies; 16+ messages in thread
From: Tim Johnson @ 2020-05-03 1:00 UTC (permalink / raw)
To: MLEmacs
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?
Thanks
--
Tim
tj49.com
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Set major mode for all visited files by extension
2020-05-03 1:00 Set major mode for all visited files by extension Tim Johnson
@ 2020-05-03 1:15 ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-05-03 15:37 ` Tim Johnson
2020-05-04 21:33 ` Set major mode for all visited files by extension Tim Johnson
1 sibling, 1 reply; 16+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2020-05-03 1:15 UTC (permalink / raw)
To: help-gnu-emacs
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...
> 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:
;;; http://user.it.uu.se/~embe8573/emacs-init/mode-by-filename.el
;;; https://dataswamp.org/~incal/emacs-init/mode-by-filename.el
(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?
> 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!
--
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Set major mode for all visited files by extension
2020-05-03 1:15 ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2020-05-03 15:37 ` Tim Johnson
2020-05-04 4:30 ` Emanuel Berg via Users list for the GNU Emacs text editor
0 siblings, 1 reply; 16+ messages in thread
From: Tim Johnson @ 2020-05-03 15:37 UTC (permalink / raw)
To: help-gnu-emacs
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:
> ;;; http://user.it.uu.se/~embe8573/emacs-init/mode-by-filename.el
> ;;; https://dataswamp.org/~incal/emacs-init/mode-by-filename.el
>
> (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.
thanks
>
>> 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!
>
--
Tim
tj49.com
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Set major mode for all visited files by extension
2020-05-03 15:37 ` Tim Johnson
@ 2020-05-04 4:30 ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-05-04 5:53 ` Jean-Christophe Helary
0 siblings, 1 reply; 16+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2020-05-04 4:30 UTC (permalink / raw)
To: help-gnu-emacs
Tim Johnson wrote:
> what are you using - if any - that handles
> session management?
Nah, I just have one Emacs instance and never kills
that. Well, it happens of course but not often.
The session management, it's supposed to solve the
problem of getting back to all the active buffers so
one doesn't have to open them every time?
I have shortcuts for all my favorite files by now so
that isn't a problem actually. Maybe there are packs
that facilitate and setup that as well, sounds
likely :)
--
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Set major mode for all visited files by extension
2020-05-04 4:30 ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2020-05-04 5:53 ` Jean-Christophe Helary
2020-05-04 6:09 ` update Emacs (was: Re: Set major mode for all visited files by extension) Emanuel Berg via Users list for the GNU Emacs text editor
0 siblings, 1 reply; 16+ messages in thread
From: Jean-Christophe Helary @ 2020-05-04 5:53 UTC (permalink / raw)
To: Help Gnu Emacs mailing list
> On May 4, 2020, at 13:30, Emanuel Berg via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org> wrote:
>
> Tim Johnson wrote:
>
>> what are you using - if any - that handles
>> session management?
>
> Nah, I just have one Emacs instance and never kills
> that. Well, it happens of course but not often.
How to you update Emacs ?
Jean-Christophe Helary
-----------------------------------------------
http://mac4translators.blogspot.com @brandelune
^ permalink raw reply [flat|nested] 16+ messages in thread
* update Emacs (was: Re: Set major mode for all visited files by extension)
2020-05-04 5:53 ` Jean-Christophe Helary
@ 2020-05-04 6:09 ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-05-04 6:20 ` Jean-Christophe Helary
2020-05-04 7:50 ` update Emacs Kévin Le Gouguec
0 siblings, 2 replies; 16+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2020-05-04 6:09 UTC (permalink / raw)
To: help-gnu-emacs
Jean-Christophe Helary wrote:
> How to you update Emacs?
Interesting question, Emacs 26 is what's in the
Debian Buster repos (Debian GNU/Linux 10) so that's
what I have, specifically-specifically version
1:26.1+1-3.2+deb10u1 of the emacs package which
contains Emacs version
GNU Emacs 26.1 (build 2, x86_64-pc-linux-gnu) of
2019-09-23, modified by Debian
I don't know, how is one suppose to update it?
Speaking of this, /etc/apt/sources.list don't get
a pretty font-lock anymore. IINM this was once in the
emacs-goodies-el (Debian) pack but that must have
changed since I have it.
nano(1) have this out of the box BTW so I suppose all
things considered Emacs isn't the world's best editor
after all :(
--
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: update Emacs (was: Re: Set major mode for all visited files by extension)
2020-05-04 6:09 ` update Emacs (was: Re: Set major mode for all visited files by extension) Emanuel Berg via Users list for the GNU Emacs text editor
@ 2020-05-04 6:20 ` Jean-Christophe Helary
2020-05-04 7:50 ` update Emacs Kévin Le Gouguec
1 sibling, 0 replies; 16+ messages in thread
From: Jean-Christophe Helary @ 2020-05-04 6:20 UTC (permalink / raw)
To: Help Gnu Emacs mailing list
> On May 4, 2020, at 15:09, Emanuel Berg via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org> wrote:
>
> Jean-Christophe Helary wrote:
>
>> How to you update Emacs?
>
> Interesting question, Emacs 26 is what's in the
> Debian Buster repos (Debian GNU/Linux 10) so that's
> what I have, specifically-specifically version
> 1:26.1+1-3.2+deb10u1 of the emacs package which
> contains Emacs version
>
> GNU Emacs 26.1 (build 2, x86_64-pc-linux-gnu) of
> 2019-09-23, modified by Debian
>
> I don't know, how is one suppose to update it?
Sorry, I mean that when you update Emacs you have to kill your running instance, correct ? Because a new version of Emacs contains code that can't simply be reinterpreted live, right ?
Jean-Christophe Helary
-----------------------------------------------
http://mac4translators.blogspot.com @brandelune
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: update Emacs
2020-05-04 6:09 ` update Emacs (was: Re: Set major mode for all visited files by extension) Emanuel Berg via Users list for the GNU Emacs text editor
2020-05-04 6:20 ` Jean-Christophe Helary
@ 2020-05-04 7:50 ` Kévin Le Gouguec
2020-05-05 2:38 ` Emanuel Berg via Users list for the GNU Emacs text editor
1 sibling, 1 reply; 16+ messages in thread
From: Kévin Le Gouguec @ 2020-05-04 7:50 UTC (permalink / raw)
To: help-gnu-emacs
Emanuel Berg via Users list for the GNU Emacs text editor
<help-gnu-emacs@gnu.org> writes:
> Speaking of this, /etc/apt/sources.list don't get
> a pretty font-lock anymore. IINM this was once in the
> emacs-goodies-el (Debian) pack but that must have
> changed since I have it.
Have you tried debian-el?
https://packages.debian.org/buster/debian-el
From what I can read on packages.debian.org, up until Debian stretch it
was indeed generated from the emacs-goodies-el source package, though
AFAICT there was no dependency (/recommendation/suggestion) between the
binary packages debian-el and emacs-goodies-el.
(I'm on OpenSUSE here, so trying it out will be somewhat involved.)
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: update Emacs
2020-05-04 7:50 ` update Emacs Kévin Le Gouguec
@ 2020-05-05 2:38 ` Emanuel Berg via Users list for the GNU Emacs text editor
0 siblings, 0 replies; 16+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2020-05-05 2:38 UTC (permalink / raw)
To: help-gnu-emacs
Kévin Le Gouguec wrote:
>> Speaking of this, /etc/apt/sources.list don't get
>> a pretty font-lock anymore. IINM this was once in
>> the emacs-goodies-el (Debian) pack but that must
>> have changed since I have it.
>
> Have you tried debian-el?
>
> https://packages.debian.org/buster/debian-el
>
> From what I can read on packages.debian.org, up
> until Debian stretch it was indeed generated from
> the emacs-goodies-el source package, though AFAICT
> there was no dependency
> (/recommendation/suggestion) between the binary
> packages debian-el and emacs-goodies-el.
Here is what it says of debian-el with 'aptitude
show':
The debian-el emacs addon has been elpafied.
This dummy package helps ease transition from
debian-el to elpa-debian-el.
And elpa-debian-el:
apt-sources - major mode for editing Debian
sources.list files; apt-utils - interface to APT
(Debian package management); debian-bug - an Emacs
command to submit a bug report; deb-view - view
contents of Debian package, similarly to tar-mode;
gnus-BTS - provides buttons for bug numbers seen in
Gnus messages; preseed - major mode for editing
debian-installer preseed files.
And yes, I can confirm that it works :) So
apt-sources has been moved between the packages
it seems.
Thanks!
--
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Set major mode for all visited files by extension
2020-05-03 1:00 Set major mode for all visited files by extension Tim Johnson
2020-05-03 1:15 ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2020-05-04 21:33 ` Tim Johnson
2020-05-05 7:42 ` Yuri Khan
1 sibling, 1 reply; 16+ messages in thread
From: Tim Johnson @ 2020-05-04 21:33 UTC (permalink / raw)
To: help-gnu-emacs
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"
(interactive)
(let ((curfile (buffer-file-name)))
(kill-this-buffer)
(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 ...
--
Tim
tj49.com
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Set major mode for all visited files by extension
2020-05-04 21:33 ` Set major mode for all visited files by extension Tim Johnson
@ 2020-05-05 7:42 ` Yuri Khan
2020-05-05 17:49 ` Stefan Monnier
2020-05-05 17:53 ` Tim Johnson
0 siblings, 2 replies; 16+ messages in thread
From: Yuri Khan @ 2020-05-05 7:42 UTC (permalink / raw)
To: Tim Johnson; +Cc: help-gnu-emacs
On Tue, 5 May 2020 at 04:33, Tim Johnson <tim@akwebsoft.com> wrote:
> (defun reload-buffer ()
> "Reload the current buffer"
> (interactive)
> (let ((curfile (buffer-file-name)))
> (kill-this-buffer)
> (find-file curfile)))
The built-in (revert-buffer), which I have bound to C-<f5>, works for
me in similar cases (but I don’t use session.el, just desktop.el).
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Set major mode for all visited files by extension
2020-05-05 7:42 ` Yuri Khan
@ 2020-05-05 17:49 ` Stefan Monnier
2020-05-05 17:53 ` Tim Johnson
1 sibling, 0 replies; 16+ messages in thread
From: Stefan Monnier @ 2020-05-05 17:49 UTC (permalink / raw)
To: help-gnu-emacs
>> (defun reload-buffer ()
>> "Reload the current buffer"
>> (interactive)
>> (let ((curfile (buffer-file-name)))
>> (kill-this-buffer)
>> (find-file curfile)))
>
> The built-in (revert-buffer), which I have bound to C-<f5>, works for
> me in similar cases (but I don’t use session.el, just desktop.el).
BTW, if you only want to (re)set the major mode but not reload the buffer's
contents, then `normal-mode` is the function you likely want to call.
Stefan
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Set major mode for all visited files by extension
2020-05-05 7:42 ` Yuri Khan
2020-05-05 17:49 ` Stefan Monnier
@ 2020-05-05 17:53 ` Tim Johnson
2020-05-05 18:47 ` Perry Smith
1 sibling, 1 reply; 16+ messages in thread
From: Tim Johnson @ 2020-05-05 17:53 UTC (permalink / raw)
To: help-gnu-emacs
On 5/4/20 11:42 PM, Yuri Khan wrote:
> On Tue, 5 May 2020 at 04:33, Tim Johnson <tim@akwebsoft.com> wrote:
>
>> (defun reload-buffer ()
>> "Reload the current buffer"
>> (interactive)
>> (let ((curfile (buffer-file-name)))
>> (kill-this-buffer)
>> (find-file curfile)))
> The built-in (revert-buffer), which I have bound to C-<f5>, works for
> me in similar cases (but I don’t use session.el, just desktop.el).
>
I think they are the same, for sure. I've used emacs for 20 years, and I
don't even remember why I wrote that. :)
--
Tim
tj49.com
^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2020-05-05 22:57 UTC | newest]
Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-05-03 1:00 Set major mode for all visited files by extension Tim Johnson
2020-05-03 1:15 ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-05-03 15:37 ` Tim Johnson
2020-05-04 4:30 ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-05-04 5:53 ` Jean-Christophe Helary
2020-05-04 6:09 ` update Emacs (was: Re: Set major mode for all visited files by extension) Emanuel Berg via Users list for the GNU Emacs text editor
2020-05-04 6:20 ` Jean-Christophe Helary
2020-05-04 7:50 ` update Emacs Kévin Le Gouguec
2020-05-05 2:38 ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-05-04 21:33 ` Set major mode for all visited files by extension Tim Johnson
2020-05-05 7:42 ` Yuri Khan
2020-05-05 17:49 ` Stefan Monnier
2020-05-05 17:53 ` Tim Johnson
2020-05-05 18:47 ` Perry Smith
2020-05-05 19:20 ` Drew Adams
2020-05-05 22:57 ` Tim Johnson
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.