auctex-devel
[Top][All Lists]
Advanced

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

Re: AUCTeX and "builtin latex mode" integration


From: Ikumi Keita
Subject: Re: AUCTeX and "builtin latex mode" integration
Date: Fri, 22 Sep 2023 17:51:20 +0900

Hi Stefan and all,

In this message, I talk about topics of the following two categories:
[A] Topics discussed so far
[B] Incompatibility found anew

[A] Topics discussed so far
>>>>> Stefan Monnier <monnier@iro.umontreal.ca> writes:
>> 2. ConTeXt modes

> If at all possible, I recommend to use different names for the parent
> mode and the dispatch function :-)

I took the way to remove language-specific modes. Now `ConTeXt-en-mode'
and `ConTeXt-nl-mode' became helper functions of `ConTeXt-mode' under
the name `ConTeXt--mode-xx' and don't exist as major modes. This
simplified the code much.

If that choice turns out to be problematic, I try to find other way.

>> 3. Additional menu item
>> I chose `text-mode' as the parent of the base mode
>> `TeX--VirTeX-mode' and `Texinfo-mode'. This is reasonable because
>> those modes called `text-mode-hook' so far. On the other hand, there
>> is a side effect that "Text" menu appears in the menu bar in all
>> AUCTeX major modes, which may be distracting for some users.

> Maybe `nil` (a.k.a. `fundamental-mode`) is a better parent, which more
> closely matches the historical behavior of AUCTeX?

I suppressed "Text" menu in AUCTeX major modes. Maybe AUCTeX should have
a new user option to determine whether to hide the item or not.

[B] Incompatibility found anew
David Fussner's effort reported in another thread[1] unveiled another
incompatibility in having `LaTeX-mode' as mode name rather than
`latex-mode'. When I try the example given in the first message of the
above thread in feature/fix-mode-names-overlap branch, it results in
user errors
No references found for: fontspec
and
No references found for: __hook_debug:n

I tracked down the origin; it is in
`semantic-symref-derive-find-filepatterns' in cedet/semantic/symref/grep.el:
----------------------------------------------------------------------
(defun semantic-symref-derive-find-filepatterns (&optional mode)
...(snip)...
  (let* ((mode (or mode major-mode))  <-- mode = LaTeX-mode
...(snip)...
      ;; No hit, try auto-mode-alist.
      (dolist (X auto-mode-alist)     <-- Looking at `auto-mode-alist'
        (when (and (eq (cdr X) mode)
                   ;; Only take in simple patterns, so try to convert this one.
                   (string-match "\\\\\\.\\([^\\'>]+\\)\\\\'" (car X)))
          (push (concat "*." (match-string 1 (car X))) pat))))
----------------------------------------------------------------------
This function is called without optional argument MODE in `(cl-defmethod
semantic-symref-perform-search ...)' in the same file, thus `mode' is
let-bound to `LaTeX-mode' (the value of `major-mode').
The `dolist' loop searches for this `LaTeX-mode' in `auto-mode-alist'
and gets no hits. Hence no files were searched for "fontspec" and
"__hook_debug:n" in the above examples. In other words,
`xref-find-references' doesn't work when `major-mode' is `LaTeX-mode'.

(I infer that `xref-find-references' doesn't work in cperl-mode if it is
redirected from perl-mode by `major-mode-remap-alist', not altering
`auto-mode-alist'.)

I suppose that we can work around this issue if
`semantic-symref-derive-find-filepatterns' is modified to look into
`major-mode-remap-alist' in emacs 29 and later. However, I don't see
clean solution for emacs<29.

I'm afraid that there are other similar inconsistencies in emacs core
where elisp codes refer to the value of `auto-mode-alist'.

Best regards,
Ikumi Keita
#StandWithUkraine #StopWarInUkraine

[1] https://debbugs.gnu.org/cgi/bugreport.cgi?bug=65912



reply via email to

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