help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Mode hooks for latex and tex files


From: Heime
Subject: Re: Mode hooks for latex and tex files
Date: Mon, 02 Dec 2024 20:44:04 +0000





Sent with Proton Mail secure email.

On Tuesday, December 3rd, 2024 at 8:29 AM, Heime via Users list for the GNU 
Emacs text editor <help-gnu-emacs@gnu.org> wrote:

> On Tuesday, December 3rd, 2024 at 8:17 AM, Arash Esbati arash@gnu.org wrote:
> 
> > Heime heimeborgia@protonmail.com writes:
> > 
> > > On Tuesday, December 3rd, 2024 at 1:17 AM, Arash Esbati arash@gnu.org 
> > > wrote:
> > > 
> > > > The only point you have to consider is that there are 2 major modes for
> > > > editing plain-tex and latex files:
> > > > 
> > > > • The modes bundled with Emacs (in tex-mode.el, do
> > > > 'M-x locate-library RET tex-mode RET') and
> > > > 
> > > > • the modes provided by AUCTeX (a package you must install from ELPA
> > > > first).
> > > > 
> > > > If you're using the former, use `plain-tex-mode-hook' or`
> > > > latex-mode-hook', and with the latter, set `plain-TeX-mode-hook' or`
> > > > LaTeX-mode-hook'.
> > > > 
> > > > `tex-mode-hook' and` TeX-mode-hook' are sort of meta-modes and not
> > > > intended for end users, so don't set them.
> > > 
> > > AUCTeX introduces unnecessary complexity by deviating from standard
> > > naming conventions for tool-related modes.
> > 
> > Which naming conventions are you referring to and where are they
> > described? The ones I'm aware of are written here[1] which read:
> > 
> > You should choose a short word to distinguish your program from other
> > Lisp programs. The names of all global symbols in your program, that
> > is the names of variables, constants, and functions, should begin with
> > that chosen prefix. Separate the prefix from the rest of the name with
> > a hyphen, ‘-’. This practice helps avoid name conflicts, since all
> > global variables in Emacs Lisp share the same name space, and all
> > functions share another name space.
> > 
> > AUCTeX uses camel-case prefix based on the file names, a sort of
> > MyLib-varname. As another example, you can grep through the gnus
> > sub-directory to see that not every hook defined there is prefixed with
> > 'gnus-'.
> > 
> > > Instead of adhering to the typical package-prefixed predicate style
> > > (e.g., auctex-tex-mode and auctex-latex-mode), it opts for
> > > inconsistent and unintuitive names.
> > 
> > This is one opinion; but AUCTeX developers had another one for the
> > prefix they used.
> 
> > > The use of plain-tex-mode instead of a unified tex-mode (as seen with
> > > latex-mode) adds further redundancy. Meta-modes not intended for
> > > direct user interaction should avoid using intuitive and general names
> > > like tex-mode, reserving such names for user-facing
> > > functionality. This inconsistency is unique to AUCTeX;
> > 
> > The mode names above (and the corresponding hooks) are all defined in
> > tex-mode.el which is distributed with Emacs; they don't belong to
> > AUCTeX:
> > 
> > $ grep define-derived-mode tex-mode.el
> > (define-derived-mode tex-mode text-mode "generic-TeX"
> > (define-derived-mode plain-tex-mode tex-mode "TeX"
> > (define-derived-mode latex-mode tex-mode "LaTeX"
> > (define-derived-mode slitex-mode latex-mode "SliTeX"
> > (define-derived-mode tex-shell shell-mode "TeX-Shell"
> > (define-derived-mode doctex-mode latex-mode "DocTeX"
> > 
> > As you can see, tex-mode.el breaks every "rule" you think you're
> > describing with "typical package-prefixed predicate style". A "mylib-"
> > prefix might be a natural choice for single file libraries, but it isn't
> > a must as long you get the prefix right.
> 
> 
> Correct, it breaks every rule. Instead of a prefix, the AUCTeX developers
> decided upon a camel-case variant. Their package does not fit nicely with
> emacs development preferred way.
> 
> > > I am also interested in the made hooks. Would the built-in be
> > > plain-tex-mode-hook and latex-mode-hook? Is there also tex-mode-hook?
> > 
> > Did you read my first message?

I missed the last hook part.  Thanks.
 
> > Best, Arash
> > 
> > Footnotes:
> > [1] 
> > https://www.gnu.org/software/emacs/manual/html_mono/elisp.html#Coding-Conventions



reply via email to

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