Skip to content

Commit ea60ab5

Browse files
authored
Merge pull request #937 from rswgnu/rsw
kotl-mode:split-cell - Fix to remove any whitespace at the split loc
2 parents 38ca3c0 + 28442e8 commit ea60ab5

File tree

3 files changed

+22
-13
lines changed

3 files changed

+22
-13
lines changed

ChangeLog

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
2026-04-12 Bob Weiner <rsw@gnu.org>
22

3+
* kotl/kotl-mode.el (kotl-mode:split-cell): Fix extra blank line(s)
4+
remaining after split a cell. Now removes all whitespace, including
5+
newlines around the point where the split occurs.
6+
test/kotl-mode-tests.el (kotl-mode-split-cell): Above fixes this test
7+
so remove ':expected-result :failed'.
8+
39
* hyrolo.el (hyrolo-hdr-move-after-p): Fix infinite loop where did not
410
check that (forward-line 1) actually moved, so just kept looping.
511
Now it checks that the return value is zero. This fixes the test:

kotl/kotl-mode.el

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
;; Author: Bob Weiner
44
;;
55
;; Orig-Date: 6/30/93
6-
;; Last-Mod: 11-Apr-26 at 19:38:12 by Bob Weiner
6+
;; Last-Mod: 12-Apr-26 at 11:24:21 by Bob Weiner
77
;;
88
;; SPDX-License-Identifier: GPL-3.0-or-later
99
;;
@@ -3035,6 +3035,7 @@ replicated in the new cell."
30353035
(interactive "*P")
30363036
;; delete any surrounding whitespace
30373037
(delete-horizontal-space)
3038+
(delete-region (point) (progn (skip-chars-backward "\n\r\t ") (point)))
30383039
(let ((new-cell-contents (kotl-mode:kill-region
30393040
(point) (kcell-view:end-contents) 'string))
30403041
(start (kcell-view:start))

test/kotl-mode-tests.el

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
;; Author: Mats Lidell <matsl@gnu.org>
44
;;
55
;; Orig-Date: 18-May-21 at 22:14:10
6-
;; Last-Mod: 20-Jan-26 at 00:21:25 by Mats Lidell
6+
;; Last-Mod: 12-Apr-26 at 11:24:18 by Bob Weiner
77
;;
88
;; SPDX-License-Identifier: GPL-3.0-or-later
99
;;
@@ -461,13 +461,23 @@
461461

462462
(ert-deftest kotl-mode-split-cell ()
463463
"Kotl-mode split cell."
464-
:expected-result :failed
465464
(let ((kotl-file (make-temp-file "hypb" nil ".kotl")))
466465
(unwind-protect
467466
(with-current-buffer (find-file kotl-file)
467+
(ert-info ("Split before second line; remove all whitespace at split")
468+
(insert "first \t")
469+
(kotl-mode:newline 1)
470+
(insert " \tsecond")
471+
(kotl-mode:beginning-of-line)
472+
(kotl-mode:split-cell)
473+
(should (= (line-number-at-pos) 3))
474+
(should (string= (kcell-view:contents) "second"))
475+
(kotl-mode:previous-cell 1)
476+
(should (string= (kcell-view:contents) "first")))
468477
(ert-info ("Split on first line")
469-
(insert "firstsecond\n")
470-
(backward-char 7)
478+
(kotl-mode:kill-tree 0)
479+
(insert "firstsecond")
480+
(backward-char 6)
471481
(kotl-mode:split-cell)
472482
(should (string= (kcell-view:label (point)) "2"))
473483
(kotl-mode:demote-tree 0)
@@ -481,14 +491,6 @@
481491
(kotl-mode:previous-line 1)
482492
(kotl-mode:end-of-line)
483493
(kotl-mode:split-cell)
484-
(should (= (line-number-at-pos) 3)))
485-
(ert-info ("Split before second line")
486-
(kotl-mode:kill-tree 0)
487-
(insert "first")
488-
(kotl-mode:newline 1)
489-
(insert "second")
490-
(kotl-mode:beginning-of-line)
491-
(kotl-mode:split-cell)
492494
(should (= (line-number-at-pos) 3))))
493495
(hy-delete-file-and-buffer kotl-file))))
494496

0 commit comments

Comments
 (0)