branch: main commit 25bb1db72158db5a9c239e0a0077404402405b94 Author: Arash Esbati <ar...@gnu.org> Commit: Arash Esbati <ar...@gnu.org>
Improve user query * style/thmtools.el (LaTeX-thmtools-env-label): * style/keytheorems.el (LaTeX-env-keytheorems-label): Use `read-multiple-choice' for the user query. Pass the help string through `substitute-command-keys'. --- style/keytheorems.el | 22 ++++++++++----------- style/thmtools.el | 55 ++++++++++++++++++++++++---------------------------- 2 files changed, 36 insertions(+), 41 deletions(-) diff --git a/style/keytheorems.el b/style/keytheorems.el index f1cb5693..1c151315 100644 --- a/style/keytheorems.el +++ b/style/keytheorems.el @@ -221,24 +221,24 @@ RefTeX users should customize or add ENVIRONMENT to both (add-to-list \\='reftex-label-alist \\='(\"theorem\" ?m \"thm:\" \"~\\ref{%s}\" nil (\"Theorem\" \"theorem\") nil))" - (let* ((help-form "\ + (let* ((help (substitute-command-keys "\ Select the content of the optional argument with a key: -'h' in order to insert a plain heading, -'k' in order to insert key=value pairs with completion, -RET in order to leave it empty.") - (choice (read-char-choice - (TeX-argument-prompt - nil nil "Heading (h), Key=val (k), Empty (RET), Help (C-h)") - '(?h ?k ?\r))) - (opthead (pcase choice +\\`h' in order to insert a plain heading, +\\`k' in order to insert key=value pairs with completion, +\\`RET' in order to leave it empty.")) + (choice (read-multiple-choice "Heading options" + '((?h "heading") + (?k "key-value") + (?\r "empty")) + help)) + (opthead (pcase (car choice) (?h (TeX-read-string (TeX-argument-prompt t nil "Heading"))) (?k (TeX-read-key-val t LaTeX-keytheorems-package-options-list)) ;; Clear minibuffer and don't leave the ugly ^M ;; there, return an empty string: (_ (message nil) "")))) (LaTeX-insert-environment environment - (when (and opthead - (not (string-empty-p opthead))) + (when (and opthead (not (string-empty-p opthead))) (format "[%s]" opthead)))) (when (LaTeX-label environment 'environment) (LaTeX-newline) diff --git a/style/thmtools.el b/style/thmtools.el index 69be5465..5a126f1d 100644 --- a/style/thmtools.el +++ b/style/thmtools.el @@ -217,38 +217,33 @@ RefTeX users should customize or add ENVIRONMENT to (add-to-list \\='reftex-label-alist \\='(\"theorem\" ?m \"thm:\" \"~\\ref{%s}\" nil (\"Theorem\" \"theorem\") nil))" - (let* ((help-form "\ + (let* ((help (substitute-command-keys "\ Select the content of the optional argument with a key: -'h' in order to insert a plain heading, -'k' in order to insert key=value pairs with completion, -RET in order to leave it empty.") - (choice (read-char-choice - (TeX-argument-prompt - nil nil "Heading (h), Key=val (k), Empty (RET), Help (C-h)") - '(?h ?k ?\r))) - (opthead (cond ((= choice ?h) - (TeX-read-string - (TeX-argument-prompt t nil "Heading"))) - ((= choice ?k) - (TeX-read-key-val - t - `(("name") - ("continues" ,(mapcar #'car (LaTeX-label-list))) - ("restate" ,(mapcar #'car (LaTeX-label-list))) - ;; We don't offer a label key here: It is - ;; marked "experimental" in the manual and - ;; inserting and parsing \label{foo} is - ;; much easier for AUCTeX and RefTeX - ;; ("label") - ("listhack" ("true" "false"))))) - (t - ;; Clear minibuffer and don't leave the ugly - ;; ^M there and return an empty string: - (message nil) - "")))) +\\`h' in order to insert a plain heading, +\\`k' in order to insert key=value pairs with completion, +\\`RET' in order to leave it empty.")) + (choice (read-multiple-choice "Heading options" + '((?h "heading") + (?k "key-value") + (?\r "empty")) + help)) + (opthead (pcase (car choice) + (?h (TeX-read-string (TeX-argument-prompt t nil "Heading"))) + (?k (TeX-read-key-val + t `(("name") + ("continues" ,(mapcar #'car (LaTeX-label-list))) + ("restate" ,(mapcar #'car (LaTeX-label-list))) + ;; We don't offer a label key here: It is + ;; marked "experimental" in the manual and + ;; inserting and parsing \label{foo} is + ;; much easier for AUCTeX and RefTeX + ;; ("label") + ("listhack" ("true" "false"))))) + ;; Clear minibuffer and don't leave the ugly ^M + ;; there, return an empty string: + (_ (message nil) "")))) (LaTeX-insert-environment environment - (when (and opthead - (not (string= opthead ""))) + (when (and opthead (not (string-empty-p opthead))) (format "[%s]" opthead)))) (when (LaTeX-label environment 'environment) (LaTeX-newline)