diff --git a/latex-table-wizard.el b/latex-table-wizard.el index 0238ae3..0b487af 100644 --- a/latex-table-wizard.el +++ b/latex-table-wizard.el @@ -90,7 +90,7 @@ (require 'latex) (require 'seq) -(require 'rx) +(eval-when-compile (require 'rx)) (require 'regexp-opt) (eval-when-compile (require 'subr-x)) (require 'transient) @@ -121,13 +121,11 @@ Capture group 1 matches the name of the macro.") (defcustom latex-table-wizard-column-delimiters '("&") "List of strings that are column delimiters if unescaped." - :type '(repeat string) - :group 'latex-table-wizard) + :type '(repeat string)) (defcustom latex-table-wizard-row-delimiters '("\\\\\\\\") "List of strings that are row delimiters if unescaped." - :type '(repeat string) - :group 'latex-table-wizard) + :type '(repeat string)) (defcustom latex-table-wizard-hline-macros '("cline" "vline" @@ -139,8 +137,7 @@ Capture group 1 matches the name of the macro.") Each member of this list is a string that would be between the \"\\\" and the arguments." - :type '(repeat string) - :group 'latex-table-wizard) + :type '(repeat string)) (defcustom latex-table-wizard-new-environments-alist nil "Alist mapping environment names to property lists. @@ -167,10 +164,9 @@ of a macro that inserts some horizontal line. For a macro :type '(alist :key-type (string :tag "Name of the environment:") :value-type (plist :key-type symbol :options (:col :row :lines) - :value-type (repeat string))) - - :group 'latex-table-wizard) + :value-type (repeat string)))) +;; Why not use `memq'? (defmacro latex-table-wizard--or (symbol &rest values) "Return non-nil if SYMBOL is `eq' to one of VALUES." (let ((bools (mapcar (lambda (value) `(eq ,symbol ,value)) @@ -452,18 +448,15 @@ is a cons cell of the form (P . V), where P is either If prop-val2 is nil, it is assumed that TABLE is a list of cells that only differ for the property in the car of PROP-VAL1 (in other words, that TABLE is either a column or a row)" - (if prop-val2 - (catch 'cell + (catch 'cell + (if prop-val2 (dolist (x table) (when (and (= (cdr prop-val1) (plist-get x (car prop-val1))) (= (cdr prop-val2) (plist-get x (car prop-val2)))) (throw 'cell x))) - nil) - (catch 'cell (dolist (x table) (when (= (cdr prop-val1) (plist-get x (car prop-val1))) - (throw 'cell x))) - nil))) + (throw 'cell x)))))) (defun latex-table-wizard--sort (table same-line dir) "Return a sorted table, column or row given TABLE. @@ -492,10 +485,10 @@ F, C precedes D and so on; and if DIR is either \\='next\\=' or (copy-table (copy-sequence table))) (if (not same-line) (sort copy-table (lambda (x y) - (let ((rows `(,(plist-get x :row) - ,(plist-get y :row))) - (cols `(,(plist-get x :column) - ,(plist-get y :column)))) + (let ((rows (list (plist-get x :row) + (plist-get y :row))) + (cols (list (plist-get x :column) + (plist-get y :column)))) (cond ((and vert (apply #'= cols)) (apply #'< rows)) (vert @@ -536,10 +529,9 @@ beginning of the available portion of the buffer." (catch 'found (while (re-search-forward regexp nil t) (when (<= (match-beginning group) position (match-end group)) - (throw 'found `(,(match-string-no-properties group) - ,(match-beginning group) - ,(match-end group)))) - nil)))))) + (throw 'found (list (match-string-no-properties group) + (match-beginning group) + (match-end group)))))))))) @@ -732,6 +724,9 @@ If SAME-LINE is non-nil, never leave current column or row." X and Y are each a list of the form \\='(B E)\\=', where B and E are markers corresponding to the beginning and the end of the buffer substring." + ;; Instead of assuming the form of X and Y, wouldn't it be better to + ;; destruct these and make sure? Then you could also avoid using + ;; `apply'? (save-excursion (let ((x-string (concat " " (string-trim @@ -821,7 +816,7 @@ Don't print any message if NO-MESSAGE is non-nil." (message "Cell (%s,%s) selected for swapping" (plist-get sel :column) (plist-get sel :row))) - (latex-table-wizard--hl-cells `(,sel))) + (latex-table-wizard--hl-cells (list sel))) ((eq thing 'row) (unless no-message (message "Row %s selected for swapping" @@ -1261,44 +1256,10 @@ information about how transient suffixes are defined (that is, how the data stored in this variable and in `latex-table-wizard-default-keys' contributes to the definition of the transient prefix)." - :type '(alist :key-type - (symbol :tag "Command:" - :options (toggle-truncate-lines - exchange-point-and-mark - universal-argument - transient-quit-all - undo - latex-table-wizard-right - latex-table-wizard-right - latex-table-wizard-left - latex-table-wizard-up - latex-table-wizard-down - latex-table-wizard-end-of-row - latex-table-wizard-beginning-of-row - latex-table-wizard-top - latex-table-wizard-bottom - latex-table-wizard-beginning-of-cell - latex-table-wizard-end-of-cell - latex-table-wizard-mark-cell - latex-table-wizard-swap-cell-right - latex-table-wizard-swap-cell-left - latex-table-wizard-swap-cell-up - latex-table-wizard-swap-cell-down - latex-table-wizard-swap-column-right - latex-table-wizard-swap-column-left - latex-table-wizard-swap-row-up - latex-table-wizard-swap-row-down - latex-table-wizard-align - latex-table-wizard-select-column - latex-table-wizard-select-row - latex-table-wizard-select-deselect-cell - latex-table-wizard-deselect-all - latex-table-wizard-swap - latex-table-wizard-insert-column - latex-table-wizard-insert-row - latex-table-wizard-kill-column - latex-table-wizard-kill-row)) - :value-type string) + :type `(alist :key-type + (symbol :tag "Command:") + :value-type string + :options ,(mapcar #'car latex-table-wizard-default-keys)) :group 'latex-table-wizard) (defun latex-table-wizard--make-suffix (symbol)