[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[AUCTeX-diffs] [elpa] externals/auctex 08f5c9e 51/71: Improve handling o
From: |
Tassilo Horn |
Subject: |
[AUCTeX-diffs] [elpa] externals/auctex 08f5c9e 51/71: Improve handling of key=vals in style/floatrow.el |
Date: |
Fri, 17 Dec 2021 15:00:35 -0500 (EST) |
branch: externals/auctex
commit 08f5c9e4c96e78806344fe26294ea2fe7158cee8
Author: Arash Esbati <arash@gnu.org>
Commit: Arash Esbati <arash@gnu.org>
Improve handling of key=vals in style/floatrow.el
* style/floatrow.el (LaTeX-floatrow-key-val-options-local)
(LaTeX-floatrow-update-key-val-options): Remove now unused
variable and function.
(LaTeX-floatrow-key-val-options): New function returning key=vals.
(LaTeX-floatrow-auto-cleanup)
(LaTeX-floatrow-arg-declare-new-options): Remove call of
`LaTeX-floatrow-update-key-val-options'.
("floatrow"): Call the function `LaTeX-floatrow-key-val-options'
instead of the variable `LaTeX-floatrow-key-val-options-local'.
Minor spacing fixes.
---
style/floatrow.el | 150 ++++++++++++++++++++++++++++--------------------------
1 file changed, 78 insertions(+), 72 deletions(-)
diff --git a/style/floatrow.el b/style/floatrow.el
index 5401f2f..be8878f 100644
--- a/style/floatrow.el
+++ b/style/floatrow.el
@@ -1,6 +1,6 @@
;;; floatrow.el --- AUCTeX style for `floatrow.sty' (v0.3b) -*-
lexical-binding: t; -*-
-;; Copyright (C) 2017--2020 Free Software Foundation, Inc.
+;; Copyright (C) 2017--2021 Free Software Foundation, Inc.
;; Author: Arash Esbati <arash@gnu.org>
;; Maintainer: auctex-devel@gnu.org
@@ -146,9 +146,74 @@
("LTcapwidth" ("table" "contents")))
"Key=value options for floatrow macros and environments.")
-(defvar LaTeX-floatrow-key-val-options-local nil
- "Buffer-local key=value options for floatrow macros and environments.")
-(make-variable-buffer-local 'LaTeX-floatrow-key-val-options-local)
+(defun LaTeX-floatrow-key-val-options ()
+ "Return an updated list of key=vals from floatrow package."
+ (append
+ (when (LaTeX-floatrow-DeclareNewOption-list)
+ (let ((vcode-keys '("precode" "rowprecode" "midcode" "postcode"
"rowpostcode"))
+ (sep-keys '("floatrowsep" "capbesidesep"))
+ result)
+ (dolist (keyvals (LaTeX-floatrow-DeclareNewOption-list) result)
+ (let* ((key (cond ((string= (nth 1 keyvals) "FloatStyle")
+ "style")
+ ((string= (nth 1 keyvals) "FloatFont")
+ "font")
+ ((string= (nth 1 keyvals) "FloatVCode")
+ "precode")
+ ((string= (nth 1 keyvals) "ColorBox")
+ "colorframeset")
+ ((string= (nth 1 keyvals) "CBoxCorners")
+ "colorframecorners")
+ ((string= (nth 1 keyvals) "ObjectSet")
+ "objectset")
+ ((string= (nth 1 keyvals) "MarginSet")
+ "margins")
+ ((string= (nth 1 keyvals) "FloatSeparators")
+ "floatrowsep")
+ ((string= (nth 1 keyvals) "FloatFootnoterule")
+ "footnoterule")
+ (t nil)))
+ (val (nth 2 keyvals))
+ (vals-predefined
+ (cadr (assoc key LaTeX-floatrow-key-val-options)))
+ (vals-parsed (cadr (assoc key result))))
+ ;; Remove entry in `result' if there is one for the `key'.
+ ;; `precode' and `floatrowsep' are special here since they
+ ;; are placeholders for other keys (see above):
+ (cond ((string= key "precode")
+ (dolist (x vcode-keys)
+ (when (assoc x result)
+ (setq result (assq-delete-all (car (assoc x result))
result)))))
+ ((string= key "floatrowsep")
+ (dolist (x sep-keys)
+ (when (assoc x result)
+ (setq result (assq-delete-all (car (assoc x result))
result)))))
+ (t
+ (when (assoc key result)
+ (setq result (assq-delete-all (car (assoc key result))
result)))))
+ ;; Add the entrie to `result'. Again, watch for `precode'
+ ;; and `floatrowsep'. Also delete any dupes:
+ (cond ((string= key "precode")
+ (dolist (x vcode-keys)
+ (cl-pushnew (list x (TeX-delete-duplicate-strings
+ (append vals-parsed
+ vals-predefined
+ (list val))))
+ result :test #'equal)))
+ ((string= key "floatrowsep")
+ (dolist (x sep-keys)
+ (cl-pushnew (list x (TeX-delete-duplicate-strings
+ (append vals-parsed
+ vals-predefined
+ (list val))))
+ result :test #'equal)))
+ (t
+ (cl-pushnew (list key (TeX-delete-duplicate-strings
+ (append vals-parsed
+ vals-predefined
+ (list val))))
+ result :test #'equal)))))))
+ LaTeX-floatrow-key-val-options))
(defvar LaTeX-floatrow-supported-float-types
'("figure" "table" ; Standard LaTeX
@@ -228,10 +293,6 @@
;; Replace initially the way fig & tab env's are inserted:
(LaTeX-floatrow-env-init)
;;
- ;; Process new key=val options:
- (when (LaTeX-floatrow-DeclareNewOption-list)
- (LaTeX-floatrow-update-key-val-options))
- ;;
;; Process new float commands like \ffigbox:
(when (LaTeX-floatrow-newfloatcommand-list)
(dolist (cmd (mapcar #'car (LaTeX-floatrow-newfloatcommand-list)))
@@ -291,56 +352,6 @@
(add-hook 'TeX-auto-cleanup-hook #'LaTeX-floatrow-auto-cleanup t)
(add-hook 'TeX-update-style-hook #'TeX-auto-parse t)
-(defun LaTeX-floatrow-update-key-val-options ()
- "Update buffer-local key-val options before offering for completion."
- (let ((vcode-keys '("precode" "rowprecode" "midcode" "postcode"
"rowpostcode"))
- (sep-keys '("floatrowsep" "capbesidesep")))
- (dolist (keyvals (LaTeX-floatrow-DeclareNewOption-list))
- (let* ((key (cond ((string= (nth 1 keyvals) "FloatStyle")
- "style")
- ((string= (nth 1 keyvals) "FloatFont")
- "font")
- ((string= (nth 1 keyvals) "FloatVCode")
- "precode")
- ((string= (nth 1 keyvals) "ColorBox")
- "colorframeset")
- ((string= (nth 1 keyvals) "CBoxCorners")
- "colorframecorners")
- ((string= (nth 1 keyvals) "ObjectSet")
- "objectset")
- ((string= (nth 1 keyvals) "MarginSet")
- "margins")
- ((string= (nth 1 keyvals) "FloatSeparators")
- "floatrowsep")
- ((string= (nth 1 keyvals) "FloatFootnoterule")
- "footnoterule")
- (t nil)))
- (val (nth 2 keyvals))
- (val-match (cadr (assoc key
LaTeX-floatrow-key-val-options-local)))
- (temp (copy-alist LaTeX-floatrow-key-val-options-local))
- (opts (cond ((string= key "precode")
- (dolist (x vcode-keys)
- (setq temp (assq-delete-all (car (assoc x temp))
temp)))
- temp)
- ((string= key "floatrowsep")
- (dolist (x sep-keys)
- (setq temp (assq-delete-all (car (assoc x temp))
temp)))
- temp)
- (t
- (assq-delete-all (car (assoc key temp)) temp)))))
- (cond ((string= key "precode")
- (dolist (x vcode-keys)
- (cl-pushnew (list x (TeX-delete-duplicate-strings (append
(list val) val-match)))
- opts :test #'equal)))
- ((string= key "floatrowsep")
- (dolist (x sep-keys)
- (cl-pushnew (list x (TeX-delete-duplicate-strings (append
(list val) val-match)))
- opts :test #'equal)))
- (t
- (cl-pushnew (list key (TeX-delete-duplicate-strings (append
(list val) val-match)))
- opts :test #'equal)))
- (setq LaTeX-floatrow-key-val-options-local (copy-alist opts))))))
-
(defun LaTeX-floatrow-arg-floatbox (optional)
"Query and insert arguments of float box commands from floatrow.sty.
If OPTIONAL is non-nil, indicate optional argument during query."
@@ -477,10 +488,9 @@ a string and corresponds to first parsed element in
(LaTeX-add-floatrow-DeclareNewOptions
(list (concat TeX-esc "Declare" key TeX-grop val TeX-grcl)
key val))
- (LaTeX-floatrow-update-key-val-options)
(TeX-argument-insert val optional)
(TeX-argument-insert
- (TeX-read-key-val optional LaTeX-floatrow-key-val-options-local)
optional)))
+ (TeX-read-key-val optional (LaTeX-floatrow-key-val-options)) optional)))
(defun LaTeX-floatrow-arg-newseparatedlabel/ref (optional type)
"Query and insert user defined label and reference macros from floatrow.sty.
@@ -543,10 +553,6 @@ only the parsed items."
(TeX-auto-add-regexp LaTeX-floatrow-newseparatedlabel-ref-regexp)
(TeX-auto-add-regexp LaTeX-floatrow-DeclareNewFloatType-regexp)
- ;; Activate the buffer-local version of key-vals
- (setq LaTeX-floatrow-key-val-options-local
- (copy-alist LaTeX-floatrow-key-val-options))
-
;; Add pre-defined float commands:
(LaTeX-add-floatrow-newfloatcommands
"ffigbox" "fcapside" "ttabbox")
@@ -556,9 +562,9 @@ only the parsed items."
;; 2.1 The \floatbox Macro
;; \floatbox[<preamble>]{<captype>}[<width>][<height>][<vert
pos>]{<caption>}{<object>}
'("floatbox"
- [ TeX-arg-eval completing-read
- (TeX-argument-prompt t nil "Preamble")
- '("\\capbeside" "\\nocapbeside" "\\captop") ]
+ [TeX-arg-eval completing-read
+ (TeX-argument-prompt t nil "Preamble")
+ '("\\capbeside" "\\nocapbeside" "\\captop")]
(TeX-arg-eval completing-read
(TeX-argument-prompt nil nil "Float type")
LaTeX-floatrow-supported-float-types)
@@ -608,14 +614,14 @@ only the parsed items."
;; 3 Float Layout Settings
'("floatsetup"
- [ TeX-arg-eval completing-read
- (TeX-argument-prompt t nil "Float type")
- LaTeX-floatrow-supported-float-types ]
- (TeX-arg-key-val LaTeX-floatrow-key-val-options-local))
+ [TeX-arg-eval completing-read
+ (TeX-argument-prompt t nil "Float type")
+ LaTeX-floatrow-supported-float-types]
+ (TeX-arg-key-val (LaTeX-floatrow-key-val-options)))
;; 3.2 Settings for Current Float Environment
'("thisfloatsetup"
- (TeX-arg-key-val LaTeX-floatrow-key-val-options-local))
+ (TeX-arg-key-val (LaTeX-floatrow-key-val-options)))
;; 3.3 Clearing of Settings for Current Float Type
'("clearfloatsetup"
- [AUCTeX-diffs] [elpa] externals/auctex 6433dc3 30/71: Extend `TeX-read-key-val' to accept a function call, (continued)
- [AUCTeX-diffs] [elpa] externals/auctex 6433dc3 30/71: Extend `TeX-read-key-val' to accept a function call, Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex c6350aa 07/71: Track standardized generic hook names in LaTeX kernel, Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex 8e0fb65 47/71: Improve handling of key=vals in style/listings.el, Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex accfe51 58/71: Add new style/xr-hyper.el, Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex 483f6e9 05/71: ; * style/hyperref.el ("hyperref"): Fix other link to testform.tex., Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex 0c01b75 13/71: ; * doc/changes.texi: Fix a markup., Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex ee37db3 33/71: Supplement doc string, Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex bd723c7 24/71: Cater for corner case when dealing with TeX error, Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex 2e968b6 36/71: ; Fix escapings, Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex b379da7 18/71: Don't indent begin/end of comment env, Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex 08f5c9e 51/71: Improve handling of key=vals in style/floatrow.el,
Tassilo Horn <=
- [AUCTeX-diffs] [elpa] externals/auctex df69443 26/71: ; Silence the compiler, Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex 0419539 37/71: Improve style/babel.el, Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex d62d8f3 34/71: Update style/fontspec.el to package version 2.7i, Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex 9e97edc 49/71: Fix wrong logic of the previous commit, Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex 8c50665 62/71: Add new style/unicodefonttable.el, Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex 7b632c6 43/71: * doc/todo.texi (Mid-term Goals): Add TODO about tool bar., Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex 7c4147b 57/71: Improve handling of key=vals in style/tcolorbox.el, Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex f6dd4a4 25/71: ; Silence the compiler, Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex df0d719 52/71: Improve handling of key=vals in style/hologo.el, Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex 2e26d49 61/71: Update style/siunitx.el to package version 3, Tassilo Horn, 2021/12/17