Ihor Radchenko <[email protected]> writes: > Right. That's tricky. > Maybe we need to re-design the whole idea with read-only in column > views. I am not sure, but tentatively, it may be possible to re-purpose > `org-fold-check-before-invisible-edit' to check for 'display property in > addition to 'invisible. Then, we might be able to reuse the existing > machinery there.
I tried your suggestion with `org-fold-check-before-invisible-edit' but did not get it to work properly. I think the read-only text property in column view is actually fine. Editing properties from column view already works via org-set-property' / org-entry-put', because org-entry-put' wraps its buffer-modifying body in `org-no-read-only'. The same pattern can apply to log notes. The attached patch wraps the buffer-modifying sections of `org-store-log-note' and `org-log-beginning' in `org-no-read-only', mirroring `org-entry-put'. Two notes on the patch shape — both deliberate, to keep review easy: - The diff in lisp/org.el' is 6/4 lines. I did not re-indent the wrapped bodies after adding the outer org-no-read-only', so the inner forms sit one column to the left of their canonical position. Re-indenting would have produced ~130 changed lines for no semantic gain; leaving it as-is keeps the change reviewable as "just add a wrap". Happy to follow up with a whitespace-only re-indent commit if you prefer the canonical form. - The inner (let ((inhibit-read-only t)) (insert-and-inherit "\n"))' inside org-store-log-note' is now redundant -- the outer `org-no-read-only' already binds it. I left it in place intentionally for the same minimal-diff reason; behavior is identical. Happy to remove it in a follow-up. The patch also includes a regression test (test-org-colview/log-note-with-read-only') that exercises both wraps on a column-view buffer. Without the fix it fails with (text-read-only "Type 'e' to edit property")' -- the exact error from the original report. Fixes the original report: 1. Enter column view on a heading without any text under it. 2. M-x org-add-note' (or C-c C-z'), type the note, `C-c C-c'. 3. Previously: "Text is read-only". With the patch: note inserted. Best, -- Slawomir Grochowski
>From 109ce7a6984052c5e063c2aef96fba338aae609c Mon Sep 17 00:00:00 2001 From: Slawomir Grochowski <[email protected]> Date: Wed, 20 May 2026 22:26:28 +0200 Subject: [PATCH] org-store-log-note, org-log-beginning: Inhibit read-only * lisp/org.el (org-store-log-note): Wrap the buffer-modification section in `org-no-read-only' so log notes can be inserted when the target buffer has read-only text properties (e.g., during column view). (org-log-beginning): Wrap the drawer-creation section in `org-no-read-only' for the same reason. * testing/lisp/test-org-colview.el (test-org-colview/log-note-with-read-only): New regression test: `org-log-beginning' and `org-store-log-note' must succeed in a column-view buffer where the heading carries a `read-only' text property. This mirrors the existing pattern in `org-entry-put', which already uses `org-no-read-only'. That is why editing properties from column view works while `org-add-note' previously failed with "Text is read-only". --- lisp/org.el | 10 +++++---- testing/lisp/test-org-colview.el | 38 ++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 4 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index cb36497f4..ee59ddcc2 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -10973,7 +10973,8 @@ narrowing." ;; fold, thus breaking the fold continuity. (unless (eobp) (when (org-at-heading-p) (backward-char))) - (org-fold-core-ignore-modifications + (org-no-read-only + (org-fold-core-ignore-modifications (let (;; Heading ;; <point> ;; Text @@ -11006,7 +11007,7 @@ narrowing." (insert "\n") (backward-char))) (org-indent-region beg (point)) - (org-fold-region cbeg (point) t 'drawer))))) + (org-fold-region cbeg (point) t 'drawer)))))) (end-of-line 0)))) (t (org-end-of-meta-data org-log-state-notes-insert-after-drawers) @@ -11153,7 +11154,8 @@ items are State notes." (push note lines)) (when (and lines (not org-note-abort)) (with-current-buffer (marker-buffer org-log-note-marker) - (org-fold-core-ignore-modifications + (org-no-read-only + (org-fold-core-ignore-modifications (org-with-wide-buffer ;; Find location for the new note. (goto-char org-log-note-marker) @@ -11183,7 +11185,7 @@ items are State notes." (insert-and-inherit line)))) (run-hooks 'org-after-note-stored-hook) (message "Note stored") - (org-back-to-heading t)))))) + (org-back-to-heading t))))))) ;; Don't add undo information when called from `org-agenda-todo'. (set-window-configuration org-log-note-window-configuration) (with-current-buffer (marker-buffer org-log-note-return-to) diff --git a/testing/lisp/test-org-colview.el b/testing/lisp/test-org-colview.el index bbf14d0d4..6c415c915 100644 --- a/testing/lisp/test-org-colview.el +++ b/testing/lisp/test-org-colview.el @@ -1823,5 +1823,43 @@ there are 4 parameters (org-columns) (get-char-property (point) 'org-columns-value)))))) +(ert-deftest test-org-colview/log-note-with-read-only () + "Test that log notes can be inserted while column view is active. +Column view puts a `read-only' text property on the newline after +each overlaid heading. `org-log-beginning' (drawer creation) and +`org-store-log-note' (note insertion) must inhibit read-only so +that `org-add-note' works in column view." + ;; `org-log-beginning' creates a LOGBOOK drawer despite the + ;; `read-only' text property installed by `org-columns'. + (should + (string-match-p + ":LOGBOOK:\n:END:" + (org-test-with-temp-text "* H\nSome text.\n" + (let ((org-columns-default-format "%ITEM") + (org-log-into-drawer t)) + (org-columns) + (org-back-to-heading) + (org-log-beginning t) + (buffer-substring-no-properties (point-min) (point-max)))))) + ;; `org-store-log-note' inserts the staged note end-to-end. + (should + (string-match-p + "^:LOGBOOK:\n- Note taken .*\\\\\\\\\n test note line\n:END:$" + (org-test-with-temp-text "* H\nSome text.\n" + (let ((org-columns-default-format "%ITEM") + (org-log-into-drawer t) + (org-log-note-purpose 'note) + (org-log-note-marker (point-marker)) + (org-log-note-window-configuration (current-window-configuration)) + (org-log-note-return-to (point-marker)) + (org-note-abort nil)) + (org-columns) + (with-current-buffer (get-buffer-create "*Org Note*") + (erase-buffer) + (insert "test note line")) + (with-current-buffer "*Org Note*" + (org-store-log-note))) + (buffer-substring-no-properties (point-min) (point-max)))))) + (provide 'test-org-colview) ;;; test-org-colview.el ends here -- 2.39.5
