[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/latex-table-wizard a28e0f0ec5 04/70: Some cleanup
From: |
ELPA Syncer |
Subject: |
[elpa] externals/latex-table-wizard a28e0f0ec5 04/70: Some cleanup |
Date: |
Sat, 13 May 2023 08:59:10 -0400 (EDT) |
branch: externals/latex-table-wizard
commit a28e0f0ec54020f169b793bb3cc8591c1c6dac7f
Author: Enrico Flor <nericoflor@gmail.com>
Commit: Enrico Flor <nericoflor@gmail.com>
Some cleanup
---
latex-table-wizard.el | 133 +++++++++++++++++++++++---------------------------
1 file changed, 62 insertions(+), 71 deletions(-)
diff --git a/latex-table-wizard.el b/latex-table-wizard.el
index bb3205a068..5ed62f1691 100644
--- a/latex-table-wizard.el
+++ b/latex-table-wizard.el
@@ -183,10 +183,53 @@ If the current environment is one that is mapped to
something in
If NAME is nil, skip any LaTeX macro that point is looking at."
(let* ((n (or name (rx (one-or-more alnum))))
(macro-re (concat "\\\\" n latex-table-wizard--macro-args-re)))
- (unless (looking-back "[^\\\\]\\\\")
+ (unless (looking-back "[^\\\\]\\\\" (line-beginning-position))
(when (looking-at macro-re)
(match-end 0)))))
+(defsubst latex-table-wizard--disjoin (str-list &optional sep)
+ "Concatenate strings in STR-LIST with separtor SEP.
+
+If SEP is nil, the separator used is \"\\\\|\""
+ (let ((separator (or sep "\\|")))
+ (mapconcat #'identity str-list separator)))
+
+(defsubst latex-table-wizard--skip-stuff (limit)
+ "Skip comments, blank space and hline macros.
+
+Hline macros are LaTeX macros whose name is a string in
+`latex-table-wizard--current-hline-macros'.
+
+Stop the skipping at LIMIT (a buffer position or a marker)."
+ (let ((done)
+ (new-start-of-line))
+ (catch 'stop
+ (while (and (not done) (<= (point) limit))
+ (skip-syntax-forward " ")
+ (let ((temp-pos (point)))
+ (when (looking-at "\n\\|%")
+ (forward-line)
+ (setq new-start-of-line (point))
+ (when (looking-at (concat
+ "[[:space:]]*"
+ (latex-table-wizard--disjoin
+ latex-table-wizard--current-col-delims)))
+ (throw 'stop nil)))
+ (ignore-errors
+ (goto-char (latex-table-wizard--end-of-macro
+ (concat
+ (regexp-opt
+ latex-table-wizard--current-hline-macros)
+ latex-table-wizard--macro-args-re))))
+ (when (looking-at "\n\\|%")
+ (forward-line)
+ (setq new-start-of-line (point)))
+ (when (eq (point) temp-pos)
+ ;; we haven't moved since trying to skip whitespace, we are
+ ;; done here.
+ (setq done t)))))
+ (when new-start-of-line (goto-char new-start-of-line))))
+
(defsubst latex-table-wizard--get-cell-boundaries (col-re
row-re
&optional limit)
@@ -212,7 +255,8 @@ argument."
(end-of-row))
(while (and (< (point) lim) (not end))
(cond ((and (looking-at "%")
- (not (looking-back "[^\\\\]\\\\")))
+ (not (looking-back "[^\\\\]\\\\"
+ (line-beginning-position))))
;; the first step is important to avoid being fooled by
;; column or row delimiters in comments!
(forward-line))
@@ -251,49 +295,6 @@ cell (B . E) with B and E being markers."
(defvar-local latex-table-wizard--parsed-table-delims nil)
-(defsubst latex-table-wizard--disjoin (str-list &optional sep)
- "Concatenate strings in STR-LIST with separtor SEP.
-
-If SEP is nil, the separator used is \"\\\\|\""
- (let ((separator (or sep "\\|")))
- (mapconcat #'identity str-list separator)))
-
-(defsubst latex-table-wizard--skip-stuff (limit)
- "Skip comments, blank space and hline macros.
-
-Hline macros are LaTeX macros whose name is a string in
-`latex-table-wizard--current-hline-macros'.
-
-Stop the skipping at LIMIT (a buffer position or a marker)."
- (let ((done)
- (new-start-of-line))
- (catch 'stop
- (while (and (not done) (<= (point) limit))
- (skip-syntax-forward " ")
- (let ((temp-pos (point)))
- (when (looking-at "\n\\|%")
- (forward-line)
- (setq new-start-of-line (point))
- (when (looking-at (concat
- "[[:space:]]*"
- (latex-table-wizard--disjoin
- latex-table-wizard--current-col-delims)))
- (throw 'stop nil)))
- (ignore-errors
- (goto-char (latex-table-wizard--end-of-macro
- (concat
- (regexp-opt
- latex-table-wizard--current-hline-macros)
- latex-table-wizard--macro-args-re))))
- (when (looking-at "\n\\|%")
- (forward-line)
- (setq new-start-of-line (point)))
- (when (eq (point) temp-pos)
- ;; we haven't moved since trying to skip whitespace, we are
- ;; done here.
- (setq done t)))))
- (when new-start-of-line (goto-char new-start-of-line))))
-
(defun latex-table-wizard--parse-table ()
"Parse table(-like) environment point is in.
@@ -318,8 +319,7 @@ Each value is an integer, S and E are markers."
latex-table-wizard--macro-args-re)
nil t)
(forward-char -1)
- (point-marker)))
- (done))
+ (point-marker))))
(latex-table-wizard--set-current-values)
(save-excursion
(goto-char env-beg)
@@ -332,10 +332,6 @@ Each value is an integer, S and E are markers."
latex-table-wizard--current-col-delims))
(row-re (latex-table-wizard--disjoin
latex-table-wizard--current-row-delims))
- (hline-macro-re (concat
- (regexp-opt
- latex-table-wizard--current-hline-macros)
- latex-table-wizard--macro-args-re))
(data (latex-table-wizard--get-cell-boundaries
col-re row-re env-end)))
(push `( :column ,col
@@ -523,6 +519,9 @@ The overlay has a non-nil value for the name property
`((t (:background ,(face-attribute 'region
:background))))))))
+(defvar latex-table-wizard--selection nil
+ "Current selection, a list of cell objects.")
+
(defun latex-table-wizard--jump (dir &optional absolute count same-line)
"Move point to the beginning of a cell in the table.
@@ -603,7 +602,7 @@ plists."
(sort (cl-remove-if-not (lambda (x) (eq curr-value (plist-get x prop)))
cells-list)
(lambda (x y) (> (plist-get x other-prop)
- (plist-get x other-prop))))))))
+ (plist-get y other-prop))))))))
@@ -717,9 +716,6 @@ TYPE is either 'cell', 'column' or 'row'."
(latex-table-wizard--hl-cells
(latex-table-wizard--get-thing type new-table))))))
-(defvar latex-table-wizard--selection nil
- "Current selection, a list of cell objects.")
-
(defun latex-table-wizard--select-thing (thing)
"Add THING point is at to list `latex-table-wizard--selection'.
@@ -777,7 +773,7 @@ Have every row start on its own line and vertically align
column delimiters."
(dolist (x (cl-remove-if-not (lambda (x) (eq 0 (plist-get x :column)))
(latex-table-wizard--parse-table)))
(goto-char (plist-get x :start))
- (unless (looking-back "^[[:space:]]*")
+ (unless (looking-back "^[[:space:]]*" (line-beginning-position))
(insert "\n")))
(latex-table-wizard-clean-whitespace)
(let ((count 0))
@@ -894,8 +890,8 @@ of the column to the left of where point is."
TABLE is a list of cell plists. If it is nil, evaluate
`latex-table-wizard--parse-table' to get a value."
(interactive)
- (let* ((cells-list (or table (latex-table-wizard--parse-table)))
- (cell (latex-table-wizard--get-thing 'cell cells-list)))
+ (let* ((table (latex-table-wizard--parse-table))
+ (cell (latex-table-wizard--get-thing 'cell table)))
(push-mark (plist-get cell :start) nil t)
(goto-char (plist-get cell :end))))
@@ -953,7 +949,6 @@ TABLE is a list of cell plists. If it is nil, evaluate
(interactive)
(save-excursion
(let* ((table (latex-table-wizard--parse-table))
- (current-cell (latex-table-wizard--get-thing 'cell table))
(current-column (latex-table-wizard--get-thing 'column table)))
(dolist (x current-column)
(goto-char (plist-get x :end))
@@ -965,7 +960,6 @@ TABLE is a list of cell plists. If it is nil, evaluate
(interactive)
(save-excursion
(let* ((table (latex-table-wizard--parse-table))
- (current-cell (latex-table-wizard--get-thing 'cell table))
(current-column (latex-table-wizard--get-thing 'column table))
(kills '()))
(dolist (x current-column)
@@ -975,8 +969,8 @@ TABLE is a list of cell plists. If it is nil, evaluate
(e (plist-get next :start)))
(push (buffer-substring b e) kills)
(delete-region b e)))
- (kill-region (latex-table-wizard--disjoin
- (nreverse kills) "\n")))))
+ (kill-new (latex-table-wizard--disjoin
+ (nreverse kills) "\n")))))
;;;###autoload
(defun latex-table-wizard-insert-row ()
@@ -1005,11 +999,9 @@ TABLE is a list of cell plists. If it is nil, evaluate
(interactive)
(save-excursion
(let* ((table (latex-table-wizard--parse-table))
- (current-cell (latex-table-wizard--get-thing 'cell table))
- (current-row (latex-table-wizard--get-thing 'row table)))
- (thread-last (latex-table-wizard--get-env-ends current-row)
- (apply #'buffer-substring)
- (kill-region)))))
+ (b-e (latex-table-wizard--get-env-ends
+ (latex-table-wizard--get-thing 'row table))))
+ (kill-region (car b-e) (cdr b-e)))))
;;;###autoload
(defun latex-table-wizard-select-cell ()
@@ -1034,7 +1026,8 @@ TABLE is a list of cell plists. If it is nil, evaluate
(interactive)
(let* ((table (latex-table-wizard--parse-table))
(curr-cell (latex-table-wizard--get-thing 'cell table)))
- (when (member curr-cell latex-table-wizard--selection))
+ (setq latex-table-wizard--selection
+ (remove curr-cell latex-table-wizard--selection))
(latex-table-wizard--remove-overlays nil
(plist-get curr-cell :start)
(plist-get curr-cell :end))
@@ -1067,9 +1060,7 @@ at point. If it is none of those object, return nil."
(let* ((table (latex-table-wizard--parse-table))
(other latex-table-wizard--selection)
(type (latex-table-wizard--type-of-selection other))
- (current (latex-table-wizard--get-thing type table))
- (land-coord (cons (plist-get current :column)
- (plist-get current :row))))
+ (current (latex-table-wizard--get-thing type table)))
(cond ((not type)
(latex-table-wizard--cleanup)
(setq latex-table-wizard--selection nil))
- [elpa] branch externals/latex-table-wizard created (now b41aac096b), ELPA Syncer, 2023/05/13
- [elpa] externals/latex-table-wizard e738b1c094 02/70: Remove comments, ELPA Syncer, 2023/05/13
- [elpa] externals/latex-table-wizard 7137ca9641 01/70: First commit, ELPA Syncer, 2023/05/13
- [elpa] externals/latex-table-wizard d71174b247 03/70: Alignment commands added, ELPA Syncer, 2023/05/13
- [elpa] externals/latex-table-wizard a28e0f0ec5 04/70: Some cleanup,
ELPA Syncer <=
- [elpa] externals/latex-table-wizard 06d0453f60 10/70: Version bump to 0.0.3, ELPA Syncer, 2023/05/13
- [elpa] externals/latex-table-wizard f9394894f7 05/70: Fix parsing if 0, 0 cell starts in same line as \begin macro, ELPA Syncer, 2023/05/13
- [elpa] externals/latex-table-wizard 29c65891e6 07/70: Fix transient autoload and remove transient change function, ELPA Syncer, 2023/05/13
- [elpa] externals/latex-table-wizard 174739aad8 06/70: Fix byte-compilations warnings about docstrings, ELPA Syncer, 2023/05/13
- [elpa] externals/latex-table-wizard 8402bc0ed9 12/70: Don't call face -face (as per elisp manual ch 40), ELPA Syncer, 2023/05/13
- [elpa] externals/latex-table-wizard 972e8eeba1 16/70: Optimize for compilation and simplify, ELPA Syncer, 2023/05/13
- [elpa] externals/latex-table-wizard c75063522b 17/70: Extend overlay limit to beginning of \end{} macro, ELPA Syncer, 2023/05/13
- [elpa] externals/latex-table-wizard 293bbfc9ed 18/70: Actually remove function definition made useless, ELPA Syncer, 2023/05/13
- [elpa] externals/latex-table-wizard 7ac03c0a51 26/70: Correct readme, ELPA Syncer, 2023/05/13
- [elpa] externals/latex-table-wizard a53d3f6158 30/70: Version 0.2.0, ELPA Syncer, 2023/05/13