vectorgraphics / asymptote

2D & 3D TeX-Aware Vector Graphics Language
https://asymptote.sourceforge.io/
GNU General Public License v3.0
533 stars 89 forks source link

asy-mode.el: "concat: Symbol’s value as variable is void: LaTeX-verbatim-regexp" on `M-x lasy-mode` #418

Open agreselin opened 5 months ago

agreselin commented 5 months ago

Hello, I'm trying to set up asy-mode following Editing-modes and LaTeX-usage. On doing M-x lasy-mode in latexusage.tex I get concat: Symbol’s value as variable is void: LaTeX-verbatim-regexp and lasy-mode doesn't turn on.

agreselin commented 5 months ago

A bit of context: I'm on Emacs 30.0.50 and I've downloaded two-mode-mode from https://www.dedasys.com/freesoftware/files/two-mode-mode.el. I've managed not to get any warnings or errors with

(setq LaTeX-verbatim-regexp nil)
(defalias 'turn-on-font-lock-if-enabled 'ignore)

The second line is for

Error running timer ‘two-mode-mode-update-mode’: (void-function turn-on-font-lock-if-enabled)

which I got after fixing the error about LaTeX-verbatim-regexp. (Maybe turn-on-font-lock-if-desired instead of ignore would be a better choice?)

Still, I don't know if the mode works as intended. Asymptote code is fontified only if lasy-mode is called from within an asy environment, but then the LaTeX code is unfontified. (featurep 'two-mode-mode) returns t, anyway.

johncbowman commented 4 months ago

Make sure you are using the latest version (from about 3 years ago) of https://raw.githubusercontent.com/vectorgraphics/asymptote/HEAD/base/asy-mode.el

The symbol LaTeX-verbatim-regexp is defined on line 1066.

agreselin commented 4 months ago

Hey John, hi! Thanks for Asymptote, I've seen what it can do and I'm very excited to learn it.

I have the version you linked. Now I don't get the void variable error for LaTeX-verbatim-regexp, there must have been something wrong with my config when I opened this issue, sorry. I still get Error running timer ‘two-mode-mode-update-mode’: (void-function turn-on-font-lock-if-enabled). Also, in lasy-mode Asymptote code is syntax-highlighted correctly but LaTeX code is not, I don't know if this is expected.

I get five Warning: ‘defadvice’ is an obsolete macro (as of 30.1); use ‘advice-add’ or ‘define-advice’. I can translate the defadvice's to the constructs in nadvice.el and send a pull request if you're interested.

johncbowman commented 4 months ago

I verified that if you open up latexusage.tex with emacs 28.3, execute lasy-mode and scroll down, syntax highlighting of the LaTeX code is suddenly disabled. Perhaps it has always been this way. If you execute lasy-mode again from within an asy block, you get the (void-function turn-on-font-lock-if-enabled) error. Executing lasy-mode repeatedly outside an asy block will give an args out of range error or the LaTeX-verbatim-regexp error. So apparently these issues have nothing to do with changes in Emacs 30. If you manage to fix these issues, a pull request would be welcome. For now, just execute lasy-mode once and all should be well.

agreselin commented 4 months ago

Fixing the issue is outside of my immediate possibilities. What I can do is translate the old defadvice's which raise the warning.