[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/auctex 8404fe8b18 17/77: Provide generic completion fun
From: |
Tassilo Horn |
Subject: |
[elpa] externals/auctex 8404fe8b18 17/77: Provide generic completion functions |
Date: |
Fri, 26 Aug 2022 16:06:32 -0400 (EDT) |
branch: externals/auctex
commit 8404fe8b1843ef1f7189df7221f58ffe9f262167
Author: Arash Esbati <arash@gnu.org>
Commit: Arash Esbati <arash@gnu.org>
Provide generic completion functions
* latex.el (TeX-read-completing-read, TeX-arg-completing-read)
(TeX-read-completing-read-multiple)
(TeX-arg-completing-read-multiple): Add generic functions to read
and insert arguments with completion.
---
latex.el | 119 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 119 insertions(+)
diff --git a/latex.el b/latex.el
index 7ec66cd923..a6ab5220c3 100644
--- a/latex.el
+++ b/latex.el
@@ -3245,6 +3245,125 @@ returning an alist. Use PROMPT as the prompt string."
(t
key-val-alist))))
+(defun TeX-read-completing-read (optional collection &optional prompt complete
+ predicate require-match
+ initial-input hist def
+ inherit-input-method)
+ "Read a string in the minibuffer, with completion and return it.
+If OPTIONAL is non-nil, indicate it in the prompt.
+
+COLLECTION provides elements for completion and is passed to
+`completing-read'. It can be:
+ - A List or an alist
+ - A symbol returning a list
+ - A function call
+
+PROMPT replaces the standard one where ' (cr): ' is appended to
+it. If you want the full control over the prompt, set COMPLETE
+to non-nil and then provide a full PROMPT.
+
+PREDICATE, REQUIRE-MATCH, INITIAL-INPUT, HIST, DEF and
+INHERIT-INPUT-METHOD are passed to `completing-read', which see."
+ (completing-read
+ (TeX-argument-prompt optional
+ (cond ((and prompt (not complete))
+ (concat prompt " (cr)"))
+ ((and prompt complete)
+ prompt)
+ (t "Option (cr)"))
+ complete)
+ (cond ((and (symbolp collection)
+ (boundp collection))
+ (symbol-value collection))
+ ((and (listp collection)
+ (symbolp (car collection))
+ (fboundp (car collection)))
+ (if (> (length collection) 1)
+ (eval collection t)
+ (funcall (car collection))))
+ (t collection))
+ predicate require-match initial-input hist def inherit-input-method))
+
+(defun TeX-arg-completing-read (optional collection &optional prompt complete
+ prefix predicate require-match
+ initial-input hist def
+ inherit-input-method)
+ "Read a string in the minibuffer, with completion and insert it.
+If OPTIONAL is non-nil, indicate it in the minibuffer and insert
+the result in brackets if not empty.
+
+For PROMPT and COMPLETE, refer to `TeX-read-completing-read'.
+For PREFIX, see `TeX-argument-insert'.
+PREDICATE, REQUIRE-MATCH, INITIAL-INPUT, HIST, DEF and
+INHERIT-INPUT-METHOD are passed to `completing-read', which see."
+ (TeX-argument-insert
+ (TeX-read-completing-read optional collection prompt complete
+ predicate require-match initial-input
+ hist def inherit-input-method)
+ optional prefix))
+
+(defun TeX-read-completing-read-multiple (optional table &optional prompt
complete
+ predicate require-match
+ initial-input hist def
+ inherit-input-method)
+ "Read multiple strings in the minibuffer, with completion and return them.
+If OPTIONAL is non-nil, indicate it in the prompt.
+
+COLLECTION provides elements for completion and is passed to
+`completing-read'. It can be:
+ - A List or an alist
+ - A symbol returning a list
+ - A function call
+
+PROMPT replaces the standard one where ' (crm): ' is appended to
+it. If you want the full control over the prompt, set COMPLETE
+to non-nil and then provide a full PROMPT.
+
+PREDICATE, REQUIRE-MATCH, INITIAL-INPUT, HIST, DEF and
+INHERIT-INPUT-METHOD are passed to
+`TeX-completing-read-multiple', which see."
+ (TeX-completing-read-multiple
+ (TeX-argument-prompt optional
+ (cond ((and prompt (not complete))
+ (concat prompt " (crm)"))
+ ((and prompt complete)
+ prompt)
+ (t "Options (crm)"))
+ complete)
+ (cond ((and (symbolp table)
+ (boundp table))
+ (symbol-value table))
+ ((and (listp table)
+ (symbolp (car table))
+ (fboundp (car table)))
+ (if (> (length table) 1)
+ (eval table t)
+ (funcall (car table))))
+ (t table))
+ predicate require-match initial-input hist def inherit-input-method))
+
+(defun TeX-arg-completing-read-multiple (optional table &optional prompt
complete
+ prefix predicate
require-match
+ initial-input hist def
+ inherit-input-method)
+ "Read multiple strings in the minibuffer, with completion and insert them.
+If OPTIONAL is non-nil, indicate it in the minibuffer and insert
+the result in brackets if not empty.
+
+For PROMPT and COMPLETE, refer to `TeX-read-completing-read-multiple'.
+For PREFIX, see `TeX-argument-insert'.
+PREDICATE, REQUIRE-MATCH, INITIAL-INPUT, HIST, DEF and
+INHERIT-INPUT-METHOD are passed to
+`TeX-completing-read-multiple', which see."
+ (TeX-argument-insert
+ (mapconcat #'identity
+ (TeX-read-completing-read-multiple optional table prompt
+ complete predicate
+ require-match initial-input
+ hist def inherit-input-method)
+ ",")
+ optional prefix))
+
(defun TeX-arg-key-val (optional key-val-alist &optional prompt)
"Prompt for keys and values in KEY-VAL-ALIST.
Insert the given value as a TeX macro argument. If OPTIONAL is
- [elpa] externals/auctex 9b5cf4b550 27/77: Fix insertion of second optional argument, (continued)
- [elpa] externals/auctex 9b5cf4b550 27/77: Fix insertion of second optional argument, Tassilo Horn, 2022/08/26
- [elpa] externals/auctex 39e0062235 46/77: Introduce face and keyword class for underlined text, Tassilo Horn, 2022/08/26
- [elpa] externals/auctex d1d1bd819d 47/77: Control the opening and closing braces during insertion, Tassilo Horn, 2022/08/26
- [elpa] externals/auctex 6e25d11aa6 44/77: Add comment, Tassilo Horn, 2022/08/26
- [elpa] externals/auctex ce4bb7c1b6 58/77: ; * style/doc.el: Delete spurious `declare-function'., Tassilo Horn, 2022/08/26
- [elpa] externals/auctex 06db9e302b 75/77: Add new style/tcolorboxlib-theorems.el, Tassilo Horn, 2022/08/26
- [elpa] externals/auctex f2138e9a74 33/77: New option for saving auto parsed information (bug#55511), Tassilo Horn, 2022/08/26
- [elpa] externals/auctex 4486056d50 16/77: Add new style/ltcaption.el, Tassilo Horn, 2022/08/26
- [elpa] externals/auctex 019bcc9cc3 48/77: ; * style/proc.el: Fix a typo., Tassilo Horn, 2022/08/26
- [elpa] externals/auctex 7d7e563862 34/77: * doc/changes.texi: Add NEWS item for the previous commit., Tassilo Horn, 2022/08/26
- [elpa] externals/auctex 8404fe8b18 17/77: Provide generic completion functions,
Tassilo Horn <=
- [elpa] externals/auctex b377080c80 50/77: Add notification about xelatex in preview-latex doc, Tassilo Horn, 2022/08/26
- [elpa] externals/auctex fe15af59d0 76/77: Merge remote-tracking branch 'origin/master' into externals/auctex, Tassilo Horn, 2022/08/26
- [elpa] externals/auctex 19a2607b42 73/77: Unbreak building with Emacs 29 after obsoleting autoload.el, Tassilo Horn, 2022/08/26
- [elpa] externals/auctex e194656ce2 28/77: Let RefTeX recognize labels in user defined environments, Tassilo Horn, 2022/08/26
- [elpa] externals/auctex 87b24d0963 45/77: Add support for the Sioyek document viewer, Tassilo Horn, 2022/08/26
- [elpa] externals/auctex 23f4040c9d 57/77: Add new test, Tassilo Horn, 2022/08/26
- [elpa] externals/auctex 34fd998400 21/77: ; * bib-cite.el (): Silence byte compiler, Tassilo Horn, 2022/08/26
- [elpa] externals/auctex 3a1a820bdf 18/77: ; Rearrange code after last commit., Tassilo Horn, 2022/08/26
- [elpa] externals/auctex 794ecb01ab 35/77: Fontify \maketitle macro, Tassilo Horn, 2022/08/26
- [elpa] externals/auctex ead30464d8 64/77: * style/listings.el (TeX-add-style-hook): Update fontification., Tassilo Horn, 2022/08/26