[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 9a3078e510 68/77: Fix comments and doc strings, (continued)
- [elpa] externals/auctex 9a3078e510 68/77: Fix comments and doc strings, Tassilo Horn, 2022/08/26
- [elpa] externals/auctex 30f7a1ca68 63/77: Don't use void function texinfo-outline-level, Tassilo Horn, 2022/08/26
- [elpa] externals/auctex 3447aa75c3 32/77: ; Further fixes about single quotes in docstrings, Tassilo Horn, 2022/08/26
- [elpa] externals/auctex fade32d568 54/77: Don't break line inside \verb-like macro (bug#56160), Tassilo Horn, 2022/08/26
- [elpa] externals/auctex 545129e1c3 55/77: * style/shortvrb.el: Add missing macros incl. fontification., Tassilo Horn, 2022/08/26
- [elpa] externals/auctex 010a1e24be 01/77: Follow up the previous commit, Tassilo Horn, 2022/08/26
- [elpa] externals/auctex fa547aa71e 02/77: Don't increase indentation after \iff, Tassilo Horn, 2022/08/26
- [elpa] externals/auctex f33df119ce 06/77: Ensure "make maintainer-clean" deletes dynvars files, Tassilo Horn, 2022/08/26
- [elpa] externals/auctex 58bc18eaf7 11/77: Be more robust against false positive, Tassilo Horn, 2022/08/26
- [elpa] externals/auctex ba568ead99 24/77: ; Silence the compiler for the change in 37e5a450, Tassilo Horn, 2022/08/26
- [elpa] externals/auctex 8404fe8b18 17/77: Provide generic completion functions,
Tassilo Horn <=
- [elpa] externals/auctex 9ca155cdb0 25/77: Improve fontification of kernel macros, Tassilo Horn, 2022/08/26
- [elpa] externals/auctex 46373674e2 22/77: ; Fix completion for counters made in 37e5a450, Tassilo Horn, 2022/08/26
- [elpa] externals/auctex e30fda8130 26/77: ; Really silence the compiler for the change in 37e5a450, Tassilo Horn, 2022/08/26
- [elpa] externals/auctex 59ef475125 30/77: Simplify regexp, Tassilo Horn, 2022/08/26
- [elpa] externals/auctex 60ca36b5a1 39/77: ; * .gitignore: Exclude temp files produced by 2022-06-01 kernel., Tassilo Horn, 2022/08/26
- [elpa] externals/auctex d1f2c2cdb2 41/77: Add new style/proc.el, Tassilo Horn, 2022/08/26
- [elpa] externals/auctex 054b38887b 42/77: Fix (void-variable compilation-in-progress) error, Tassilo Horn, 2022/08/26
- [elpa] externals/auctex b24dcb4feb 40/77: Track changes in LaTeX kernel 2022-06-01, Tassilo Horn, 2022/08/26
- [elpa] externals/auctex 4163bb5c42 66/77: Fix `autoconf` warnings, 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