emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/markdown-mode 3713b4d 2/2: Merge pull request #626 from jr


From: ELPA Syncer
Subject: [nongnu] elpa/markdown-mode 3713b4d 2/2: Merge pull request #626 from jrblevin/issue-625
Date: Wed, 21 Jul 2021 21:57:22 -0400 (EDT)

branch: elpa/markdown-mode
commit 3713b4deb54caa496d0202169584e1c3802b3b3a
Merge: 359347b 619704e
Author: Shohei YOSHIDA <syohex@gmail.com>
Commit: GitHub <noreply@github.com>

    Merge pull request #626 from jrblevin/issue-625
    
    Add table alignment flag
---
 CHANGES.md             |  3 +++
 markdown-mode.el       | 31 +++++++++++++++++++++++--------
 tests/markdown-test.el | 18 ++++++++++++++++++
 3 files changed, 44 insertions(+), 8 deletions(-)

diff --git a/CHANGES.md b/CHANGES.md
index c40210f..890ae1b 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -13,6 +13,8 @@
     -   Introduce `markdown-ordered-list-enumeration` variable [GH-587][]
     -   Search wiki link under project
     -   Add `markdown-insert-foldable-block` function [GH-598][]
+    -   Add `markdown-table-align-p` flag [GH-625][]
+        Control table alignment after table operation
 
 *   Improvements:
     -   Correct indirect buffer's indentation in `markdown-edit-code-block` 
[GH-375][]
@@ -72,6 +74,7 @@
   [gh-590]: https://github.com/jrblevin/markdown-mode/pull/590
   [gh-598]: https://github.com/jrblevin/markdown-mode/pull/598
   [gh-613]: https://github.com/jrblevin/markdown-mode/issues/613
+  [gh-625]: https://github.com/jrblevin/markdown-mode/issues/625
 
 # Markdown Mode 2.4
 
diff --git a/markdown-mode.el b/markdown-mode.el
index 18465a1..c5e4b17 100644
--- a/markdown-mode.el
+++ b/markdown-mode.el
@@ -621,6 +621,13 @@ This variable must be set before loading markdown-mode."
   :safe 'booleanp
   :package-version '(markdown-mode . "2.5"))
 
+(defcustom markdown-table-align-p t
+  "Non-nil means that table is aligned after table operation."
+  :group 'markdown
+  :type 'bool
+  :safe 'booleanp
+  :package-version '(markdown-mode . "2.5"))
+
 
 ;;; Markdown-Specific `rx' Macro ==============================================
 
@@ -9204,7 +9211,8 @@ With optional argument UP, move it up."
          (insert "|   "))
        (forward-line)))
     (set-marker end nil)
-    (markdown-table-align)))
+    (when markdown-table-align-p
+      (markdown-table-align))))
 
 (defun markdown-table-delete-column ()
   "Delete column at point from table."
@@ -9223,7 +9231,8 @@ With optional argument UP, move it up."
        (forward-line)))
     (set-marker end nil)
     (markdown-table-goto-column (max 1 (1- col)))
-    (markdown-table-align)))
+    (when markdown-table-align-p
+      (markdown-table-align))))
 
 (defun markdown-table-move-column (&optional left)
   "Move table column at point to the right.
@@ -9249,7 +9258,8 @@ With optional argument LEFT, move it to the left."
        (forward-line)))
     (set-marker end nil)
     (markdown-table-goto-column colpos)
-    (markdown-table-align)))
+    (when markdown-table-align-p
+      (markdown-table-align))))
 
 (defun markdown-table-move-column-left ()
   "Move table column at point to the left."
@@ -9270,7 +9280,8 @@ Create new table lines if required."
   (if (or (looking-at "[ \t]*$")
           (save-excursion (skip-chars-backward " \t") (bolp)))
       (newline)
-    (markdown-table-align)
+    (when markdown-table-align-p
+      (markdown-table-align))
     (let ((col (markdown-table-get-column)))
       (beginning-of-line 2)
       (if (or (not (markdown-table-at-point-p))
@@ -9288,7 +9299,8 @@ Create new table lines if required."
   (interactive)
   (unless (markdown-table-at-point-p)
     (user-error "Not at a table"))
-  (markdown-table-align)
+  (when markdown-table-align-p
+    (markdown-table-align))
   (let ((end (markdown-table-end)))
     (when (markdown-table-hline-at-point-p) (end-of-line 1))
     (condition-case nil
@@ -9311,7 +9323,8 @@ Create new table lines if required."
   (interactive)
   (unless (markdown-table-at-point-p)
     (user-error "Not at a table"))
-  (markdown-table-align)
+  (when markdown-table-align-p
+    (markdown-table-align))
   (when (markdown-table-hline-at-point-p) (beginning-of-line 1))
   (condition-case nil
       (progn
@@ -9367,7 +9380,8 @@ Horizontal separator lines will be eliminated."
                contents "")))
     (markdown-table-goto-dline col_old)
     (markdown-table-goto-column dline_old))
-  (markdown-table-align))
+  (when markdown-table-align-p
+    (markdown-table-align)))
 
 (defun markdown-table-sort-lines (&optional sorting-type)
   "Sort table lines according to the column at point.
@@ -9506,7 +9520,8 @@ spaces, or alternatively a TAB should be used as the 
separator."
              (t (error "Invalid cell separator"))))
       (while (re-search-forward re end t) (replace-match "| " t t)))
     (goto-char begin)
-    (markdown-table-align)))
+    (when markdown-table-align-p
+      (markdown-table-align))))
 
 (defun markdown-insert-table (&optional rows columns align)
   "Insert an empty pipe table.
diff --git a/tests/markdown-test.el b/tests/markdown-test.el
index a597d76..8416f88 100644
--- a/tests/markdown-test.el
+++ b/tests/markdown-test.el
@@ -6933,6 +6933,24 @@ title: asdasdasd
 | aaa | bbbb | ccccc | dddddd |
 "))))
 
+(ert-deftest test-markdown-table/disable-table-align ()
+  "Test table navigation."
+  (let ((input "| 12345 | 6 |
+| 7 | 8 |"))
+    (markdown-test-string input
+      (save-excursion
+        (search-forward "1")
+        (let ((markdown-table-align-p nil))
+          (markdown-table-forward-cell)
+          (should (string= (buffer-string) input))))
+
+      (search-forward "1")
+      (let ((expected "| 12345 | 6 |
+| 7     | 8 |
+"))
+        (markdown-table-forward-cell)
+        (should (string= (buffer-string) expected))))))
+
 (provide 'markdown-test)
 
 ;;; markdown-test.el ends here



reply via email to

[Prev in Thread] Current Thread [Next in Thread]