all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Emanuel Berg via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org>
To: help-gnu-emacs@gnu.org
Subject: Re: Set major mode for all visited files by extension
Date: Sun, 03 May 2020 03:15:00 +0200	[thread overview]
Message-ID: <87y2q9rf8r.fsf@ebih.ebihd> (raw)
In-Reply-To: 82913dab-368c-f955-08cc-e22f8da3585e@akwebsoft.com

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




  reply	other threads:[~2020-05-03  1:15 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

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=87y2q9rf8r.fsf@ebih.ebihd \
    --to=help-gnu-emacs@gnu.org \
    --cc=moasenwood@zoho.eu \
    /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.