Skip to content

Commit d18a8f8

Browse files
committed
Fix table insertion to agree with tests
Additional minor changes: - Indicate the default case in the alignment prompt. - Advance point to a location suitable to begin text entry in table. - Check location of point in tests.
1 parent 02d68d7 commit d18a8f8

File tree

2 files changed

+11
-20
lines changed

2 files changed

+11
-20
lines changed

markdown-mode.el

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9358,7 +9358,7 @@ rows and columns and the column alignment."
93589358
(interactive)
93599359
(let* ((rows (or rows (string-to-number (read-string "Row size: "))))
93609360
(columns (or columns (string-to-number (read-string "Column size: "))))
9361-
(align (or align (read-string "Alignment ([l]eft, [r]ight, [c]enter): ")))
9361+
(align (or align (read-string "Alignment ([l]eft, [r]ight, [c]enter, or RET for default): ")))
93629362
(align (cond ((equal align "l") ":--")
93639363
((equal align "r") "--:")
93649364
((equal align "c") ":-:")
@@ -9367,7 +9367,7 @@ rows and columns and the column alignment."
93679367
(indent (make-string (current-column) ?\ ))
93689368
(line (concat
93699369
(apply 'concat indent "|"
9370-
(make-list columns " |")) "\n"))
9370+
(make-list columns " |")) "\n"))
93719371
(hline (apply 'concat indent "|"
93729372
(make-list columns (concat align "|")))))
93739373
(if (string-match
@@ -9380,7 +9380,7 @@ rows and columns and the column alignment."
93809380
(if (> rows 1)
93819381
(progn
93829382
(end-of-line 1) (insert (concat "\n" hline)) (goto-char pos)))
9383-
(markdown-table-align)))
9383+
(markdown-table-forward-cell)))
93849384

93859385

93869386
;;; ElDoc Support

tests/markdown-test.el

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5475,7 +5475,8 @@ See GH-288."
54755475
|:--|:--|
54765476
| | |
54775477
| | |
5478-
"))))
5478+
"))
5479+
(should (= (point) 3))))
54795480

54805481
(ert-deftest test-markdown-insertion/create-table-with-right-align ()
54815482
"Insert table with right column alignment."
@@ -5486,7 +5487,8 @@ See GH-288."
54865487
|--:|--:|
54875488
| | |
54885489
| | |
5489-
"))))
5490+
"))
5491+
(should (= (point) 3))))
54905492

54915493
(ert-deftest test-markdown-insertion/create-table-with-center-align ()
54925494
"Insert table with center column alignment."
@@ -5497,7 +5499,8 @@ See GH-288."
54975499
|:-:|:-:|
54985500
| | |
54995501
| | |
5500-
"))))
5502+
"))
5503+
(should (= (point) 3))))
55015504

55025505
(ert-deftest test-markdown-insertion/create-table-with-default-align ()
55035506
"Insert table with default column alignment."
@@ -5508,20 +5511,8 @@ See GH-288."
55085511
|---|---|
55095512
| | |
55105513
| | |
5511-
"))))
5512-
5513-
;;; Create table with center column alignment
5514-
5515-
(ert-deftest test-markdown-insertion/create-table-with-center-align ()
5516-
"Insert table with center align."
5517-
(markdown-test-string ""
5518-
(execute-kbd-macro (read-kbd-macro "M-x markdown-insert-table RET 2 RET 3 RET c RET"))
5519-
(should (string-equal (buffer-string) "| | |
5520-
|---|---|
5521-
| | |
5522-
| | |
5523-
"))))
5524-
5514+
"))
5515+
(should (= (point) 3))))
55255516

55265517
;;; gfm-mode tests:
55275518

0 commit comments

Comments
 (0)