[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/latex-table-wizard d71174b247 03/70: Alignment commands
|
From: |
ELPA Syncer |
|
Subject: |
[elpa] externals/latex-table-wizard d71174b247 03/70: Alignment commands added |
|
Date: |
Sat, 13 May 2023 08:59:09 -0400 (EDT) |
branch: externals/latex-table-wizard
commit d71174b2475d6235cc66e428ec0410a089e8365d
Author: Enrico Flor <nericoflor@gmail.com>
Commit: Enrico Flor <nericoflor@gmail.com>
Alignment commands added
---
latex-table-wizard.el | 59 +++++++++++++++++++++++++++++++++++++++++++++++---
move-01.gif | Bin 180937 -> 0 bytes
readme.org | 27 ++++++++++++++++-------
select-01.gif | Bin 215650 -> 0 bytes
swap-01.gif | Bin 359257 -> 0 bytes
wizard-01.gif | Bin 0 -> 309942 bytes
6 files changed, 75 insertions(+), 11 deletions(-)
diff --git a/latex-table-wizard.el b/latex-table-wizard.el
index 9ca51ef60e..bb3205a068 100644
--- a/latex-table-wizard.el
+++ b/latex-table-wizard.el
@@ -749,6 +749,54 @@ THING is either 'cell', 'column' or 'row'."
;;; Interactive functions
+;;;###autoload
+(defun latex-table-wizard-clean-whitespace ()
+ "Remove excess whitespace from cell borders."
+ (interactive)
+ (save-excursion
+ (let* ((table (latex-table-wizard--parse-table))
+ (extrs (latex-table-wizard--get-env-ends table)))
+ (whitespace-cleanup-region (car extrs) (cdr extrs))
+ (dolist (x (flatten-list (mapcar (lambda (x) (list (plist-get x :start)
+ (plist-get x :end)))
+ table)))
+ (goto-char x)
+ (just-one-space)))))
+
+;;;###autoload
+(defun latex-table-wizard-align ()
+ "Align and format table at point.
+
+Have every row start on its own line and vertically align column delimiters."
+ (interactive)
+ (let ((max-col (thread-last (latex-table-wizard--parse-table)
+ (mapcar (lambda (x) (plist-get x :column)))
+ (delete-dups)
+ (apply #'max))))
+ (save-excursion
+ (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:]]*")
+ (insert "\n")))
+ (latex-table-wizard-clean-whitespace)
+ (let ((count 0))
+ (while (<= count max-col)
+ (let ((line (cl-remove-if-not (lambda (x) (eq count
+ (plist-get x :column)))
+ (latex-table-wizard--parse-table)))
+ (col-pos '()))
+ (dolist (cell line)
+ (goto-char (plist-get cell :end))
+ (push (current-column) col-pos))
+ (let ((longest (apply #'max col-pos)))
+ (dolist (cell line)
+ (goto-char (plist-get cell :end))
+ (when (< (current-column) longest)
+ (insert (make-string (- longest (current-column))
+ (string-to-char " ")))))))
+ (setq count (1+ count)))))))
+
;;;###autoload
(defun latex-table-wizard-right (&optional n)
"Move point N cells to the right.
@@ -1049,7 +1097,9 @@ at point. If it is none of those object, return nil."
("N" "bottom" latex-table-wizard-bottom :transient t)
""
("a" "beginning of cell" latex-table-wizard-beginning-of-cell :transient t)
- ("e" "end of cell" latex-table-wizard-end-of-cell :transient t)))
+ ("e" "end of cell" latex-table-wizard-end-of-cell :transient t)
+ ""
+ ("u" "universal argument" universal-argument :transient t)))
(defconst latex-table-wizard--mark-suffixes
'(("x" "exchange point and mark" exchange-point-and-mark :transient t)
@@ -1078,11 +1128,14 @@ at point. If it is none of those object, return nil."
("d SPC" "deselect cell" latex-table-wizard-deselect-cell :transient t)
("d c" "select column" latex-table-wizard-deselect-column :transient t)
("d r" "select row" latex-table-wizard-deselect-row :transient t)
+ ""
("s" "swap selection" latex-table-wizard-swap :transient t)))
(defconst latex-table-wizard--other-suffixes
- '(("/" "undo" undo :transient t)
- ("u" "universal argument" universal-argument :transient t)
+ '(("w" "compress table" latex-table-wizard-clean-whitespace :transient t)
+ ("TAB" "align table" latex-table-wizard-align :transient t)
+ ("/" "undo" undo :transient t)
+ ""
("RET" "done" transient-quit-one)))
;;;###autoload
diff --git a/move-01.gif b/move-01.gif
deleted file mode 100644
index 467c5bdb25..0000000000
Binary files a/move-01.gif and /dev/null differ
diff --git a/readme.org b/readme.org
index e5a3c93e94..f8f8c6ecc2 100644
--- a/readme.org
+++ b/readme.org
@@ -19,7 +19,7 @@ Copyright (C) 2022 Enrico Flor.
(a) The FSF’s Back-Cover Text is: “You have the freedom to copy and
modify this GNU manual.”
-* Introduction
+* Overview
One of org-mode's magic features is its table editing capabilities.
The goal of this package is to replicate that luxury for LaTeX
@@ -30,8 +30,6 @@ change all the bindings, and can use all the commands without
the
transient interface, this readme will refer to the commands through
the default bindings as they can be seen in the transient below.
-[[./default-transient.png][Transient interface]]
-
The transient interface is invoked through the ~latex-table-wizard-do~
command, and exited, as usual, with ~C-g~.
@@ -41,11 +39,7 @@ environments contains embedded tables (that is, other tabular
environments inside of its cells). The table is parsed so that these
big cells are treated like any other cell.
-[[./move-01.gif]]
-
-[[./select-01.gif]]
-
-[[./swap-01.gif]]
+[[./wizard-01.gif]]
* Available commands
For now, we will assume a standard LaTeX syntax for tabular
@@ -187,6 +181,23 @@ corresponding portion thereof. If you selected multiple
cell that are
not part of the same column or row, the swap won't happen
(LaTeX-table-wizard doesn't know what to do).
+** Format the table
+
+Two more command fix the appearance of the table. To "compress" the
+table by removing excess white space at the edges of each cell, call
+~latex-table-wizard-clean-whitespace~.
+
+Call ~latex-table-wizard-align~ if you want the columns to be vertically
+aligned too (and each row starting on its own line). This alignment
+command tries to be smart and not be fooled by column or row
+delimiters embedded in a cell.
+
+| Command | Default key |
+|-------------------------------------+-------------|
+| ~latex-table-wizard-clean-whitespace~ | ~w~ |
+| ~latex-table-wizard-align~ | ~TAB~ |
+
+
* Customization
** Change keybindings
To change the default keybindings you give an appropriate value to the
diff --git a/select-01.gif b/select-01.gif
deleted file mode 100644
index 8a1e20c8cb..0000000000
Binary files a/select-01.gif and /dev/null differ
diff --git a/swap-01.gif b/swap-01.gif
deleted file mode 100644
index 2be51568fc..0000000000
Binary files a/swap-01.gif and /dev/null differ
diff --git a/wizard-01.gif b/wizard-01.gif
new file mode 100644
index 0000000000..a69e48f5e1
Binary files /dev/null and b/wizard-01.gif differ
- [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 <=
- [elpa] externals/latex-table-wizard a28e0f0ec5 04/70: Some cleanup, ELPA Syncer, 2023/05/13
- [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