branch: externals/auctex commit 259ffc34c474f559d840e5ab4701780629bc8791 Author: Arash Esbati <ar...@gnu.org> Commit: Arash Esbati <ar...@gnu.org>
Use DEFAULT argument of `TeX-read-string' in styles * style/longtable.el (LaTeX-env-longtable): * style/ocg-p.el (LaTeX-env-ocgp-ocgtabular): * style/plext.el (LaTeX-plext-env-array): * style/xltabular.el (LaTeX-env-xltabular): Use the DEFAULT argument in `TeX-read-string' where applicable. --- style/longtable.el | 21 ++++++++++++++++----- style/ocg-p.el | 11 +++++++++-- style/plext.el | 15 ++++++++++++--- style/xltabular.el | 28 +++++++++++++++++++++------- 4 files changed, 58 insertions(+), 17 deletions(-) diff --git a/style/longtable.el b/style/longtable.el index 2646e339ab..8db4083c66 100644 --- a/style/longtable.el +++ b/style/longtable.el @@ -1,6 +1,6 @@ ;;; longtable.el --- AUCTeX style for `longtable.sty'. -*- lexical-binding: t; -*- -;; Copyright (C) 2013--2020 Free Software Foundation, Inc. +;; Copyright (C) 2013--2022 Free Software Foundation, Inc. ;; Maintainer: auctex-devel@gnu.org ;; Author: Mosè Giordano <m...@gnu.org> @@ -56,13 +56,24 @@ insert line break macro." (defun LaTeX-env-longtable (environment) "Insert a longtable-like ENVIRONMENT with caption and label." - (let* ((pos (completing-read (TeX-argument-prompt t nil "Position") - '(("l") ("r") ("c")))) - (fmt (TeX-read-string "Format: " LaTeX-default-format)) + (let* ((pos (and LaTeX-default-position ; `LaTeX-default-position' + ; can be nil, i.e. no prompt + (completing-read (TeX-argument-prompt t nil "Position") + '("l" "r" "c") + nil nil LaTeX-default-position))) + (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))) (caption (TeX-read-string "Caption: ")) (short-caption (when (>= (length caption) LaTeX-short-caption-prompt-length) (TeX-read-string "(Optional) Short caption: ")))) - (setq LaTeX-default-format fmt) + (setq LaTeX-default-position pos + LaTeX-default-format fmt) (LaTeX-insert-environment environment (concat (unless (zerop (length pos)) diff --git a/style/ocg-p.el b/style/ocg-p.el index 26f881f445..d3ab40da89 100644 --- a/style/ocg-p.el +++ b/style/ocg-p.el @@ -1,6 +1,6 @@ ;;; ocg-p.el --- AUCTeX style for `ocg-p.sty' (v0.4) -*- lexical-binding: t; -*- -;; Copyright (C) 2018, 2020 Free Software Foundation, Inc. +;; Copyright (C) 2018--2022 Free Software Foundation, Inc. ;; Author: Arash Esbati <ar...@gnu.org> ;; Maintainer: auctex-devel@gnu.org @@ -123,7 +123,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))) (dbase (TeX-read-string "Database name: ")) (opts (TeX-read-string "Additional options: "))) (setq LaTeX-default-position pos) diff --git a/style/plext.el b/style/plext.el index 8b4cf0b3f3..26e564e584 100644 --- a/style/plext.el +++ b/style/plext.el @@ -1,6 +1,6 @@ ;;; plext.el --- AUCTeX style for the plext package. -*- lexical-binding: t; -*- -;; Copyright (C) 2014, 2020 Free Software Foundation, Inc. +;; Copyright (C) 2014, 2020, 2022 Free Software Foundation, Inc. ;; Author: Ikumi Keita <ik...@ikumi.que.jp> ;; Maintainer: auctex-devel@gnu.org @@ -55,11 +55,20 @@ (defun LaTeX-plext-env-array (env) (let ((dir (TeX-read-string "(Optional) Direction (t or y or z): ")) (width (if (string= env "tabular*") - (TeX-read-string "Width: " LaTeX-default-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)))) (unless (zerop (length dir)) (setq dir (concat "<" dir ">"))) (if (string= env "tabular*") diff --git a/style/xltabular.el b/style/xltabular.el index 09c5a97248..3fb3e0d220 100644 --- a/style/xltabular.el +++ b/style/xltabular.el @@ -1,6 +1,6 @@ ;;; xltabular.el --- AUCTeX style for `xltabular.sty' (v0.05) -*- lexical-binding: t; -*- -;; Copyright (C) 2017, 2020 Free Software Foundation, Inc. +;; Copyright (C) 2017--2022 Free Software Foundation, Inc. ;; Author: Arash Esbati <ar...@gnu.org> ;; Maintainer: auctex-devel@gnu.org @@ -49,15 +49,29 @@ nested curly brace pair nor escaped \"}\".") ;; Optional <hPos> comes before <width>, hence we cannot use ;; `LaTeX-env-tabular*' here and has to cook our own function which ;; is a combination of `LaTeX-env-tabular*' and - ;; `LaTeX-env-longtable': - (let* ((pos (completing-read (TeX-argument-prompt t nil "Position") - '("l" "r" "c"))) - (width (TeX-read-string "Width: " LaTeX-default-width)) - (fmt (TeX-read-string "Format: " LaTeX-default-format)) + ;; `LaTeX-env-longtable'. Note that `LaTeX-default-position' can be + ;; nil, i.e. do not prompt: + (let* ((pos (and LaTeX-default-position + (completing-read (TeX-argument-prompt t nil "Position") + '("l" "r" "c") + nil nil LaTeX-default-position))) + (width (TeX-read-string + (format "Width (default %s): " LaTeX-default-width) + nil nil LaTeX-default-width)) + (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))) (caption (TeX-read-string "Caption: ")) (short-caption (when (>= (length caption) LaTeX-short-caption-prompt-length) (TeX-read-string "(Optional) Short caption: ")))) - (setq LaTeX-default-format fmt) + (setq LaTeX-default-position pos + LaTeX-default-width width + LaTeX-default-format fmt) (LaTeX-insert-environment environment (concat (unless (zerop (length pos)) _______________________________________________ auctex-diffs mailing list auctex-di...@gnu.org https://lists.gnu.org/mailman/listinfo/auctex-diffs