Claude helped me find the root cause of this bug.  I have verified and
tested all the code blocks here under ~emacs -Q~.  The content of this
message from "#+COLUMNS" can be run as an org file.

Peter



#+COLUMNS: %item %roman %arabic %id

* description
  ~org-update-all-dblocks~ doesn't properly pick up ~ID~ properties from
folded
  headings when generating ~columnview~ tables, even though the ~ID~'s are
  parsed.  Instead of generating a table with only entries from the heading
with
  the specified ID, all matching property values from the entire file are
  tabulated.  For me, this was unexpected, so if the proposed fix is not
taken,
  documentation should be clearer about the intent.

* proposed fix
  #+begin_src diff
diff --git a/lisp/org-colview.el b/lisp/org-colview.el
index b0ec25129..15c118dd1 100644
--- a/lisp/org-colview.el
+++ b/lisp/org-colview.el
@@ -858,4 +858,4 @@ (defun org-columns-goto-top-level
     org-columns-top-level-marker
     (cond ((org-before-first-heading-p) (point-min))
          ((org-entry-get nil "COLUMNS" t)
org-entry-property-inherited-from)
-         (t (org-back-to-heading) (point))))))
+         (t (org-back-to-heading t) (point))))))

* demo
  Observe what happens to the ~tables~ section when the ~entries~ section
is folded
  and unfolded -- when it is folded, each table contains all entries in the
  file.  When it is not folded, the tables generate as expected.

  #+begin_src elisp :results none
    (org-update-all-dblocks)
  #+end_src

** Options for fixing locally

*** option A: straight elisp
    #+begin_src elisp :results none
      (org-with-wide-buffer
       (org-save-outline-visibility t
           (save-excursion
             (org-show-all)
             (org-update-all-dblocks))))
    #+end_src

*** option B: advice
    This is just to show that changing the call to ~org-back-to-heading~ at
    =org-colview.el:861= would produce the desired result.

    add
    #+begin_src elisp :results none
      (defun force-invisible-ok (orig &optional _invisible-ok)
        (funcall orig t))

      (advice-add 'org-back-to-heading :around #'force-invisible-ok)
    #+end_src

    remove
    #+begin_src elisp :results none
      (advice-remove 'org-back-to-heading #'force-invisible-ok)
    #+end_src

*** option C: redefine function
    #+begin_src elisp :results none
      (defun org-columns-goto-top-level ()
        "Move to the beginning of the column view area.
      Also sets `org-columns-top-level-marker' to the new position."
        (unless (markerp org-columns-top-level-marker)
          (setq org-columns-top-level-marker (make-marker)))
        (goto-char
         (move-marker
          org-columns-top-level-marker
          (cond ((org-before-first-heading-p) (point-min))
                ((org-entry-get nil "COLUMNS" t)
org-entry-property-inherited-from)
                (t (org-back-to-heading t) (point))))))
    #+end_src

** entries

*** small numbers
    :PROPERTIES:
    :ID:       20260806T230500.723592
    :END:
**** one
     :PROPERTIES:
     :roman:    I
     :arabic:   1
     :END:
     The unit.
**** two
     :PROPERTIES:
     :ROMAN:    II
     :ARABIC:   2
     :END:
     The smallest prime.
*** bigger numbers
    :PROPERTIES:
    :ID:       20260806T230507.917825
    :END:
**** three
     :PROPERTIES:
     :ROMAN:    III
     :ARABIC:   3
     :END:
     The smallest odd prime.
**** four
     :PROPERTIES:
     :ROMAN:    IV
     :ARABIC:   4
     :END:
     The smallest composite number.

** tables of numbers from entries
*** small
    #+BEGIN: columnview :hlines 1 :id "20260806T230500.723592"
    #+END:

*** big
    #+BEGIN: columnview :hlines 1 :id "20260806T230507.917825"
    #+END:


* COMMENT version information
Emacs  : GNU Emacs 30.2 (build 2, x86_64-pc-linux-gnu, GTK+ Version
3.24.41, cairo version 1.18.0)
 of 2025-08-16
Package: Org mode version 9.7.11 (release_9.7.11 @
/usr/local/share/emacs/30.2/lisp/org/)

Reply via email to