diff --git a/ChangeLog b/ChangeLog index 1c3d8c34..bb89895f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2026-05-16 Bob Weiner + +* kotl/kotl-mode.el (kotl-mode:split-cell): Fix to ensure point within a + valid cell position and fix to not modify label-separator and leave + a stray character in the original cell when splitting at the first + character of that cell, i.e. all contents move to the second cell. + test/kotl-mode-tests.el (kotl-mode-split-cell): Add test of split on + first character. + 2026-05-16 Mats Lidell * hload-path.el (hload-path--make-directory-autoloads-in-sync-subprocess): diff --git a/kotl/kotl-mode.el b/kotl/kotl-mode.el index 391d32bd..8c363eb6 100644 --- a/kotl/kotl-mode.el +++ b/kotl/kotl-mode.el @@ -3,7 +3,7 @@ ;; Author: Bob Weiner ;; ;; Orig-Date: 6/30/93 -;; Last-Mod: 11-May-26 at 12:50:49 by Bob Weiner +;; Last-Mod: 16-May-26 at 11:55:50 by Bob Weiner ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -3054,9 +3054,12 @@ With optional universal ARG, {\\`C-u'}, the new cell is added as the child of the current cell. Non-read-only attributes from the current cell are replicated in the new cell." (interactive "*P") - ;; delete any surrounding whitespace - (delete-horizontal-space) - (delete-region (point) (progn (skip-chars-backward "\n\r\t ") (point))) + (kotl-mode:to-valid-position) + (kcell-view:operate + (lambda () + ;; delete any surrounding whitespace + (delete-horizontal-space) + (delete-region (point) (progn (skip-chars-backward "\n\r\t ") (point))))) (let ((new-cell-contents (kotl-mode:kill-region (point) (kcell-view:end-contents) 'string)) (start (kcell-view:start)) diff --git a/test/kotl-mode-tests.el b/test/kotl-mode-tests.el index 9aa74742..a6c7abef 100644 --- a/test/kotl-mode-tests.el +++ b/test/kotl-mode-tests.el @@ -3,7 +3,7 @@ ;; Author: Mats Lidell ;; ;; Orig-Date: 18-May-21 at 22:14:10 -;; Last-Mod: 12-Apr-26 at 15:11:30 by Bob Weiner +;; Last-Mod: 16-May-26 at 12:04:54 by Bob Weiner ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -491,7 +491,18 @@ (kotl-mode:previous-line 1) (kotl-mode:end-of-line) (kotl-mode:split-cell) - (should (= (line-number-at-pos) 3)))) + (should (= (line-number-at-pos) 3))) + (ert-info ("Split on first char in cell") + (kotl-mode:kill-tree 0) + (insert "first") + (kotl-mode:beginning-of-line) + (kotl-mode:split-cell) + (should (= (line-number-at-pos) 3)) + (should (string= (kcell-view:contents) "first")) + (kotl-mode:previous-cell 1) + (should (string= (kcell-view:contents) "")) + (should (string= " 1. " (buffer-substring-no-properties + (line-beginning-position) (point)))))) (hy-delete-file-and-buffer kotl-file)))) (ert-deftest kotl-mode-append-cell ()