branch: externals/auctex commit 88a75635097ab45b9136f1732e78bde317ef949c Author: Arash Esbati <ar...@gnu.org> Commit: Arash Esbati <ar...@gnu.org>
Fix last improvement for skipping of inline verbatim macros * tex.el (TeX-ispell-tex-arg-verb-end): New function. * tex-ispell.el (TeX-ispell-verb-delimiters): Replace `TeX-ispell-verb-opening-delimiters' and `TeX-ispell-verb-closing-delimiters' with new customizable option `TeX-ispell-verb-delimiters'. (TeX-ispell-skip-setcar): Use new function `TeX-ispell-tex-arg-verb-end' with verbatim macros. --- tex-ispell.el | 43 ++++++++++++++++++++----------------------- tex.el | 24 ++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 23 deletions(-) diff --git a/tex-ispell.el b/tex-ispell.el index 0b08f40..e1c5fd1 100644 --- a/tex-ispell.el +++ b/tex-ispell.el @@ -72,18 +72,6 @@ (require 'tex) -(defcustom TeX-ispell-verb-opening-delimiters "{!|#\"*/+-" - "String with all opening delimiters for verb macros. -The elements must match `TeX-ispell-verb-closing-delimiters'." - :group 'TeX-misc - :type 'string) - -(defcustom TeX-ispell-verb-closing-delimiters "}!|#\"*/+-" - "String with all closing delimiters for verb macros. -The elements must match `TeX-ispell-verb-opening-delimiters'." - :group 'TeX-misc - :type 'string) - ;; Add new macros here: (eval-when-compile (defvar TeX-ispell-skip-cmds-list @@ -299,17 +287,26 @@ Environments for math or verbatim text are candidates for this list.")) ;; booktabs.sty ("\\\\cmidrule" . "{[-0-9]+}") ;; fontspec.sty - ("\\\\fontspec" TeX-ispell-tex-arg-end 1 1 0) - ;; listings.sty & fancyvrb.sty: - (,(concat "\\\\\\(lstinline\\|Verb\\)\\(\\[[^]]*\\]\\)?" - "[" TeX-ispell-verb-opening-delimiters "]") - . - ,(concat "[" TeX-ispell-verb-closing-delimiters "]")) - ;; minted.sty - (,(concat "\\\\mint\\(inline\\)?\\(\\[[^]]*\\]\\)?{\\([^}]+\\)}" - "[" TeX-ispell-verb-opening-delimiters "]") - . - ,(concat "[" TeX-ispell-verb-closing-delimiters "]")))) + ("\\\\fontspec" TeX-ispell-tex-arg-end 1 1 0))) + + +;; Special setup for verbatim macros: +(defcustom TeX-ispell-verb-delimiters "!|#~\"*/+^-" + "String with all delimiters for verbatim macros. +Characters special in regexps like `^' and `-' must come last and +not be quoted. An opening brace `{' should not be used." + :group 'TeX-misc + :type 'string) + +;; listings.sty & fancyvrb.sty: With opt. argument only before verb content: +(TeX-ispell-skip-setcar + `((,(concat "\\\\" (regexp-opt '("Verb" "lstinline"))) + TeX-ispell-tex-arg-verb-end))) + +;; minted.sty: With opt. and mandatory argument before verb content: +(TeX-ispell-skip-setcar + `((,(concat "\\\\" (regexp-opt '("mint" "mintinline"))) + TeX-ispell-tex-arg-verb-end 1))) ;; Add environments here: diff --git a/tex.el b/tex.el index 8c37ae0..64e570d 100644 --- a/tex.el +++ b/tex.el @@ -6677,6 +6677,30 @@ skipped." (message "Error skipping s-expressions at point %d" (point)) (sit-for 2)))) +(defun TeX-ispell-tex-arg-verb-end (&optional arg) + "Skip across an optional argument, ARG number of mandatory ones and verbatim content. +This function always checks if one optional argument in brackets +is given and skips over it. If ARG is a number, it skips over +that many mandatory arguments in braces. Then it checks for +verbatim content to skip which is enclosed by a character given +in `TeX-ispell-verb-delimiters' or in braces, otherwise raises an +error." + (condition-case nil + (progn + (when (looking-at "[ \t\n]*\\[") (forward-sexp)) + (when (and arg (looking-at "{")) + (forward-sexp arg)) + (cond ((looking-at (concat "[" TeX-ispell-verb-delimiters "]")) + (forward-char) + (skip-chars-forward (concat "^" (string (char-before)))) + (forward-char)) + ((looking-at "{") + (forward-sexp)) + (t (error nil)))) + (error + (message (format "Verbatim delimiter is not one of %s" + (split-string TeX-ispell-verb-delimiters "" t))) + (sit-for 2)))) ;;; Abbrev mode