[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[AUCTeX-diffs] [elpa] externals/auctex c6350aa 07/71: Track standardized
From: |
Tassilo Horn |
Subject: |
[AUCTeX-diffs] [elpa] externals/auctex c6350aa 07/71: Track standardized generic hook names in LaTeX kernel |
Date: |
Fri, 17 Dec 2021 15:00:25 -0500 (EST) |
branch: externals/auctex
commit c6350aae1ca4befcdde2289d005e193a63b51050
Author: Arash Esbati <arash@gnu.org>
Commit: Arash Esbati <arash@gnu.org>
Track standardized generic hook names in LaTeX kernel
* latex.el (TeX-read-hook): Unify query for hooks and track the
change for standardized generic hook names described in:
https://github.com/latex3/latex2e/blob/develop/base/doc/ltnews34.tex
---
latex.el | 331 ++++++++++++++++++++++++++++++++++-----------------------------
1 file changed, 177 insertions(+), 154 deletions(-)
diff --git a/latex.el b/latex.el
index 8ce8c6e..9954cc5 100644
--- a/latex.el
+++ b/latex.el
@@ -3117,161 +3117,184 @@ as values for the key. Use PROMPT as the prompt
string."
(defun TeX-read-hook ()
"Read a LaTeX hook and return it as a string."
(let* ((hook (completing-read
- (TeX-argument-prompt nil nil "Hook")
- '("cmd"
- "env"
- ;; From ltfilehook-doc.pdf
- "file/before" "file/after"
- "include/before" "include/end" "include/after"
- "class/before" "class/after"
- "package/before" "package/after"
- ;; From lthooks-doc.pdf
- "begindocument"
- "begindocument/before"
- "begindocument/end"
- "enddocument"
- "enddocument/afterlastpage"
- "enddocument/afteraux"
- "enddocument/info"
- "enddocument/end"
- "rmfamily" "sffamily"
- "ttfamily" "normalfont"
- "bfseries" "bfseries/defaults"
- "mdseries" "mdseries/defaults"
- ;; From ltshipout-doc.pdf
- "shipout/before" "shipout/after"
- "shipout/foreground" "shipout/background"
- "shipout/firstpage" "shipout/lastpage"
- ;; From ltpara-doc.pdf
- "para/before" "para/begin"
- "para/end" "para/after")))
- (place (lambda ()
- (completing-read
- (TeX-argument-prompt nil nil "Where")
- (if (string= hook "cmd")
- '("after" "before")
- '("before" "begin" "end" "after")))))
- (search (lambda ()
- (if (eq TeX-arg-input-file-search 'ask)
- (not (y-or-n-p "Find file yourself? "))
- TeX-arg-input-file-search)))
- name where files ); result
+ (TeX-argument-prompt nil nil "Hook")
+ '("cmd"
+ "env"
+ ;; From ltfilehook-doc.pdf
+ "file" "include" "class" "package"
+ ;; From lthooks-doc.pdf
+ "begindocument" "enddocument"
+ "rmfamily" "sffamily"
+ "ttfamily" "normalfont"
+ "bfseries" "mdseries"
+ ;; From ltshipout-doc.pdf
+ "shipout"
+ ;; From ltpara-doc.pdf
+ "para")))
+ (place (lambda (&optional opt pr)
+ (completing-read
+ (TeX-argument-prompt opt pr "Where")
+ (cond ((member hook '("env" "para"))
+ '("after" "before" "begin" "end"))
+ ((string= hook "include")
+ '("after" "before" "end"))
+ ((string= hook "begindocument")
+ '("before" "end"))
+ ((string= hook "enddocument")
+ '("afterlastpage" "afteraux" "info" "end"))
+ ((member hook '("bfseries" "mdseries"))
+ '("defaults"))
+ ((string= hook "shipout")
+ '("before" "after"
+ "foreground" "background"
+ "firstpage" "lastpage"))
+ (t
+ '("after" "before"))))))
+ (search (lambda ()
+ (if (eq TeX-arg-input-file-search 'ask)
+ (not (y-or-n-p "Find file yourself? "))
+ TeX-arg-input-file-search)))
+ name where files)
(cond ((string= hook "cmd")
- ;; cmd/<name>/<where>
- (setq name (completing-read
- (TeX-argument-prompt nil nil "Command")
- (TeX-symbol-list)))
- (setq where (funcall place)))
-
- ;; env/<name>/<where>
- ((string= hook "env")
- (setq name (completing-read
- (TeX-argument-prompt nil nil "Environment")
- (LaTeX-environment-list)))
- (setq where (funcall place)))
-
- ;; file/(before|after)/<file-name.xxx> where <file-name> is
- ;; optional and must be with extension
- ((member hook '("file/before" "file/after"))
- (if (funcall search)
- (progn
- (unless TeX-global-input-files-with-extension
- (setq TeX-global-input-files-with-extension
- (prog2
- (message "Searching for files...")
- (mapcar #'list
- (TeX-search-files-by-type 'texinputs
- 'global
- t nil))
- (message "Searching for files...done"))))
- (setq name
- (completing-read
- (TeX-argument-prompt t nil "File")
- TeX-global-input-files-with-extension)))
- (setq name
- (file-name-nondirectory
- (read-file-name
- (TeX-argument-prompt t nil "File")
- nil "")))))
-
- ;; include/(before|after|end)/<file-name> where <file-name>
- ;; is optional
- ((member hook '("include/before" "include/end" "include/after"))
- (if (funcall search)
- (progn
- (setq files
- (prog2
- (message "Searching for files...")
- ;; \include looks for files with TeX content,
- ;; so limit the search:
- (let* ((TeX-file-extensions '("tex" "ltx")))
- (TeX-search-files-by-type 'texinputs 'local t t))
- (message "Searching for files...done")))
- (setq name (completing-read
- (TeX-argument-prompt t nil "File")
- files)))
- (setq name
- (file-name-base
- (read-file-name
- (TeX-argument-prompt t nil "File")
- nil "")))))
-
- ;; class/(before|after)/<doc-class> where <doc-class> is
- ;; optional
- ((member hook '("class/before" "class/after"))
- (if (funcall search)
- (progn
- (unless LaTeX-global-class-files
- (setq LaTeX-global-class-files
- (prog2
- (message "Searching for LaTeX classes...")
- (let* ((TeX-file-extensions '("cls")))
- (mapcar #'list
- (TeX-search-files-by-type 'texinputs
- 'global
- t t)))
- (message "Searching for LaTeX classes...done"))))
- (setq name (completing-read
- (TeX-argument-prompt t nil "Document class")
- LaTeX-global-class-files)))
- (setq name
- (file-name-base
- (read-file-name
- (TeX-argument-prompt t nil "File")
- nil "")))))
-
- ;; package/(before|after)/<pack-name> where
- ;; <pack-name> is optional
- ((member hook '("package/before" "package/after"))
- (if (funcall search)
- (progn
- (unless LaTeX-global-package-files
- (setq LaTeX-global-package-files
- (prog2
- (message "Searching for LaTeX packages...")
- (let* ((TeX-file-extensions '("sty")))
- (mapcar #'list
- (TeX-search-files-by-type 'texinputs
- 'global
- t t)))
- (message "Searching for LaTeX packages...done"))))
- (setq name (completing-read
- (TeX-argument-prompt t nil "Package")
- LaTeX-global-package-files)))
- (setq name (file-name-base
- (read-file-name
- (TeX-argument-prompt t nil "File")
- nil "")))))
-
- ;; User specific input for the hook, do nothing:
- (t nil))
- ;; Process the input: For cmd or env, concat the elements with a
- ;; slash. For other hooks, check if the optional name is given
- ;; and append it with a backslash to the hook:
- (if (member hook '("cmd" "env"))
- (concat hook "/" name "/" where)
- (concat hook (when (and name (not (string= name "")))
- (concat "/" name))))))
+ ;; cmd/<name>/<where>: <where> is one of (before|after)
+ (setq name (completing-read
+ (TeX-argument-prompt nil nil "Command")
+ (TeX-symbol-list)))
+ (setq where (funcall place)))
+
+ ;; env/<name>/<where>: <where> is one of (before|after|begin|end)
+ ((string= hook "env")
+ (setq name (completing-read
+ (TeX-argument-prompt nil nil "Environment")
+ (LaTeX-environment-list)))
+ (setq where (funcall place)))
+
+ ;; file/<file-name.xxx>/<where>: <file-name> is optional and
+ ;; must be with extension and <where> is one of
+ ;; (before|after)
+ ((string= hook "file")
+ (if (funcall search)
+ (progn
+ (unless TeX-global-input-files-with-extension
+ (setq TeX-global-input-files-with-extension
+ (prog2
+ (message "Searching for files...")
+ (mapcar #'list
+ (TeX-search-files-by-type 'texinputs
+ 'global
+ t nil))
+ (message "Searching for files...done"))))
+ (setq name
+ (completing-read
+ (TeX-argument-prompt t nil "File")
+ TeX-global-input-files-with-extension)))
+ (setq name
+ (file-name-nondirectory
+ (read-file-name
+ (TeX-argument-prompt t nil "File")
+ nil ""))))
+ (setq where (funcall place)))
+
+ ;; include/<file-name>/<where>: <file-name> is optional and
+ ;; <where> is one of (before|after|end)
+ ((string= hook "include")
+ (if (funcall search)
+ (progn
+ (setq files
+ (prog2
+ (message "Searching for files...")
+ ;; \include looks for files with TeX content,
+ ;; so limit the search:
+ (let* ((TeX-file-extensions '("tex" "ltx")))
+ (TeX-search-files-by-type 'texinputs 'local t t))
+ (message "Searching for files...done")))
+ (setq name (completing-read
+ (TeX-argument-prompt t nil "File")
+ files)))
+ (setq name
+ (file-name-base
+ (read-file-name
+ (TeX-argument-prompt t nil "File")
+ nil ""))))
+ (setq where (funcall place)))
+
+ ;; class/<doc-class>/<where>: <doc-class> is optional and
+ ;; <where> is one of (before|after)
+ ((string= hook "class")
+ (if (funcall search)
+ (progn
+ (unless LaTeX-global-class-files
+ (setq LaTeX-global-class-files
+ (prog2
+ (message "Searching for LaTeX classes...")
+ (let* ((TeX-file-extensions '("cls")))
+ (mapcar #'list
+ (TeX-search-files-by-type 'texinputs
+ 'global
+ t t)))
+ (message "Searching for LaTeX classes...done"))))
+ (setq name (completing-read
+ (TeX-argument-prompt t nil "Document class")
+ LaTeX-global-class-files)))
+ (setq name
+ (file-name-base
+ (read-file-name
+ (TeX-argument-prompt t nil "Document class")
+ nil ""))))
+ (setq where (funcall place)))
+
+ ;; package/<pack-name>/<where>: <pack-name> is optional and
+ ;; <where> is one of (before|after)
+ ((string= hook "package")
+ (if (funcall search)
+ (progn
+ (unless LaTeX-global-package-files
+ (setq LaTeX-global-package-files
+ (prog2
+ (message "Searching for LaTeX packages...")
+ (let* ((TeX-file-extensions '("sty")))
+ (mapcar #'list
+ (TeX-search-files-by-type 'texinputs
+ 'global
+ t t)))
+ (message "Searching for LaTeX packages...done"))))
+ (setq name (completing-read
+ (TeX-argument-prompt t nil "Package")
+ LaTeX-global-package-files)))
+ (setq name (file-name-base
+ (read-file-name
+ (TeX-argument-prompt t nil "Package")
+ nil ""))))
+ (setq where (funcall place)))
+
+ ;; begindocument/<where>: <where> is empty or one of
+ ;; (before|end)
+ ((string= hook "begindocument")
+ (setq where (funcall place t)))
+
+ ;; enddocument/<where>: <where> is empty or one of
+ ;; (afterlastpage|afteraux|info|end)
+ ((string= hook "enddocument")
+ (setq where (funcall place t)))
+
+ ;; bfseries|mdseries/<where>: <where> is empty or defaults
+ ((member hook '("bfseries" "mdseries"))
+ (setq where (funcall place t)))
+
+ ;; shipout/<where>: <where> is one of
+ ;; (before|after|foreground|background|firstpage|lastpage)
+ ((string= hook "shipout")
+ (setq where (funcall place)))
+
+ ;; Other hooks or user specific input, do nothing:
+ (t nil))
+
+ ;; Process the input: Concat the given parts and return it
+ (concat hook
+ (when (and name (not (string= name "")))
+ (concat "/" name))
+ (when (and where (not (string= where "")))
+ (concat "/" where)))))
(defun TeX-arg-hook (optional)
"Prompt for a LaTeX hook.
- [AUCTeX-diffs] [elpa] externals/auctex 0752650 44/71: Don't use obsolete @inforef, (continued)
- [AUCTeX-diffs] [elpa] externals/auctex 0752650 44/71: Don't use obsolete @inforef, Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex bc5f7bc 60/71: Add new style/cancel.el, Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex 380bc4a 06/71: Handle optional embellishment arguments correctly, Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex db45d9e 41/71: Improve handling of key=vals in style/mdframed.el, Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex 9f3e760 10/71: Recognize L3 \msg_line_context: on warning parsing, Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex 3684fde 17/71: Explain how to support option completion, Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex 44a8a42 09/71: ; Don't use `assoc-delete-all', Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex 22e4415 68/71: Add styles for packages from sttools collection, Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex ae2d7ef 23/71: Silence compiler warning, Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex 6433dc3 30/71: Extend `TeX-read-key-val' to accept a function call, Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex c6350aa 07/71: Track standardized generic hook names in LaTeX kernel,
Tassilo Horn <=
- [AUCTeX-diffs] [elpa] externals/auctex 8e0fb65 47/71: Improve handling of key=vals in style/listings.el, Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex accfe51 58/71: Add new style/xr-hyper.el, Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex 483f6e9 05/71: ; * style/hyperref.el ("hyperref"): Fix other link to testform.tex., Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex 0c01b75 13/71: ; * doc/changes.texi: Fix a markup., Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex ee37db3 33/71: Supplement doc string, Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex bd723c7 24/71: Cater for corner case when dealing with TeX error, Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex 2e968b6 36/71: ; Fix escapings, Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex b379da7 18/71: Don't indent begin/end of comment env, Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex 08f5c9e 51/71: Improve handling of key=vals in style/floatrow.el, Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex df69443 26/71: ; Silence the compiler, Tassilo Horn, 2021/12/17