diff options
author | JSDurand <mmemmew@gmail.com> | 2022-10-10 11:40:03 +0800 |
---|---|---|
committer | JSDurand <mmemmew@gmail.com> | 2022-10-10 11:40:03 +0800 |
commit | 6a9cf0331865d83f629856ac515941bf4f4c0353 (patch) | |
tree | 198a10c50c8b810f3034e411b752dcb580622896 | |
parent | 5691ee998a2d136cdfdea2c7f3970dab71499cc8 (diff) |
tex: account for \right constructs
* tex-conf.el (end-exit-paren, (open-back-paren): Modify the commands
so that they treat \right as part of the parentheses.
-rw-r--r-- | tex-conf.el | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/tex-conf.el b/tex-conf.el index fa11a90..58940b2 100644 --- a/tex-conf.el +++ b/tex-conf.el @@ -175,18 +175,31 @@ (cond ((memq ch ch-list) (forward-char)) ((looking-at-p "\\(\\\\)\\|\\\\]\\|\\\\}\\)") (forward-char 2)) + ((looking-at-p "\\\\right") + (forward-char 6) + (end-exit-paren)) (t (self-insert-command 1))))) ;;;###autoload (defun open-back-paren () "Use \"à\" to go back to the parenthesis." (interactive) - (let ((ch (char-before nil)) - (ch-list '(?\) ?\} ?\] ?\$))) - (cond ((looking-back "\\(\\\\)\\|\\\\]\\|\\\\}\\)" (- (point) 2)) - (forward-char -2)) - ((memq ch ch-list) (backward-char)) - (t (self-insert-command 1))))) + (save-match-data + (let ((ch (char-before nil)) + (ch-list '(?\) ?\} ?\] ?\$)) + continue) + (cond ((looking-back "\\(\\\\)\\|\\\\]\\|\\\\}\\)" + (max (- (point) 2) (point-min))) + (forward-char -2) + (setq continue t)) + ((memq ch ch-list) (backward-char) (setq continue t)) + (t (self-insert-command 1))) + (cond + ((and continue + (looking-back + "\\\\right" + (max (- (point) 6) (point-min)))) + (forward-char -6)))))) (make-variable-buffer-local 'parens-require-spaces) |