Conflict between YASnippet and cdlatex
Today, when I edited the LaTeX document for my personal project, the cdlatex
expansion took precedence over the YASnippet expansion, which made the latter not function properly. Such a phenomenon has not appeared before.
Solution
-
Create the following Elisp function
tjh/cdlatex-yas-expand
, in which the YASnippet expansion will be tried first. If successful, this function returnst
and the defaultcdlatex
expansion will be ignored. Otherwise, thecdlatex
expansion will be used.(defun tjh/cdlatex-yas-expand () "Resolve the conflict between cdlatex and yasnippet. When this function returns true, the default `cdlatex-tab` will not be executed. The effect of function is to first try yasnippet expansion, then cdlatex expansion." (interactive) (if (or (bound-and-true-p yas-minor-mode) (bound-and-true-p yas-global-mode)) (if (yas-expand) t nil) nil))
-
Add
tjh/cdlatex-yas-expand
tocdlatex-tab-hook
.(add-hook 'cdlatex-tab-hook 'tjh/cdlatex-yas-expand)