[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[AUCTeX-diffs] [elpa] externals/auctex 90b1803b02 10/60: Use DEFAULT arg
From: |
Tassilo Horn |
Subject: |
[AUCTeX-diffs] [elpa] externals/auctex 90b1803b02 10/60: Use DEFAULT argument in latex.el where appropriate |
Date: |
Fri, 8 Apr 2022 11:52:47 -0400 (EDT) |
branch: externals/auctex
commit 90b1803b024add1ad76f98a564579f263bf08e62
Author: Arash Esbati <arash@gnu.org>
Commit: Arash Esbati <arash@gnu.org>
Use DEFAULT argument in latex.el where appropriate
* latex.el (LaTeX-env-array, LaTeX-env-tabular*): Use the DEFAULT
argument of `TeX-read-string' when asking for the mandatory FMT
argument.
(LaTeX-env-minipage): Use `format' instead of `concat' to assemble
the prompt.
(LaTeX-env-bib): Use DEFAULT argument for the bibitem label.
(TeX-arg-file-name, TeX-arg-file-name-sans-extension): Use the
DEFAULT argument only when used as a mandatory argument.
(TeX-arg-date, TeX-arg-version): Add support for DEFAULT argument
of `TeX-read-string'.
---
latex.el | 100 +++++++++++++++++++++++++++++++++++++++++++++------------------
1 file changed, 71 insertions(+), 29 deletions(-)
diff --git a/latex.el b/latex.el
index 570e2d2e10..f8dd1551dd 100644
--- a/latex.el
+++ b/latex.el
@@ -1261,7 +1261,14 @@ Just like array and tabular."
(let ((pos (and LaTeX-default-position ; LaTeX-default-position can
; be nil, i.e. do not prompt
(TeX-read-string "(Optional) Position: "
LaTeX-default-position)))
- (fmt (TeX-read-string "Format: " LaTeX-default-format)))
+ (fmt (TeX-read-string
+ (if (string= LaTeX-default-format "")
+ "Format: "
+ (format "Format (default %s): " LaTeX-default-format))
+ nil nil
+ (if (string= LaTeX-default-format "")
+ nil
+ LaTeX-default-format))))
(setq LaTeX-default-position pos)
(setq LaTeX-default-format fmt)
(LaTeX-insert-environment environment
@@ -1315,14 +1322,12 @@ Just like array and tabular."
(concat TeX-esc (car elt)))
(LaTeX-length-list)))))
(inner-pos (when (and height (not (string= height "")))
- (completing-read
- (TeX-argument-prompt t nil "Inner position")
- '("t" "b" "c" "s"))))
+ (completing-read
+ (TeX-argument-prompt t nil "Inner position")
+ '("t" "b" "c" "s"))))
(width (TeX-read-string
- (TeX-argument-prompt nil nil
- (concat "Width (default "
- LaTeX-default-width
- ")"))
+ (TeX-argument-prompt nil nil (format "Width (default %s)"
+ LaTeX-default-width))
nil nil LaTeX-default-width)))
(setq LaTeX-default-position pos)
(setq LaTeX-default-width width)
@@ -1338,11 +1343,20 @@ Just like array and tabular."
(defun LaTeX-env-tabular* (environment)
"Insert ENVIRONMENT with width, position and column specifications."
- (let ((width (TeX-read-string "Width: " LaTeX-default-width))
+ (let ((width (TeX-read-string
+ (format "Width (default %s): " LaTeX-default-width)
+ nil nil LaTeX-default-width))
(pos (and LaTeX-default-position ; LaTeX-default-position can
; be nil, i.e. do not prompt
(TeX-read-string "(Optional) Position: "
LaTeX-default-position)))
- (fmt (TeX-read-string "Format: " LaTeX-default-format)))
+ (fmt (TeX-read-string
+ (if (string= LaTeX-default-format "")
+ "Format: "
+ (format "Format (default %s): " LaTeX-default-format))
+ nil nil
+ (if (string= LaTeX-default-format "")
+ nil
+ LaTeX-default-format))))
(setq LaTeX-default-width width)
(setq LaTeX-default-position pos)
(setq LaTeX-default-format fmt)
@@ -1375,7 +1389,9 @@ Just like array and tabular."
"Insert ENVIRONMENT with label for bibitem."
(LaTeX-insert-environment environment
(concat TeX-grop
- (TeX-read-string "Label for BibItem: "
"99")
+ (TeX-read-string
+ (format "Label for BibItem (default %s):
" "99")
+ nil nil "99")
TeX-grcl))
(end-of-line 0)
(delete-char 1)
@@ -2139,7 +2155,8 @@ If OPTIONAL is non-nil, insert the resulting value as an
optional
argument, otherwise as a mandatory one. Use PROMPT as the prompt
string. ARGS is unused."
(TeX-argument-insert
- (TeX-read-string (TeX-argument-prompt optional prompt "Index tag"))
optional))
+ (TeX-read-string (TeX-argument-prompt optional prompt "Index tag"))
+ optional))
(defun TeX-arg-index (optional &optional prompt &rest _args)
"Prompt for an index entry completing with known entries.
@@ -2271,11 +2288,19 @@ string."
Initial input is the name of the file being visited in the
current buffer, with extension. If OPTIONAL is non-nil, insert
it as an optional argument. Use PROMPT as the prompt string."
- (TeX-argument-insert
- (TeX-read-string
- (TeX-argument-prompt optional prompt "Name")
- (file-name-nondirectory buffer-file-name))
- optional))
+ (let ((name (file-name-nondirectory buffer-file-name)))
+ (TeX-argument-insert
+ (TeX-read-string
+ (TeX-argument-prompt optional
+ (when prompt
+ (if optional
+ prompt
+ (format (concat prompt " (default %s)") name)))
+ (if optional
+ "Name"
+ (format "Name (default %s)" name)))
+ nil nil (if optional nil name))
+ optional)))
(defun TeX-arg-file-name-sans-extension (optional &optional prompt)
"Prompt for a file name.
@@ -2283,11 +2308,20 @@ Initial input is the name of the file being visited in
the
current buffer, without extension. If OPTIONAL is non-nil,
insert it as an optional argument. Use PROMPT as the prompt
string."
- (TeX-argument-insert
- (TeX-read-string
- (TeX-argument-prompt optional prompt "Name")
- (file-name-sans-extension (file-name-nondirectory buffer-file-name)))
- optional))
+ (let ((name (file-name-sans-extension
+ (file-name-nondirectory buffer-file-name))))
+ (TeX-argument-insert
+ (TeX-read-string
+ (TeX-argument-prompt optional
+ (when prompt
+ (if optional
+ prompt
+ (format (concat prompt " (default %s)") name)))
+ (if optional
+ "Name"
+ (format "Name (default %s)" name)))
+ nil nil (if optional nil name))
+ optional)))
(defun TeX-arg-define-label (optional &optional prompt)
"Prompt for a label completing with known labels.
@@ -2774,9 +2808,12 @@ argument, otherwise as a mandatory one. Use PROMPT as
the prompt
string."
(let ((default (format-time-string TeX-date-format (current-time))))
(TeX-argument-insert
- (TeX-read-string (TeX-argument-prompt
- optional prompt (format "Date (default %s)" default))
- nil nil default)
+ (TeX-read-string
+ (TeX-argument-prompt optional
+ (when prompt
+ (format (concat prompt " (default %s)") default))
+ (format "Date (default %s)" default))
+ nil nil default)
optional)))
(defun TeX-arg-version (optional &optional prompt)
@@ -2784,10 +2821,15 @@ string."
Use as initial input the current date. If OPTIONAL is non-nil,
insert the resulting value as an optional argument, otherwise as
a mandatory one. Use PROMPT as the prompt string."
- (TeX-argument-insert
- (TeX-read-string (TeX-argument-prompt optional prompt "Version")
- (format-time-string "%Y/%m/%d" (current-time)))
- optional))
+ (let ((version (format-time-string "%Y/%m/%d" (current-time))))
+ (TeX-argument-insert
+ (TeX-read-string
+ (TeX-argument-prompt optional
+ (when prompt
+ (format (concat prompt " (default %s)") version))
+ (format "Version (default %s)" version))
+ nil nil version)
+ optional)))
(defun TeX-arg-pagestyle (optional &optional prompt definition)
"Prompt for a LaTeX pagestyle with completion.
- [AUCTeX-diffs] [elpa] externals/auctex updated (8ff369bd92 -> 03ed9004cd), Tassilo Horn, 2022/04/08
- [AUCTeX-diffs] [elpa] externals/auctex 90b1803b02 10/60: Use DEFAULT argument in latex.el where appropriate,
Tassilo Horn <=
- [AUCTeX-diffs] [elpa] externals/auctex e625dc05ea 01/60: Improve keymap handling, Tassilo Horn, 2022/04/08
- [AUCTeX-diffs] [elpa] externals/auctex 0847db39c9 03/60: Improve file query in style/ltxtable.el, Tassilo Horn, 2022/04/08
- [AUCTeX-diffs] [elpa] externals/auctex 7119e9b58c 14/60: ; Fix tests relying on font-lock has put syntax properties already, Tassilo Horn, 2022/04/08
- [AUCTeX-diffs] [elpa] externals/auctex 3e95554c27 19/60: Reduce code duplication in style/sidecap.el, Tassilo Horn, 2022/04/08
- [AUCTeX-diffs] [elpa] externals/auctex 163dcb75bd 02/60: Fix label insertion at env. insertion with active region (bug#28382), Tassilo Horn, 2022/04/08
- [AUCTeX-diffs] [elpa] externals/auctex f464242eab 29/60: Enable indent by square bracket, Tassilo Horn, 2022/04/08
- [AUCTeX-diffs] [elpa] externals/auctex f686fbca6d 16/60: Add new test, Tassilo Horn, 2022/04/08
- [AUCTeX-diffs] [elpa] externals/auctex e37c7a8b39 31/60: Revise documentation about simultaneous process, Tassilo Horn, 2022/04/08
- [AUCTeX-diffs] [elpa] externals/auctex 844e758a47 07/60: Improve indent in tabular-like environments, Tassilo Horn, 2022/04/08
- [AUCTeX-diffs] [elpa] externals/auctex 0e0551126d 17/60: * doc/changes.texi: Document switch from initial input to default., Tassilo Horn, 2022/04/08