[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/latex-table-wizard a3bb0cf5f5 27/70: Replace cl-lib wit
From: |
ELPA Syncer |
Subject: |
[elpa] externals/latex-table-wizard a3bb0cf5f5 27/70: Replace cl-lib with seq and remove inlines |
Date: |
Sat, 13 May 2023 08:59:11 -0400 (EDT) |
branch: externals/latex-table-wizard
commit a3bb0cf5f52dca4704e83ba35babba0a43c982e8
Author: Enrico Flor <nericoflor@gmail.com>
Commit: Enrico Flor <nericoflor@gmail.com>
Replace cl-lib with seq and remove inlines
---
latex-table-wizard.el | 108 +++++++++++++++++++++++++-------------------------
1 file changed, 53 insertions(+), 55 deletions(-)
diff --git a/latex-table-wizard.el b/latex-table-wizard.el
index 34616bf20f..550e8412b1 100644
--- a/latex-table-wizard.el
+++ b/latex-table-wizard.el
@@ -48,21 +48,21 @@
;; (that is, a table inside of the cell of a table).
;; The only command you need to remember (and perhaps bind a
-;; conveniente key to) is latex-table-wizard-do. This is actually a
-;; transient prefix, so that all the other commands will be available
-;; from a prompt in the echo area. All the commands provided by this
-;; package (including latex-table-wizard-do) assume that point is
-;; inside of the table-like environment you want to edit when they are
-;; called.
-
-;; The keybinding set by default in the prefix latex-table-wizard-do
-;; are inspired to some extent by Emacs defaults. If you want to
-;; change these keybindings or change the layout of the transient
-;; interface in any way you should redefine the transient prefix in
-;; your configuration (or define a new one with another name), by
-;; taking inspiration from the one defined in this file (the macro
-;; that does that is called transient-define-prefix). Check out the
-;; documentation transient.el and
+;; conveniente key to) is latex-table-wizard-do. This command calls a
+;; transient prefix called latex-table-wizard-prefix, so that all the
+;; other commands will be available from a prompt in the echo area.
+;; All the commands provided by this package (including
+;; latex-table-wizard-do) assume that point is inside of the
+;; table-like environment you want to edit when they are called.
+
+;; The keybinding set by default in the transient prefix are inspired
+;; to some extent by Emacs defaults. If you want to change these
+;; keybindings or change the layout of the transient interface in any
+;; way you should redefine the transient prefix in your configuration
+;; (or define a new one with another name), by taking inspiration from
+;; the one defined in this file (the macro that does that is called
+;; transient-define-prefix). Check out the documentation transient.el
+;; and
;;
;; M-x describe-function transient-define-prefix
@@ -93,7 +93,7 @@
;;; Dependencies
(require 'latex)
-(require 'cl-lib)
+(require 'seq)
(require 'rx)
(require 'regexp-opt)
(eval-when-compile (require 'subr-x))
@@ -135,7 +135,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.")
-(cl-defsubst latex-table-wizard--unescaped-p (&optional position)
+(defun latex-table-wizard--unescaped-p (&optional position)
"Return t if LaTeX macro starting at POSITION is not escaped.
If POSITION is nil, use the value of `point'.
@@ -149,7 +149,7 @@ A macro is escaped if it is preceded by a single
\\='\\\\='."
(let ((matched (buffer-substring-no-properties
(match-beginning 0)
(match-end 0))))
- (when (cl-evenp (length matched)) t))))))
+ (when (eq (logand (length matched) 1) 0) t))))))
;; Every time latex-table-wizard--parse-table is evaluated, the values
;; of the variables below is set:
@@ -225,7 +225,7 @@ If the current environment is one that is mapped to
something in
;; plists. ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-(cl-defsubst latex-table-wizard--end-of-macro (&optional name)
+(defun latex-table-wizard--end-of-macro (&optional name)
"If looking at unescaped macro named NAME, go to its end.
If NAME is nil, skip any LaTeX macro that point is looking at."
@@ -235,14 +235,14 @@ If NAME is nil, skip any LaTeX macro that point is
looking at."
(when (looking-at macro-re)
(match-end 0)))))
-(cl-defsubst latex-table-wizard--disjoin (str-list &optional sep)
+(defun latex-table-wizard--disjoin (str-list &optional sep)
"Concatenate strings in STR-LIST with separator SEP.
If SEP is nil, the separator used is \"\\\\|\""
(let ((separator (or sep "\\|")))
(mapconcat #'identity str-list separator)))
-(cl-defsubst latex-table-wizard--skip-stuff (limit)
+(defun latex-table-wizard--skip-stuff (limit)
"Skip comments, blank space and hline macros.
Hline macros are LaTeX macros whose name is a string in
@@ -278,9 +278,9 @@ Stop the skipping at LIMIT (a buffer position or a marker)."
(setq done t)))))
(when new-start-of-line (goto-char new-start-of-line))))
-(cl-defsubst latex-table-wizard--get-cell-boundaries (col-re
- row-re
- &optional limit)
+(defun latex-table-wizard--get-cell-boundaries (col-re
+ row-re
+ &optional limit)
"Return boundaries of current cell (where point is).
What is returned is a list of the form
@@ -336,7 +336,7 @@ argument."
(forward-char 1))))
`(,beg ,end ,end-of-row)))
-(cl-defsubst latex-table-wizard--get-env-ends (table)
+(defun latex-table-wizard--get-env-ends (table)
"Given TABLE, return beginning and end of the environment.
TABLE is a list of cell plists. The return type is a cons
@@ -436,7 +436,7 @@ other words, that TABLE is either a column or a row)"
(throw 'cell x)))
nil)))
-(cl-defsubst latex-table-wizard--sort (dir x y)
+(defun latex-table-wizard--sort (dir x y)
"Return t if cell X precedes Y.
Precedence depends on the value of DIR (either \\='next\\=',
@@ -472,7 +472,7 @@ of DIR (either \\='next\\=', \\='previous\\=',
\\='forward\\=' or
0
(thread-last
table
- (cl-remove-if-not
+ (seq-filter
(lambda (x) (= (plist-get x same-prop) same-value)))
(mapcar (lambda (x) (plist-get x different-prop)))
(apply #'max)))))
@@ -480,9 +480,9 @@ of DIR (either \\='next\\=', \\='previous\\=',
\\='forward\\=' or
`(,same-prop . ,same-value)
`(,different-prop . ,different-value))))
-(cl-defsubst latex-table-wizard--point-on-regexp-p (regexp
- &optional capture-group
- search-beginning-pos)
+(defun latex-table-wizard--point-on-regexp-p (regexp
+ &optional capture-group
+ search-beginning-pos)
"Return non-nil if point is on a substring matched by REGEXP.
If CAPTURE-GROUP is non-nil, limit the condition to the substring
@@ -536,7 +536,7 @@ current DIR."
:row
:column))
(other-prop (if (eq prop :row) :column :row)))
- (sort (cl-remove-if-not
+ (sort (seq-filter
(lambda (x) (= (plist-get x prop)
(plist-get curr prop)))
table)
@@ -546,7 +546,7 @@ current DIR."
(lambda (x y)
(latex-table-wizard--sort dir x y)))))
(cell-num (length sorted))
- (now (cl-position curr sorted :test 'equal))
+ (now (seq-position sorted curr))
(new-index (if (or (eq dir 'next) (eq dir 'forward))
(+ now count)
(- now count))))
@@ -599,14 +599,14 @@ The overlay has a non-nil value for the name property
(defvar-local latex-table-wizard--selection nil
"Current selection, a list of cell objects.")
-(cl-defsubst latex-table-wizard--locate-point (pos table)
+(defun latex-table-wizard--locate-point (pos table)
"Return cell from TABLE in which position POS is in.
POS is a buffer position or a marker.
If POS is not in a cell in TABLE, it means it's between two
cells: return the closest one."
- (let ((candidate (car (cl-remove-if-not
+ (let ((candidate (car (seq-filter
(lambda (x) (<= (plist-get x :start)
pos
(plist-get x :end)))
@@ -617,16 +617,16 @@ cells: return the closest one."
((< pos (car ends))
(latex-table-wizard--get-cell-pos table '(:column . 0) '(:row . 0)))
((> pos (cdr ends))
- (car (cl-remove-if-not
+ (car (seq-filter
(lambda (x) (= (plist-get x :end) (cdr ends)))
table)))
(t (goto-char (apply #'max
(mapcar (lambda (x) (plist-get x :start))
- (cl-remove-if-not
+ (seq-filter
(lambda (x) (< (plist-get x :end) pos))
table))))))))
-(cl-defsubst latex-table-wizard--get-thing (thing &optional table)
+(defun latex-table-wizard--get-thing (thing &optional table)
"Return THING point is in.
THING can be either \\='cell\\=', \\='column\\=' or \\='row\\='.
@@ -644,8 +644,8 @@ plists."
(let* ((prop (if (eq thing 'row) :row :column))
(other-prop (if (eq thing 'row) :column :row))
(curr-value (plist-get curr prop)))
- (sort (cl-remove-if-not (lambda (x) (= curr-value (plist-get x prop)))
- cells-list)
+ (sort (seq-filter (lambda (x) (= curr-value (plist-get x prop)))
+ cells-list)
(lambda (x y) (> (plist-get x other-prop)
(plist-get y other-prop))))))))
@@ -689,7 +689,7 @@ If SAME-LINE is non-nil, never leave current column or row."
;;; Swapping functions
-(cl-defsubst latex-table-wizard--swap-substrings (x y)
+(defun latex-table-wizard--swap-substrings (x y)
"Swap two buffer substrings.
X and Y are each a list of the form \\='(B E)\\=', where B and E
@@ -713,14 +713,14 @@ buffer substring."
(insert x-string)
(just-one-space))))
-(cl-defsubst latex-table-wizard--swap-cells (x y)
+(defun latex-table-wizard--swap-cells (x y)
"Evaluate `latex-table-wizard--swap-substrings' on cells X and Y."
(latex-table-wizard--swap-substrings `(,(plist-get x :start)
,(plist-get x :end))
`(,(plist-get y :start)
,(plist-get y :end))))
-(cl-defsubst latex-table-wizard--type-of-selection (sel)
+(defun latex-table-wizard--type-of-selection (sel)
"Return type of list of cells SEL.
Non-nil values that are returned are is either \\='cell\\=' (if
@@ -768,10 +768,10 @@ TYPE is either \\='cell\\=', \\='column\\=' or
\\='row\\='."
(if (eq type 'cell)
(latex-table-wizard--swap-cells current-cell other-cell)
(let* ((current (latex-table-wizard--get-thing type table))
- (other (cl-loop for x in current
- collect
- (latex-table-wizard--get-other-cell
- dir t 1 table x))))
+ (other))
+ (dolist (x current)
+ (push (latex-table-wizard--get-other-cell dir t 1 table x)
+ other))
(latex-table-wizard--swap-line type current other)))
(let ((new-table (latex-table-wizard--parse-table)))
(goto-char (plist-get (latex-table-wizard--get-cell-pos
@@ -837,17 +837,16 @@ delimiters."
(delete-dups)
(apply #'max))))
(save-excursion
- (dolist (x (cl-remove-if-not (lambda (x) (= 0 (plist-get x :column)))
- (latex-table-wizard--parse-table)))
+ (dolist (x (seq-filter (lambda (x) (= 0 (plist-get x :column)))
+ (latex-table-wizard--parse-table)))
(goto-char (plist-get x :start))
(unless (looking-back "^[[:space:]]*" (line-beginning-position))
(insert "\n")))
(latex-table-wizard-clean-whitespace)
(let ((count 0))
(while (<= count max-col)
- (let ((line (cl-remove-if-not (lambda (x) (= count
- (plist-get x :column)))
- (latex-table-wizard--parse-table)))
+ (let ((line (seq-filter (lambda (x) (= count (plist-get x :column)))
+ (latex-table-wizard--parse-table)))
(col-pos '()))
(dolist (cell line)
(goto-char (plist-get cell :end))
@@ -1211,15 +1210,14 @@ Only remove them in current buffer."
(remove-overlays (point-min) (point-max) 'tabl-inside-ol t)
(remove-overlays (point-min) (point-max) 'tabl-outside-ol t)))
-(defsubst latex-table-wizard--get-out ()
+(defun latex-table-wizard--get-out ()
"If point is on column or row delimiter, move to its beginning."
(latex-table-wizard--set-current-values)
(when-let ((macro (latex-table-wizard--point-on-regexp-p
(latex-table-wizard--disjoin
`(,(regexp-opt
- (cl-union
- latex-table-wizard--current-row-delims
- latex-table-wizard--current-col-delims))
+ (append latex-table-wizard--current-row-delims
+ latex-table-wizard--current-col-delims))
,latex-table-wizard--macro-re))
0 (line-beginning-position))))
(thread-last macro
- [elpa] externals/latex-table-wizard f2f2efeed4 50/70: New alignment commands and bug fixes, (continued)
- [elpa] externals/latex-table-wizard f2f2efeed4 50/70: New alignment commands and bug fixes, ELPA Syncer, 2023/05/13
- [elpa] externals/latex-table-wizard c315f144a6 47/70: Add short description file, ELPA Syncer, 2023/05/13
- [elpa] externals/latex-table-wizard bb8c0e04f1 58/70: Two commands to comment out cells added, ELPA Syncer, 2023/05/13
- [elpa] externals/latex-table-wizard c3b1802c1e 29/70: Syntax-quote lists, ELPA Syncer, 2023/05/13
- [elpa] externals/latex-table-wizard 4b5670e397 33/70: Collapse align and compress whitespace commands, ELPA Syncer, 2023/05/13
- [elpa] externals/latex-table-wizard 5d8a8f1ef1 36/70: Add correct info page, ELPA Syncer, 2023/05/13
- [elpa] externals/latex-table-wizard 484145d44a 61/70: Fix hanging parens, ELPA Syncer, 2023/05/13
- [elpa] externals/latex-table-wizard a3509e7572 60/70: Updated documentation, ELPA Syncer, 2023/05/13
- [elpa] externals/latex-table-wizard a8b7ca7fd2 66/70: Fix behavior with math in cells, ELPA Syncer, 2023/05/13
- [elpa] externals/latex-table-wizard 78aaa5b18b 67/70: Fix bug in parsing function, ELPA Syncer, 2023/05/13
- [elpa] externals/latex-table-wizard a3bb0cf5f5 27/70: Replace cl-lib with seq and remove inlines,
ELPA Syncer <=
- [elpa] externals/latex-table-wizard 63dc920fb5 54/70: Add option whether to allow or disallow detached arguments, ELPA Syncer, 2023/05/13
- [elpa] externals/latex-table-wizard b41aac096b 70/70: Change copyright assignment to FSF, ELPA Syncer, 2023/05/13
- [elpa] externals/latex-table-wizard 0252ecd876 21/70: Make latex-table-wizard--selection buffer-local, ELPA Syncer, 2023/05/13
- [elpa] externals/latex-table-wizard 583bf279a3 25/70: Typos fixed and readme expanded, ELPA Syncer, 2023/05/13
- [elpa] externals/latex-table-wizard bb01371e2a 35/70: Bump to version 1.0.0, ELPA Syncer, 2023/05/13
- [elpa] externals/latex-table-wizard f65b6e30e7 37/70: Remove old reference to void variable, ELPA Syncer, 2023/05/13
- [elpa] externals/latex-table-wizard 841bed109e 63/70: Fix bug with vacuous modification of tables, ELPA Syncer, 2023/05/13
- [elpa] externals/latex-table-wizard 80c1d68cf3 68/70: Skip sexp at opening brace, ELPA Syncer, 2023/05/13
- [elpa] externals/latex-table-wizard 7568cbbe11 39/70: Fix for tables with braces in the argument slot of the environment, ELPA Syncer, 2023/05/13
- [elpa] externals/latex-table-wizard e81418a27d 40/70: Add regexp separators, ELPA Syncer, 2023/05/13