;ELC ;;; Compiled ;;; in Emacs version 28.0.50 ;;; with all optimizations. (custom-declare-group 'texmathp nil "Testing TeX and LaTeX documents for math mode." :tag "Test For TeX and LaTeX Math Mode" :prefix "texmathp-" :group 'tex) (defvar texmathp-environments nil) (defvar texmathp-macros nil) (defvar texmathp-onoff-regexp nil) (defvar texmathp-toggle-regexp nil) (defvar texmathp-tex-commands1 nil) (defvar texmathp-memory nil) #@61 The default entries for `texmathp-tex-commands', which see. (defvar texmathp-tex-commands-default '(("$$" sw-toggle) ("$" sw-toggle) ("\\hbox" arg-off) ("\\vbox" arg-off) ("\\vtop" arg-off) ("\\vcenter" arg-off) ("equation" env-on) ("eqnarray" env-on) ("eqnarray*" env-on) ("math" env-on) ("displaymath" env-on) ("minipage" env-off) ("\\fbox" arg-off) ("\\mbox" arg-off) ("\\framebox" arg-off) ("\\label" arg-off) ("\\textrm" arg-off) ("\\(" sw-on) ("\\)" sw-off) ("\\[" sw-on) ("\\]" sw-off) ("\\ensuremath" arg-on) ("equation*" env-on) ("align" env-on) ("align*" env-on) ("gather" env-on) ("gather*" env-on) ("multline" env-on) ("multline*" env-on) ("flalign" env-on) ("flalign*" env-on) ("alignat" env-on) ("alignat*" env-on) ("xalignat" env-on) ("xalignat*" env-on) ("xxalignat" env-on) ("\\boxed" arg-on) ("\\text" arg-off) ("\\intertext" arg-off) ("\\tag" arg-off) ("\\tag*" arg-off) ("\\shortintertext" arg-off) ("empheq" env-on) ("AmSequation" env-on) ("AmSequation*" env-on) ("AmSalign" env-on) ("AmSalign*" env-on) ("AmSgather" env-on) ("AmSgather*" env-on) ("AmSmultline" env-on) ("AmSmultline*" env-on) ("AmSflalign" env-on) ("AmSflalign*" env-on) ("AmSalignat" env-on) ("AmSalignat*" env-on) ("dmath" env-on) ("dmath*" env-on) ("dseries" env-on) ("dseries*" env-on) ("dgroup" env-on) ("dgroup*" env-on) ("darray" env-on) ("darray*" env-on) ("dsuspend" env-off)) (#$ . 445)) #@202 Compile the value of `texmathp-tex-commands' into the internal lists. Call this when you have changed the value of that variable without using customize (customize calls it when setting the variable). (defalias 'texmathp-compile #[0 "\306\211\n B\307\n \"\310 !\306\211\211\211@\211\262\203SA@\262A\262\311\267\202D@ B\202@B\202@B\262\202\312=\203@B\262\202\313\314\315\"P\316\314\315\"P\211\207" [texmathp-macros texmathp-environments texmathp-tex-commands texmathp-tex-commands-default texmathp-memory texmathp-tex-commands1 nil append reverse #s(hash-table size 6 test eq rehash-size 1.5 rehash-threshold 0.8125 purecopy t data (env-on 43 env-off 43 arg-on 51 arg-off 51 sw-on 59 sw-off 59)) sw-toggle "\\(?:[^\\]\\|\\`\\)" regexp-opt t "\\([^\\$]\\|\\`\\)" texmathp-onoff-regexp texmathp-toggle-regexp] 10 (#$ . 1839) nil]) (byte-code "\300\301\302\303\304DD\305\306\307\310\311&\210\300\312\302\303\313DD\314\310\315%\210\300\316\302\303\317DD\320\310\321%\207" [custom-declare-variable texmathp-tex-commands funcall function #[0 "\300\207" [nil] 1] "List of environments and macros influencing (La)TeX math mode.\nThis user-defined list is used in addition to LaTeX and AMSLaTeX defaults.\nThe structure of each entry is (NAME TYPE)\n\n- The first item in each entry is the name of an environment or macro.\n If it's a macro, include the backslash.\n\n- The second item is a symbol indicating how the command works:\n `env-on' Environment: turns math mode for its body on\n `env-off' Environment: turns math mode for its body off\n `arg-on' Command: turns math mode for its arguments on\n `arg-off' Command: turns math mode for its arguments off\n `sw-on' Switch: turns math-mode of following text on\n `sw-off' Switch: turns math-mode of following text off\n `sw-toggle' Switch: toggles math mode of following text" :set #[514 "\300\"\210\301 \207" [set-default texmathp-compile] 5 "\n\n(fn SYMBOL VALUE)"] :type (repeat (list :value ("" env-on) (string :tag "Name") (choice :tag "Type" (const :tag "Environment: turns math mode for its body on" env-on) (const :tag "Environment: turns math mode for its body off" env-off) (const :tag "Command: turns math mode for its argument on" arg-on) (const :tag "Command: turns math-mode for its argument off" arg-off) (const :tag "Switch: turns math-mode of following text on" sw-on) (const :tag "Switch: turns math-mode of following text off" sw-off) (const :tag "Switch: toggles math mode of following text" sw-toggle)))) texmathp-search-n-paragraphs #[0 "\300\207" [2] 1] "Number of paragraphs to check before point.\nNormally, you cannot have an empty line in a math environment in (La)TeX.\nThe fastest method to test for math mode is then limiting the search\nbackward to the nearest empty line.\nHowever, during editing it happens that such lines exist temporarily.\nTherefore we look a little further. This variable determines how many\nempty lines we go back to fix the search limit." number texmathp-allow-detached-args #[0 "\300\207" [nil] 1] "Non-nil means, allow arguments of macros to be detached by whitespace.\nWhen this is t, `aaa' will be interpreted as an argument of \\bbb in the\nfollowing construct: \\bbb [xxx] {aaa}\nThis is legal in TeX. The disadvantage is that any number of braces expressions\nwill be considered arguments of the macro independent of its definition." boolean] 8) #@380 After a call to `texmathp' this variable shows why math-mode is on or off. The value is a cons cell (MATCH . POSITION). MATCH is a string like a car of an entry in `texmathp-tex-commands', e.g. "equation" or "\ensuremath" or "\=\[" or "$". POSITION is the buffer position of the match. If there was no match, it points to the limit used for searches, usually two paragraphs up. (defvar texmathp-why nil (#$ . 5299)) #@46 Syntax table used while texmathp is parsing. (defvar texmathp-syntax-table (byte-code "\300 \301\302\303\"\304\"\210\207" [make-syntax-table mapc make-closure #[257 "\301@A\300#\207" [V0 modify-syntax-entry] 5 "\n\n(fn X)"] ((92 . "\\") (12 . ">") (10 . ">") (37 . "<") (91 . ".") (93 . ".") (123 . "(}") (125 . "){") (40 . ".") (41 . ".") (34 . ".") (38 . ".") (95 . ".") (64 . "_") (126 . " ") (36 . "$") (39 . "w"))] 5) (#$ . 5722)) #@280 Determine if point is inside (La)TeX math mode. Returns t or nil. Additional info is placed into `texmathp-why'. The functions assumes that you have (almost) syntactically correct (La)TeX in the buffer. See the variable `texmathp-tex-commands' about which commands are checked. (defalias 'texmathp #[0 "`\304\211\212\305\306\304\307$\203\310\224\202e)\311!\312\203(AV\203(A\202)!\304B\2034\262\203CAAY\203C\262\313@ \"A@\314>\262\204u\315!\211\262\203uAAY\203u\313@ \"A@\316=\203u\262\317\262\204\254\212\211Ab\210\320\n\317#\203\240?\211\262\203\232\321\322!\322\224B\262\202~\304\262\202~\203\253\203\253\262)\211\323\324!\203\312\325\326\203\277\327\202\300\330@\206\306\331A$\210\205\317\317\207" [texmathp-search-n-paragraphs texmathp-tex-commands1 texmathp-toggle-regexp texmathp-why nil re-search-backward "[\n ][ ]*[\n ]" 1 0 texmathp-match-macro texmathp-match-environment assoc (env-on arg-on) texmathp-match-switch sw-on t re-search-forward match-string-no-properties 2 called-interactively-p any message "math-mode is %s: %s begins at buffer position %d" "on" "off" "new paragraph"] 12 (#$ . 6168) nil]) #@146 Find out if point is inside any of the math environments. Limit searched to BOUND. The return value is like ("equation" . (point)). (fn BOUND) (defalias 'texmathp-match-environment #[257 "\3032\204\212\204\304\303\305\"\210\212\306 \210\307\305w\210\310`d` G\\^\" \230)\305\211\311\312\313#\203\314 \315\316\"\216\311\n\317 \313#)\262\205@\313=\203{\310\320\224\320\225\"\262\321\322!\323\230\203_B\262\210\202$@\232\203nA\262\210\202$\235\203{\304\303`B\"\210\210\202$\266)\3050\207" [texmathp-environments comment-start comment-start-skip exit throw nil beginning-of-line " " buffer-substring-no-properties re-search-backward "\\\\\\(begin\\|end\\)[ ]*{\\([^}]+\\)}" t match-data make-closure #[0 "\301\300\302\"\207" [V0 set-match-data evaporate] 3] line-beginning-position 2 match-string-no-properties 1 "end"] 9 (#$ . 7363)]) #@155 Find out if point is within the arguments of any of the Math macros. Limit searches to BOUND. The return value is like ("\macro" . (point)). (fn BOUND) (defalias 'texmathp-match-macro #[257 "\3032\303\204 \304\303\305\"\210\305\211\306 \307\310\"\216\214\212\311 !\210\312]`}\210\3131/\314\315!\210\3160\2023\210\202\273\203\273h\317>\204M\n\203\213\320\321\316#\203\213\322\224Tb\210h\323=\203c\3241_\325 \210\3160\202\210\210\202\213\326\216\327\330\331\"\210\327\323\331\"\210\327\332\333\"\210\327\334\335\"\210\3361\205\325 \210\3160\202\207\210\305)\2046`\262g\337>\203\265\320\340\305\316#\203\265\341\322\224\322\225\"\211\262\203\265\235\203\265\304\303`B\"\210b\210\202\"\304\303\305\"+\266\2030\207" [texmathp-macros texmathp-syntax-table texmathp-allow-detached-args exit throw nil syntax-table make-closure #[0 "\301\300!\207" [V0 set-syntax-table] 2] set-syntax-table 1 (error) up-list -1 t (93 125) re-search-backward "[]}][ ]*[\n ]?\\([ ]*%[^\n ]*[\n ]\\)*[ ]*\\=" 0 125 (error) backward-sexp #[0 "\300\301\302\"\210\300\303\304\"\210\300\305\306\"\210\300\307\306\"\210\310\207" [modify-syntax-entry 123 "(}" 125 "){" 91 "." 93 nil] 3] modify-syntax-entry 123 "." 91 "(]" 93 ")[" (error) (91 123) "\\\\[*a-zA-Z]+\\=" buffer-substring-no-properties] 8 (#$ . 8236)]) #@84 Search backward for any of the math switches. Limit searched to BOUND. (fn BOUND) (defalias 'texmathp-match-switch #[257 "\212\301\302#\205\303\304\224\304\225\"\304\224B)\207" [texmathp-onoff-regexp re-search-backward t buffer-substring-no-properties 1] 5 (#$ . 9560)]) (provide 'texmathp)