emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v2 07/38] org-at-heading-p: Accept optional argument* lisp/org.el


From: Ihor Radchenko
Subject: [PATCH v2 07/38] org-at-heading-p: Accept optional argument* lisp/org.el (org-at-heading-p): Use second argument to allow
Date: Wed, 20 Apr 2022 21:24:52 +0800

* 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 b55e00803..862243f28 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -10527,7 +10527,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 b9d2d7834..8c823a7c8 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -17259,7 +17259,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)))
@@ -17861,7 +17861,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)
@@ -19611,9 +19611,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.
-- 
2.35.1



-- 
Ihor Radchenko,
PhD,
Center for Advancing Materials Performance from the Nanoscale (CAMP-nano)
State Key Laboratory for Mechanical Behavior of Materials, Xi'an Jiaotong 
University, Xi'an, China
Email: yantar92@gmail.com, ihor_radchenko@alumni.sutd.edu.sg



reply via email to

[Prev in Thread] Current Thread [Next in Thread]