* lisp/org.el (org-at-heading-p): Use second argument to allow
checking for visible headings. Note that by default, unlike
`outline-on-heading-p', `org-at-heading-p' returns non-nil for
invisible headings. Passing second argument is just like
`(outline-on-heading-p)'.
(org-indent-line):
* lisp/org-agenda.el (org-agenda-add-entry-to-org-agenda-diary-file):
* lisp/org-colview.el (org-columns--call):
(org-columns-store-format): Update arguments in `org-at-heading-p'
calls.
---
lisp/org-agenda.el | 2 +-
lisp/org-colview.el | 4 ++--
lisp/org.el | 14 +++++++++-----
3 files changed, 12 insertions(+), 8 deletions(-)
diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index 72292fb4e..cc7cb5527 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -10526,7 +10526,7 @@ (defun org-agenda-add-entry-to-org-agenda-diary-file (type text &optional d1 d2)
(anniversary
(or (re-search-forward "^\\*[ \t]+Anniversaries" nil t)
(progn
- (or (org-at-heading-p t)
+ (or (org-at-heading-p)
(progn
(outline-next-heading)
(insert "* Anniversaries\n\n")
diff --git a/lisp/org-colview.el b/lisp/org-colview.el
index 082d6def0..15cab35f0 100644
--- a/lisp/org-colview.el
+++ b/lisp/org-colview.el
@@ -699,7 +699,7 @@ (defun org-columns--call (fun)
(let ((hide-body (and (/= (line-end-position) (point-max))
(save-excursion
(move-beginning-of-line 2)
- (org-at-heading-p t)))))
+ (org-at-heading-p)))))
(unwind-protect (funcall fun)
(when hide-body (outline-hide-entry)))))
@@ -1026,7 +1026,7 @@ (defun org-columns-store-format ()
;; No COLUMNS keyword in the buffer. Insert one at the
;; beginning, right before the first heading, if any.
(goto-char (point-min))
- (unless (org-at-heading-p t) (outline-next-heading))
+ (unless (org-at-heading-p) (outline-next-heading))
(let ((inhibit-read-only t))
(insert-before-markers "#+COLUMNS: " fmt "\n"))))
(setq-local org-columns-default-format fmt))))))
diff --git a/lisp/org.el b/lisp/org.el
index f59d2cfb0..b17a5477c 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -17243,7 +17243,7 @@ (defun org-toggle-heading (&optional nstars)
;; Case 1. Started at an heading: de-star headings.
((org-at-heading-p)
(while (< (point) end)
- (when (org-at-heading-p t)
+ (when (org-at-heading-p)
(looking-at org-outline-regexp) (replace-match "")
(setq toggled t))
(forward-line)))
@@ -17844,7 +17844,7 @@ (defun org-context ()
(p (point)) clist o)
;; First the large context
(cond
- ((org-at-heading-p t)
+ ((org-at-heading-p)
(push (list :headline (point-at-bol) (point-at-eol)) clist)
(when (progn
(beginning-of-line 1)
@@ -19594,9 +19594,13 @@ (defun org-before-first-heading-p ()
(end-of-line)
(null (re-search-backward org-outline-regexp-bol nil t))))))
-(defun org-at-heading-p (&optional _)
- "Non-nil when on a headline."
- (outline-on-heading-p t))
+(defun org-at-heading-p (&optional invisible-not-ok)
+ "Return t if point is on a (possibly invisible) heading line.
+If INVISIBLE-NOT-OK is non-nil, an invisible heading line is not ok."
+ (save-excursion
+ (beginning-of-line)
+ (and (bolp) (or (not invisible-not-ok) (not (org-fold-folded-p)))
+ (looking-at outline-regexp))))
(defun org-in-commented-heading-p (&optional no-inheritance element)
"Non-nil if point is under a commented heading.