Hi everyone,
This patch adds tests coverage for the user-visible behavior of
`org-columns-quit'.
The two new tests cover:
- quit-leaves-buffer-editable: the buffer accepts edits after
`org-columns-quit' — the `read-only' protection is gone.
- quit-does-not-modify-buffer: entering and exiting column view
does not leave the buffer marked as modified, even though the
teardown internally manipulates text properties.
Both tests assert user-visible behavior rather than implementation
details, so they should remain valid across future refactoring of
the column view teardown path.
Best,
--
Slawomir Grochowski
>From cf7efa1702289ee5d5a87c45349ff35d9299e736 Mon Sep 17 00:00:00 2001
From: Slawomir Grochowski <[email protected]>
Date: Tue, 5 May 2026 09:31:20 +0200
Subject: [PATCH] test-org-colview: Add coverage for org-columns-quit teardown
* testing/lisp/test-org-colview.el
(test-org-colview/quit-leaves-buffer-editable): New test verifying that
the buffer accepts edits as normal after `org-columns-quit'.
(test-org-colview/quit-does-not-modify-buffer): New test verifying that
entering and exiting column view does not leave the buffer marked as
modified.
---
testing/lisp/test-org-colview.el | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/testing/lisp/test-org-colview.el b/testing/lisp/test-org-colview.el
index bbf14d0d4..b173fd2e3 100644
--- a/testing/lisp/test-org-colview.el
+++ b/testing/lisp/test-org-colview.el
@@ -1823,5 +1823,32 @@ there are 4 parameters
(org-columns)
(get-char-property (point) 'org-columns-value))))))
+(ert-deftest test-org-colview/quit-leaves-buffer-editable ()
+ "Test that the buffer is editable again after exiting column view.
+Column view restricts editing of the buffer text it covers to prevent
+accidental edits while column view is active. After `org-columns-quit'
+the buffer must accept edits as normal."
+ (should
+ (org-test-with-temp-text "* H"
+ (let ((org-columns-default-format "%ITEM")) (org-columns))
+ (org-columns-quit)
+ ;; Insert inside the heading text would error with `text-read-only'
+ ;; if column view's protection were still active.
+ (goto-char 2)
+ (insert "X")
+ (string= "*X H" (buffer-string)))))
+
+(ert-deftest test-org-colview/quit-does-not-modify-buffer ()
+ "Test that exiting column view does not leave the buffer marked as modified.
+Column view is a read-only display layered over the buffer. It does not
+change buffer content, so entering and exiting it must not be visible as
+a buffer modification. Exiting must leave the modified flag clean."
+ (should-not
+ (org-test-with-temp-text "* H"
+ (set-buffer-modified-p nil)
+ (let ((org-columns-default-format "%ITEM")) (org-columns))
+ (org-columns-quit)
+ (buffer-modified-p))))
+
(provide 'test-org-colview)
;;; test-org-colview.el ends here
--
2.39.5