From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Emanuel Berg Newsgroups: gmane.emacs.help Subject: Re: file mode synonymous with major mode Date: Fri, 29 Mar 2024 02:14:53 +0100 Message-ID: <87le61x2ia.fsf@dataswamp.org> References: <867chmmzwp.fsf@p200300d62732bb94c15e79ce9a9ec518.dip0.t-ipconnect.de> <87h6gqf9g9.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="2614"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) To: help-gnu-emacs@gnu.org Cancel-Lock: sha1:APtZVdIl5NalplKPcoQxnOif/xE= Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Sun Mar 31 12:54:39 2024 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 1rqsph-0000Pn-ND for geh-help-gnu-emacs@m.gmane-mx.org; Sun, 31 Mar 2024 12:54:37 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rqspQ-0005q0-Kp; Sun, 31 Mar 2024 06:54:20 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rq0pk-0000Et-Ub for help-gnu-emacs@gnu.org; Thu, 28 Mar 2024 21:15:08 -0400 Original-Received: from ciao.gmane.io ([116.202.254.214]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rq0pj-0005ea-22 for help-gnu-emacs@gnu.org; Thu, 28 Mar 2024 21:15:04 -0400 Original-Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1rq0pf-0006No-KI for help-gnu-emacs@gnu.org; Fri, 29 Mar 2024 02:14:59 +0100 X-Injected-Via-Gmane: http://gmane.org/ Mail-Followup-To: help-gnu-emacs@gnu.org Mail-Copies-To: never Received-SPF: pass client-ip=116.202.254.214; envelope-from=geh-help-gnu-emacs@m.gmane-mx.org; helo=ciao.gmane.io X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, HEADER_FROM_DIFFERENT_DOMAINS=0.249, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Sun, 31 Mar 2024 06:54:14 -0400 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 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-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.help:146202 Archived-At: tpeplt wrote: >>> Reading the emacs manual '24.3 Choosing File Modes'. Is it >>> correct to assert that the file mode is synonymous with >>> the major mode ? >>> >>> https://www.gnu.org/software/emacs/manual/html_node/emacs/Choosing-Modes.html >> >> Given that that page talks about both major and minor >> modes, I'd say no. It rather refers to any modes activated >> for a specific file. >> >> Note that it's hardly an issue. "File mode" does not have >> any specific meaning in Emacs (unlike major and minor >> mode), so I wouldn't worry about it too much. (In fact, >> going through the manual, there appears to be another use >> of the term "file mode", referring to what is more commonly >> called "file permissions": see (info "(emacs) Misc File >> Ops").) > > Also, the major mode that is in effect for a given buffer > may have nothing to do with ANY file. For example, the > *scratch* buffer and Help buffers have no file associated > with them, but both have a major mode. [...] I think you are over-theorizing around a supposed concept that actually isn't really there or, if it is, is much better tackled from a/the practical angle. Buffer have modes and filenames are the best ways to set them. If it doesn't happen automatically, use Elisp as below to set it based on the file extension (filename suffix). If that cannot happen the file name can be used in full, there is an example of that below. If everything fails or cannot be done (why?), use file local variable as described here as the last way: (info "(emacs) Specifying File Variables") [Note: As good as using the filename are using unique elements in the file that appear naturally, e.g. the hashbang initial line of shell scripts - for example "#! /bin/zsh" for zsh - as you want that anyway, it is even better that Emacs can just use it to set the buffer to the correct mode when you find the file.] ;;; -*- lexical-binding: t -*- ;; ;; this file: ;; https://dataswamp.org/~incal/emacs-init/mode-by-filename.el (setq auto-mode-alist `( ("\\.bal\\'" . balance-mode) ("\\.cl\\'" . common-lisp-mode) ("\\.dat\\'" . gnuplot-mode) ("\\.gpi\\'" . gnuplot-mode) ("\\.grm\\'" . sml-mode) ("\\.lu\\'" . lua-mode) ("\\.nqp\\'" . perl-mode) ("\\.php\\'" . html-mode) ("\\.pic\\'" . nroff-mode) ("\\.pl\\'" . prolog-mode) ("\\.sed\\'" . conf-mode) ("\\.service\\'" . conf-mode) ("\\.tap\\'" . gcode-mode) ("\\.tex\\'" . latex-mode) ("\\.xr\\'" . conf-xdefaults-mode) ("torrc\\'" . conf-mode) ("keys\\'" . conf-mode) ("DOS\\'" . text-mode) ,@auto-mode-alist) ) (provide 'mode-by-filename) -- underground experts united https://dataswamp.org/~incal