GNU bug report logs -
#73302
TeX-find-closing-brace and verbatim macros
Previous Next
Reported by: Paul Nelson <ultrono <at> gmail.com>
Date: Mon, 16 Sep 2024 16:13:02 UTC
Severity: normal
Done: Arash Esbati <arash <at> gnu.org>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
Hi Arash, thanks, the modified code you supplied (after a couple
tweaks) addresses all examples considered thus far, and indeed feels
less brittle. Pushed to my package repo, copying for below in case of
curiosity.
(defun czm-tex-fold--verb-data (&rest _args)
"Return data for a verbatim macro.
Returns a list of the form (START END CONTENT)."
(when-let* ((boundaries (LaTeX-verbatim-macro-boundaries))
(bound-start (car boundaries))
(bound-end (cdr boundaries))
(end-delim-char (char-before bound-end))
(start-delim-char (if (= end-delim-char ?\})
?\{
end-delim-char))
(start-delim (char-to-string start-delim-char))
(verb-arg-start
(1+ (progn
(goto-char bound-end)
(if (string= start-delim TeX-grop)
(progn (backward-sexp) (point))
(forward-char -1)
(search-backward start-delim bound-start t)))))
(verb-arg-end (1- bound-end)))
(list bound-start
bound-end
(buffer-substring-no-properties verb-arg-start
verb-arg-end))))
(defun czm-tex-fold-verbs (start end)
"Fold verbatim macros between START and END."
(save-excursion
(goto-char start)
(let ((re (concat "\\\\" (regexp-opt
(append
(LaTeX-verbatim-macros-with-braces)
(LaTeX-verbatim-macros-with-delims))))))
(while (let ((case-fold-search nil))
(re-search-forward re end t))
(when-let* ((data (czm-tex-fold--verb-data))
(spec (lambda (&rest _args)
(nth 2 (czm-tex-fold--verb-data)))))
(apply #'czm-tex-fold--create-misc-overlay (append data
(list spec))))))))
This bug report was last modified 231 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.