From 6a9cf0331865d83f629856ac515941bf4f4c0353 Mon Sep 17 00:00:00 2001 From: JSDurand Date: Mon, 10 Oct 2022 11:40:03 +0800 Subject: 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. --- tex-conf.el | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) (limited to 'tex-conf.el') 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) -- cgit v1.2.3-18-g5258