From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Emanuel Berg via Users list for the GNU Emacs text editor Newsgroups: gmane.emacs.help Subject: Re: Set major mode for all visited files by extension Date: Sun, 03 May 2020 03:15:00 +0200 Message-ID: <87y2q9rf8r.fsf@ebih.ebihd> References: <82913dab-368c-f955-08cc-e22f8da3585e@akwebsoft.com> Reply-To: Emanuel Berg Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="70810"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) To: help-gnu-emacs@gnu.org Cancel-Lock: sha1:2EjsKsFIYQo9x0AseJQk3AwuJQI= Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Sun May 03 03:15:52 2020 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jV3EW-000IJN-K4 for geh-help-gnu-emacs@m.gmane-mx.org; Sun, 03 May 2020 03:15:52 +0200 Original-Received: from localhost ([::1]:44362 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jV3EV-0001iS-Lf for geh-help-gnu-emacs@m.gmane-mx.org; Sat, 02 May 2020 21:15:51 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:57844) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jV3Dp-0001Qx-0w for help-gnu-emacs@gnu.org; Sat, 02 May 2020 21:15:09 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jV3Do-0006vp-BP for help-gnu-emacs@gnu.org; Sat, 02 May 2020 21:15:08 -0400 Original-Received: from ciao.gmane.io ([159.69.161.202]:44028) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jV3Dn-0006uP-Q7 for help-gnu-emacs@gnu.org; Sat, 02 May 2020 21:15:08 -0400 Original-Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1jV3Dl-000HRe-KL for help-gnu-emacs@gnu.org; Sun, 03 May 2020 03:15:05 +0200 X-Injected-Via-Gmane: http://gmane.org/ Mail-Followup-To: help-gnu-emacs@gnu.org Mail-Copies-To: never Received-SPF: pass client-ip=159.69.161.202; envelope-from=geh-help-gnu-emacs@m.gmane-mx.org; helo=ciao.gmane.io X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/02 19:58:34 X-ACL-Warn: Detected OS = Linux 3.11 and newer [fuzzy] X-Received-From: 159.69.161.202 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:123001 Archived-At: 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