Re: Parsing of \renewcommand-ed macros
Arash Esbati writes: Hi Arash, >> Why are you indenting the docstrings? That looks ugly in C-h f. > > Upps, thanks for catching this. It wasn't me, I suspect it was > aggressive-indent (but don't ask me why). I use that, too, but since emacs-lisp-mode uses lisp-indent-line as indent-line-function and that doesn't indent inside strings, that should not have happened. Bye, Tassilo
Re: Parsing of \renewcommand-ed macros
Hi Tassilo, Tassilo Horn writes: > I haven't looked at the actual changes but just found this nitpick: > > @@ -1803,7 +1805,7 @@ This is necessary since index entries may contain > commands and stuff.") > > (defun LaTeX-split-bibs (match) >"Extract bibliography resources from MATCH. > -Split the string at commas and remove Biber file extensions." > + Split the string at commas and remove Biber file extensions." >(let ((bibs (split-string (TeX-match-buffer match) " *, *"))) > (dolist (bib bibs) >(LaTeX-add-bibliographies (replace-regexp-in-string > @@ -1826,7 +1828,7 @@ Split the string at commas and remove Biber file > extensions." > > (defun LaTeX-listify-package-options (options) >"Return a list from a comma-separated string of package OPTIONS. > -The input string may include LaTeX comments and newlines." > + The input string may include LaTeX comments and newlines." >;; We jump through all those hoops and don't just use `split-string' >;; or the like in order to be able to deal with key=value package >;; options which can look like this: "pdftitle={A Perfect Day}, > > Why are you indenting the docstrings? That looks ugly in C-h f. Upps, thanks for catching this. It wasn't me, I suspect it was aggressive-indent (but don't ask me why). New version is attached. Best, Arash diff --git a/latex.el b/latex.el index a8696f39..8bb01c49 100644 --- a/latex.el +++ b/latex.el @@ -1764,27 +1764,29 @@ This is necessary since index entries may contain commands and stuff.") (defvar LaTeX-auto-regexp-list (append (let ((token TeX-token-char)) - `((,(concat "\\(?:new\\|provide\\)command\\*?{?\\(" token "+\\)}?\\[\\([0-9]+\\)\\]\\[\\([^\n\r]*\\)\\]") -(1 2 3) LaTeX-auto-optional) - (,(concat "\\(?:new\\|provide\\)command\\*?{?\\(" token "+\\)}?\\[\\([0-9]+\\)\\]") -(1 2) LaTeX-auto-arguments) + `((,(concat "\\(re\\)?\\(?:new\\|provide\\)command\\*?" + "{?\\(" token "+\\)}?\\[\\([0-9]+\\)\\]\\[\\([^\n\r]*\\)\\]") +(2 3 4 1) LaTeX-auto-optional) + (,(concat "\\(re\\)?\\(?:new\\|provide\\)command\\*?" + "{?\\(" token "+\\)}?\\[\\([0-9]+\\)\\]") +(2 3 1) LaTeX-auto-arguments) (,(concat "\\(?:new\\|provide\\)command\\*?{?\\(" token "+\\)}?") 1 TeX-auto-symbol) - (,(concat "newenvironment\\*?{?\\(" token "+\\)\\*?}?\\[\\([0-9]+\\)\\]\\[") -(1 2) LaTeX-auto-env-args-with-opt) - (,(concat "newenvironment\\*?{?\\(" token "+\\)\\*?}?\\[\\([0-9]+\\)\\]") -(1 2) LaTeX-auto-env-args) - (,(concat "newenvironment\\*?{?\\(" token "+\\)\\*?}?") + ("\\(re\\)?newenvironment\\*?{\\([^}]+\\)}\\[\\([0-9]+\\)\\]\\[" +(2 3 1) LaTeX-auto-env-args-with-opt) + ("\\(re\\)?newenvironment\\*?{\\([^}]+\\)}\\[\\([0-9]+\\)\\]" +(2 3 1) LaTeX-auto-env-args) + ("newenvironment\\*?{\\([^}]+\\)}" 1 LaTeX-auto-environment) (,(concat "newtheorem{\\(" token "+\\)}") 1 LaTeX-auto-environment) ("input{\\(\\.*[^#}%\\.\n\r]+\\)\\(\\.[^#}%\\.\n\r]+\\)?}" 1 TeX-auto-file) ("include{\\(\\.*[^#}%\\.\n\r]+\\)\\(\\.[^#}%\\.\n\r]+\\)?}" 1 TeX-auto-file) - (, (concat "bibitem{\\(" token "[^, \n\r\t%\"#'()={}]*\\)}") - 1 LaTeX-auto-bibitem) - (, (concat "bibitem\\[[^][\n\r]+\\]{\\(" token "[^, \n\r\t%\"#'()={}]*\\)}") - 1 LaTeX-auto-bibitem) + (,(concat "bibitem{\\(" token "[^, \n\r\t%\"#'()={}]*\\)}") +1 LaTeX-auto-bibitem) + (,(concat "bibitem\\[[^][\n\r]+\\]{\\(" token "[^, \n\r\t%\"#'()={}]*\\)}") +1 LaTeX-auto-bibitem) ("bibliography{\\([^#}\n\r]+\\)}" 1 LaTeX-auto-bibliography) ("addbibresource\\(?:\\[[^]]+\\]\\)?{\\([^#}\n\r]+\\)\\..+}" 1 LaTeX-auto-bibliography) @@ -1973,7 +1975,8 @@ The value is actually the tail of the list of options given to PACKAGE." ((member "12pt" options) "12") (t - "10"))) t) + "10"))) + t) (unless (equal options '("")) (TeX-add-to-alist 'LaTeX-provided-class-options (list (cons style options) @@ -1987,6 +1990,14 @@ The value is actually the tail of the list of options given to PACKAGE." ;; Cleanup optional arguments (mapc (lambda (entry) + ;; If we're renewcommand-ing and there is already an entry + ;; in `TeX-auto-symbol', delete it first: + (when (and (string= (nth 2 entry) "re") + (assoc (car entry) TeX-auto-symbol)) +(setq TeX-auto-symbol + (assq-delete-all (car (assoc (car entry) +
Re: Parsing of \renewcommand-ed macros
Arash Esbati writes: Hi Arash, >> IIUC AUCTeX doesn't have any provisions to parse \renewcommand-ed >> macros in `LaTeX-auto-regexp-list' and subsequently in the function >> `LaTeX-auto-cleanup'. Before fiddling with the parser, I'd like to >> know if I'm missing something. > > Ok, I fiddled with the parser and the outcome is attached. Any > comments welcome. I haven't looked at the actual changes but just found this nitpick: --8<---cut here---start->8--- @@ -1803,7 +1805,7 @@ This is necessary since index entries may contain commands and stuff.") (defun LaTeX-split-bibs (match) "Extract bibliography resources from MATCH. -Split the string at commas and remove Biber file extensions." + Split the string at commas and remove Biber file extensions." (let ((bibs (split-string (TeX-match-buffer match) " *, *"))) (dolist (bib bibs) (LaTeX-add-bibliographies (replace-regexp-in-string @@ -1826,7 +1828,7 @@ Split the string at commas and remove Biber file extensions." (defun LaTeX-listify-package-options (options) "Return a list from a comma-separated string of package OPTIONS. -The input string may include LaTeX comments and newlines." + The input string may include LaTeX comments and newlines." ;; We jump through all those hoops and don't just use `split-string' ;; or the like in order to be able to deal with key=value package ;; options which can look like this: "pdftitle={A Perfect Day}, --8<---cut here---end--->8--- Why are you indenting the docstrings? That looks ugly in C-h f. Bye, Tassilo
Re: Parsing of \renewcommand-ed macros
Arash Esbati writes: > IIUC AUCTeX doesn't have any provisions to parse \renewcommand-ed macros > in `LaTeX-auto-regexp-list' and subsequently in the function > `LaTeX-auto-cleanup'. Before fiddling with the parser, I'd like to know > if I'm missing something. Ok, I fiddled with the parser and the outcome is attached. Any comments welcome. Best, Arash diff --git a/latex.el b/latex.el index a8696f39..3a75cc9b 100644 --- a/latex.el +++ b/latex.el @@ -1764,27 +1764,29 @@ This is necessary since index entries may contain commands and stuff.") (defvar LaTeX-auto-regexp-list (append (let ((token TeX-token-char)) - `((,(concat "\\(?:new\\|provide\\)command\\*?{?\\(" token "+\\)}?\\[\\([0-9]+\\)\\]\\[\\([^\n\r]*\\)\\]") -(1 2 3) LaTeX-auto-optional) - (,(concat "\\(?:new\\|provide\\)command\\*?{?\\(" token "+\\)}?\\[\\([0-9]+\\)\\]") -(1 2) LaTeX-auto-arguments) + `((,(concat "\\(re\\)?\\(?:new\\|provide\\)command\\*?" + "{?\\(" token "+\\)}?\\[\\([0-9]+\\)\\]\\[\\([^\n\r]*\\)\\]") +(2 3 4 1) LaTeX-auto-optional) + (,(concat "\\(re\\)?\\(?:new\\|provide\\)command\\*?" + "{?\\(" token "+\\)}?\\[\\([0-9]+\\)\\]") +(2 3 1) LaTeX-auto-arguments) (,(concat "\\(?:new\\|provide\\)command\\*?{?\\(" token "+\\)}?") 1 TeX-auto-symbol) - (,(concat "newenvironment\\*?{?\\(" token "+\\)\\*?}?\\[\\([0-9]+\\)\\]\\[") -(1 2) LaTeX-auto-env-args-with-opt) - (,(concat "newenvironment\\*?{?\\(" token "+\\)\\*?}?\\[\\([0-9]+\\)\\]") -(1 2) LaTeX-auto-env-args) - (,(concat "newenvironment\\*?{?\\(" token "+\\)\\*?}?") + ("\\(re\\)?newenvironment\\*?{\\([^}]+\\)}\\[\\([0-9]+\\)\\]\\[" +(2 3 1) LaTeX-auto-env-args-with-opt) + ("\\(re\\)?newenvironment\\*?{\\([^}]+\\)}\\[\\([0-9]+\\)\\]" +(2 3 1) LaTeX-auto-env-args) + ("newenvironment\\*?{\\([^}]+\\)}" 1 LaTeX-auto-environment) (,(concat "newtheorem{\\(" token "+\\)}") 1 LaTeX-auto-environment) ("input{\\(\\.*[^#}%\\.\n\r]+\\)\\(\\.[^#}%\\.\n\r]+\\)?}" 1 TeX-auto-file) ("include{\\(\\.*[^#}%\\.\n\r]+\\)\\(\\.[^#}%\\.\n\r]+\\)?}" 1 TeX-auto-file) - (, (concat "bibitem{\\(" token "[^, \n\r\t%\"#'()={}]*\\)}") - 1 LaTeX-auto-bibitem) - (, (concat "bibitem\\[[^][\n\r]+\\]{\\(" token "[^, \n\r\t%\"#'()={}]*\\)}") - 1 LaTeX-auto-bibitem) + (,(concat "bibitem{\\(" token "[^, \n\r\t%\"#'()={}]*\\)}") +1 LaTeX-auto-bibitem) + (,(concat "bibitem\\[[^][\n\r]+\\]{\\(" token "[^, \n\r\t%\"#'()={}]*\\)}") +1 LaTeX-auto-bibitem) ("bibliography{\\([^#}\n\r]+\\)}" 1 LaTeX-auto-bibliography) ("addbibresource\\(?:\\[[^]]+\\]\\)?{\\([^#}\n\r]+\\)\\..+}" 1 LaTeX-auto-bibliography) @@ -1803,7 +1805,7 @@ This is necessary since index entries may contain commands and stuff.") (defun LaTeX-split-bibs (match) "Extract bibliography resources from MATCH. -Split the string at commas and remove Biber file extensions." + Split the string at commas and remove Biber file extensions." (let ((bibs (split-string (TeX-match-buffer match) " *, *"))) (dolist (bib bibs) (LaTeX-add-bibliographies (replace-regexp-in-string @@ -1826,7 +1828,7 @@ Split the string at commas and remove Biber file extensions." (defun LaTeX-listify-package-options (options) "Return a list from a comma-separated string of package OPTIONS. -The input string may include LaTeX comments and newlines." + The input string may include LaTeX comments and newlines." ;; We jump through all those hoops and don't just use `split-string' ;; or the like in order to be able to deal with key=value package ;; options which can look like this: "pdftitle={A Perfect Day}, @@ -1973,7 +1975,8 @@ The value is actually the tail of the list of options given to PACKAGE." ((member "12pt" options) "12") (t - "10"))) t) + "10"))) + t) (unless (equal options '("")) (TeX-add-to-alist 'LaTeX-provided-class-options (list (cons style options) @@ -1987,6 +1990,14 @@ The value is actually the tail of the list of options given to PACKAGE." ;; Cleanup optional arguments (mapc (lambda (entry) + ;; If we're renewcommand-ing and there is already an entry + ;; in `TeX-auto-symbol', delete it first: + (when (and (string= (nth 2 entry) "re") + (assoc (car entry) TeX-auto-symbol)) +(setq TeX-auto-symbol + (assq-delete-all (car (assoc (car entry) + TeX-auto-symbol)) +