5

When I execute describe-mode from within a .texi file, I see:

Texinfo/P mode defined in `texinfo.el' (`texinfo-mode'):
:override advice: ‘TeX-texinfo-mode’

What happens is that AUCTeX takes over the builtin Texinfo mode.

Where does that override advice come from? And how do I get back the native Texinfo mode?

feklee
  • 1,029
  • 5
  • 17

1 Answers1

9

Some information about advices

An advice is mainly a method of last resort to customize the behavior of functions defined in other libraries. There are many variants of advice. Examples are:

  • overriding the function with another function (That is the extreme case where one completely replaces the original function.)
  • wrapping the original function with an advising function
  • filtering the arguments of the original function
  • filtering the return value of the original function

Also special hook variables can be advised (see the manual).

One should prefer other methods for influencing the behavior of library functions. Often the library developer provides normal and special hook variables. Those have following advantages over advices:

  • they are at places where the library developer thinks it is safe to tweak the behavior of the function
  • hooks are often well documented by the library developer; often conditions on the hook functions are specified such as whether they may move point or change match-data

Source of the advice of texinfo-mode and how one can avoid it

TeX-texinfo-mode comes from the AUCTeX package. It is defined in tex-info.el. Also the override-advice of texinfo-mode with TeX-texinfo-mode is contained in tex-info.el.

You can find that information yourself by the key sequence C-h f TeX-texinfo-mode. (Note that the key sequence C-h f is bound to the command describe-function.) The link provided with the help page points to the file where the function is defined.

You can get back the old behavior by customizing the variable TeX-modes via M-x customize-option RET TeX-modes RET. You can also use the menu item
OptionsCustomize EmacsSpecific Option....

Toggle texinfo-mode from the TeX-modes list off.


General method to remove an advice

The opt-out of the override of texinfo-mode via TeX-modes is possible in AUCTeX.

The more general approach to revert the effect of an (override) advice is advice-remove after the advising package has been loaded.

This is demonstrated for texinfo-mode. One would put the following code in one's init file:

(with-eval-after-load 'tex-info
  (advice-remove 'texinfo-mode #'TeX-texinfo-mode))

But, you do not need to do that since you have the customization option TeX-modes.

NickD
  • 27,023
  • 3
  • 23
  • 42
Tobias
  • 32,569
  • 1
  • 34
  • 75
  • *Can you complete the answer by explaining what an advice is?* (I just discovered the section about advising functions in the Elisp info pages.) – feklee Jun 26 '19 at 09:47
  • Instead of `eval-after-load` with a string first argument, I suggest advertising `with-eval-after-load` with a symbol as its first argument. – Basil Jun 26 '19 at 10:46
  • @Basil `with-eval-after-load`is essentially `eval-after-load`. You are right about the feature `'tex-info` instead of the file name. – Tobias Jun 26 '19 at 11:03
  • @Tobias I know that `with-eval-after-load` is a wrapper around `eval-after-load`, but the former enforces passing an evaluated lambda to the latter. The same commit that introduced `with-eval-after-load` in Emacs 24.4 also changed `eval-after-load` to accept a function argument, rather than an unevaluated form. That's why it's better to recommend the higher-level and better-behaved `with-eval-after-load` wrapper. – Basil Jun 26 '19 at 11:18
  • @Tobias Thanks. – Basil Jun 26 '19 at 12:20