branch: externals/auctex
commit 6433dc38e49ab79a4341ad515d1bf8986be3b9c2
Author: Arash Esbati <[email protected]>
Commit: Arash Esbati <[email protected]>
Extend `TeX-read-key-val' to accept a function call
* doc/changes.texi: Document the change.
* latex.el (TeX-read-key-val): Accept a function call returning an
alist as second argument.
---
doc/changes.texi | 12 ++++++++++++
latex.el | 17 +++++++++++++----
2 files changed, 25 insertions(+), 4 deletions(-)
diff --git a/doc/changes.texi b/doc/changes.texi
index ba5fab2..30166b9 100644
--- a/doc/changes.texi
+++ b/doc/changes.texi
@@ -40,6 +40,18 @@ uses these functions, use @code{split-string} and
@code{assoc-string}
instead.
@item
+The function @code{TeX-read-key-val} now accepts a function call as second
+argument. This change should help @AUCTeX{} style writers who use
+@code{TeX-arg-key-val} and have to deal with dynamic key-values. Example
+of usage:
+@lisp
+(TeX-add-style-hook "foo"
+ (lambda ()
+ (TeX-add-symbols
+ '("bar" (TeX-arg-key-val (function-returning-key-val))))))
+@end lisp
+
+@item
Since @AUCTeX{} 12.2, @kbd{C-x C-w} accidentally disabled the parse on
save in that buffer, even when you enabled @code{TeX-auto-save} option.
This bug was fixed.
diff --git a/latex.el b/latex.el
index 9630556..afd4190 100644
--- a/latex.el
+++ b/latex.el
@@ -3097,12 +3097,21 @@ If OPTIONAL is non-nil, indicate in the prompt that we
are
reading an optional argument. KEY-VAL-ALIST is an alist. The
car of each element should be a string representing a key and the
optional cdr should be a list with strings to be used as values
-for the key. Use PROMPT as the prompt string."
+for the key. KEY-VAL-ALIST can be a symbol or a function call
+returning an alist. Use PROMPT as the prompt string."
(multi-prompt-key-value
(TeX-argument-prompt optional prompt "Options (k=v)")
- (if (symbolp key-val-alist)
- (eval key-val-alist t)
- key-val-alist)))
+ (cond ((and (symbolp key-val-alist)
+ (boundp key-val-alist))
+ (symbol-value key-val-alist))
+ ((and (listp key-val-alist)
+ (symbolp (car key-val-alist))
+ (fboundp (car key-val-alist)))
+ (let ((head (car key-val-alist))
+ (tail (cdr key-val-alist)))
+ (apply head tail)))
+ (t
+ key-val-alist))))
(defun TeX-arg-key-val (optional key-val-alist &optional prompt)
"Prompt for keys and values in KEY-VAL-ALIST.