Elisp: Modify Syntax Table Temporarily
Here's a example of how to use a temporary syntax table just for 1 command.
Suppose, we want the curly quote “ ” to be considered as a matching pair like brackets.
The curly quotes in standard-syntax-table
is considered as punctuation class, not matching pairs like brackets.
〔see Elisp: Show Char's Syntax〕
(defun test () "move cursor to the right 1 char, but if it is a left curly quote, jump to the right curly quote. Version 2017-02-13" (interactive) (let ((xtemp-syn-table (make-syntax-table))) (modify-syntax-entry ?\“ "(”" xtemp-syn-table) (modify-syntax-entry ?\” ")“" xtemp-syn-table) (with-syntax-table xtemp-syn-table (if (looking-at "\\s(") (forward-sexp 1) (right-char )))))
test “xyz” text
Syntax Table Functions (ELISP Manual)