auctex-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[AUCTeX-diffs] [elpa] externals/auctex 238dad67f9 04/60: Introduce DEFAU


From: Tassilo Horn
Subject: [AUCTeX-diffs] [elpa] externals/auctex 238dad67f9 04/60: Introduce DEFAULT argument in `TeX-arg-length'
Date: Fri, 8 Apr 2022 11:52:45 -0400 (EDT)

branch: externals/auctex
commit 238dad67f937da217a75518b9fffe734830b530b
Author: Arash Esbati <arash@gnu.org>
Commit: Arash Esbati <arash@gnu.org>

    Introduce DEFAULT argument in `TeX-arg-length'
    
    * latex.el (TeX-arg-length): Add DEFAULT to argument names list
    which will be passed to `completing-read'.  Adjust how this
    argument is shown in the minibuffer when available.
    Add a default value to "enlargethispage" and "enlargethispage*".
    
    * style/ltxtable.el ("ltxtable"): Use DEFAULT argument of
    `TeX-arg-length' for the table width.
---
 latex.el          | 42 ++++++++++++++++++++++++++----------------
 style/ltxtable.el |  2 +-
 2 files changed, 27 insertions(+), 17 deletions(-)

diff --git a/latex.el b/latex.el
index bfd5b8c605..a5e57b0929 100644
--- a/latex.el
+++ b/latex.el
@@ -2222,25 +2222,35 @@ list of defined saveboxes."
         (LaTeX-add-saveboxes savebox))
     (TeX-argument-insert savebox optional TeX-esc)))
 
-(defun TeX-arg-length (optional &optional prompt initial-input definition)
+(defun TeX-arg-length (optional &optional prompt initial-input
+                                definition default)
   "Prompt for a LaTeX length.
 If OPTIONAL is non-nil, insert the resulting value as an optional
 argument, otherwise as a mandatory one.  Use PROMPT as the prompt
 string.  If INITIAL-INPUT is non-nil, insert it in the minibuffer
 initially, with point positioned at the end.  If DEFINITION is
-non-nil, the length is added to the list of defined length."
-  (let ((length (completing-read (TeX-argument-prompt optional prompt "Length")
-                                 ;; A valid length can be a macro or a length 
of
-                                 ;; the form <value><dimension>.  Input 
starting
-                                 ;; with a `\' can be completed with length
-                                 ;; macros.
-                                 (mapcar (lambda(elt) (concat TeX-esc (car 
elt)))
-                                         (LaTeX-length-list))
-                                 ;; Some macros takes as argument only a length
-                                 ;; macro (e.g., `\setlength' in its first
-                                 ;; argument, and `\newlength'), in this case 
is
-                                 ;; convenient to set `\\' as initial input.
-                                 nil nil initial-input)))
+non-nil, the length is added to the list of defined length.
+DEFAULT is passed to `completing-read', which see."
+  (let ((length
+         (completing-read
+          (TeX-argument-prompt optional
+                               ;; Cater for the case when PROMPT and
+                               ;; DEFAULT are both given:
+                               (if (and prompt default)
+                                   (concat prompt " (default " default ")")
+                                 prompt)
+                               (concat "Length"
+                                       (when (and default (not optional))
+                                         (concat " (default " default ")"))))
+          ;; A valid length can be a macro or a length of the form
+          ;; <value><dimension>.  Input starting with a `\' can be
+          ;; completed with length macros.
+          (mapcar (lambda (elt) (concat TeX-esc (car elt)))
+                  (LaTeX-length-list))
+          ;; Some macros takes as argument only a length macro (e.g.,
+          ;; `\setlength' in its first argument, and `\newlength'), in
+          ;; this case is convenient to set `\\' as initial input.
+          nil nil initial-input nil default)))
     (if (and definition (not (zerop (length length))))
         ;; Strip leading TeX-esc from macro name
         (LaTeX-add-lengths (substring length 1)))
@@ -7367,8 +7377,8 @@ function would return non-nil and `(match-string 1)' 
would return
      '("filecontents*" LaTeX-env-contents))
 
     (TeX-add-symbols
-     '("enlargethispage" TeX-arg-length)
-     '("enlargethispage*" TeX-arg-length)
+     '("enlargethispage"  (TeX-arg-length nil nil nil "1.0\\baselineskip"))
+     '("enlargethispage*" (TeX-arg-length nil nil nil "1.0\\baselineskip"))
      '("tabularnewline" [ TeX-arg-length ])
      '("suppressfloats" [ TeX-arg-tb "Suppress floats position" ])
      '("ensuremath" "Math commands")
diff --git a/style/ltxtable.el b/style/ltxtable.el
index 51b9b02550..b80eb07034 100644
--- a/style/ltxtable.el
+++ b/style/ltxtable.el
@@ -59,7 +59,7 @@ The regexp for the 2. argument is the same as for \"input\" 
and
 
    (TeX-add-symbols
     '("LTXtable"
-      (TeX-arg-length "Width" "1.0\\linewidth")
+      (TeX-arg-length "Width" nil nil "1.0\\linewidth")
       (TeX-arg-eval
        (lambda ()
          (let ((longtable (file-relative-name




reply via email to

[Prev in Thread] Current Thread [Next in Thread]