[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/org 31d53cb015 056/101: org-end-of-subtree: Use org-ele
From: |
ELPA Syncer |
Subject: |
[elpa] externals/org 31d53cb015 056/101: org-end-of-subtree: Use org-element API |
Date: |
Sat, 1 Jul 2023 09:59:12 -0400 (EDT) |
branch: externals/org
commit 31d53cb0157d51c4e42e50baee8c5d821ca334a5
Author: Ihor Radchenko <yantar92@posteo.net>
Commit: Ihor Radchenko <yantar92@posteo.net>
org-end-of-subtree: Use org-element API
* lisp/org.el (org-end-of-subtree): Skip all the blank lines before,
not just the last empty. Update the docstring.
---
lisp/org.el | 62 +++++++++++++++++++++++++------------------------------------
1 file changed, 25 insertions(+), 37 deletions(-)
diff --git a/lisp/org.el b/lisp/org.el
index 11cac24777..2d186d661e 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -20562,47 +20562,35 @@ If there is no such heading, return nil."
(point)))))
(defun org-end-of-subtree (&optional invisible-ok to-heading element)
- "Goto to the end of a subtree at point or for ELEMENT heading."
- ;; This contains an exact copy of the original function, but it uses
- ;; `org-back-to-heading-or-point-min', to make it work also in invisible
- ;; trees and before first headline. And is uses an invisible-ok argument.
- ;; Under Emacs this is not needed, but the old outline.el needs this fix.
- ;; Furthermore, when used inside Org, finding the end of a large subtree
- ;; with many children and grandchildren etc, this can be much faster
- ;; than the outline version.
- (if element
- (setq element (org-element-lineage element '(headline inlinetask)
'include-self))
- (org-back-to-heading-or-point-min invisible-ok))
- (unless (and (org-element--cache-active-p)
- (let ((cached (or element (org-element-at-point nil t))))
- (and cached
- (org-element-type-p cached 'headline)
- (goto-char (org-element-end cached)))))
- (let ((first t)
- (level (funcall outline-level)))
- (cond ((= level 0)
- (goto-char (point-max)))
- ((and (derived-mode-p 'org-mode) (< level 1000))
- ;; A true heading (not a plain list item), in Org
- ;; This means we can easily find the end by looking
- ;; only for the right number of stars. Using a regexp to do
- ;; this is so much faster than using a Lisp loop.
- (let ((re (concat "^\\*\\{1," (number-to-string level) "\\} ")))
- (forward-char 1)
- (and (re-search-forward re nil 'move) (beginning-of-line 1))))
- (t
- ;; something else, do it the slow way
- (while (and (not (eobp))
- (or first (> (funcall outline-level) level)))
- (setq first nil)
- (outline-next-heading))))))
+ "Goto to the end of a visible subtree at point or ELEMENT and return point.
+The subtree is considered at first heading parent containing point or
+ELEMENT.
+
+When end of the subtree has blank lines, move point before these blank
+lines.
+
+When INVISIBLE-OK is non-nil, ignore visibility.
+
+When before first heading, goto `point-max' minus blank lines.
+When TO-HEADING is non-nil, go to the next heading or `point-max'."
+ (when element
+ (setq element (org-element-lineage
+ element
+ '(headline inlinetask)
+ 'include-self))
+ (goto-char (org-element-begin element)))
+ (unless (and invisible-ok element)
+ (org-back-to-heading-or-point-min invisible-ok)
+ (setq element (org-element-at-point)))
+ (if (org-element-type-p element 'headline)
+ (goto-char (org-element-end element))
+ (goto-char (point-max)))
(unless to-heading
(when (memq (preceding-char) '(?\n ?\^M))
;; Go to end of line before heading
(forward-char -1)
- (when (memq (preceding-char) '(?\n ?\^M))
- ;; leave blank line before heading
- (forward-char -1))))
+ ;; Skip blank lines
+ (skip-chars-backward "\n\r\t ")))
(point))
(defun org-end-of-meta-data (&optional full)
- [elpa] externals/org eb0a293a02 048/101: Remove 'org-category text property cache, (continued)
- [elpa] externals/org eb0a293a02 048/101: Remove 'org-category text property cache, ELPA Syncer, 2023/07/01
- [elpa] externals/org e3d690edf8 054/101: org-element-cache-map: Allow when cache is disabled, ELPA Syncer, 2023/07/01
- [elpa] externals/org ebbdd67a2a 059/101: Remove effort property cache, ELPA Syncer, 2023/07/01
- [elpa] externals/org c22697f472 023/101: Use new function names `org-element-extract' and `org-element-set', ELPA Syncer, 2023/07/01
- [elpa] externals/org a06dc07cc0 028/101: org-element: Defer more when parsing headings and inlinetasks, ELPA Syncer, 2023/07/01
- [elpa] externals/org ea4f4fdf58 035/101: Rename `org-export-get-parent' to `org-element-parent', ELPA Syncer, 2023/07/01
- [elpa] externals/org a2730b47fa 032/101: org-odt--paragraph-style: Use `org-element-lineage', ELPA Syncer, 2023/07/01
- [elpa] externals/org a43cc8c9aa 033/101: org-export-get-node-property: Use `org-element-property-inherited', ELPA Syncer, 2023/07/01
- [elpa] externals/org bc29f5de41 038/101: org-element: New `org-element-*property*' functions, ELPA Syncer, 2023/07/01
- [elpa] externals/org 7cbc441915 044/101: org-entry-get-with-inheritance: Use org-element API, ELPA Syncer, 2023/07/01
- [elpa] externals/org 31d53cb015 056/101: org-end-of-subtree: Use org-element API,
ELPA Syncer <=
- [elpa] externals/org 7dee228569 063/101: org-element-at-point-no-context: Update docstring, ELPA Syncer, 2023/07/01
- [elpa] externals/org e1a2ea65ef 064/101: Allow syntax nodes to be supplied in place of POM in API functions, ELPA Syncer, 2023/07/01
- [elpa] externals/org 16d7cdcf52 068/101: org-manual: Remove unused drawer properties to disable, ELPA Syncer, 2023/07/01
- [elpa] externals/org 96b754c105 083/101: org-get-category, org-get-tags: Clarify that match data is modified, ELPA Syncer, 2023/07/01
- [elpa] externals/org fcde1f779d 090/101: test-org-element/at-point: Add new test, ELPA Syncer, 2023/07/01
- [elpa] externals/org 383d5dacb7 096/101: org-fold-show-set-visibility: Fix lineage visibility, ELPA Syncer, 2023/07/01
- [elpa] externals/org 4a8849340d 005/101: org-element-ast: New functions to map and resolve property values, ELPA Syncer, 2023/07/01
- [elpa] externals/org ea9d5b45db 012/101: org-element-create: Allow single &rest argument as a list, ELPA Syncer, 2023/07/01
- [elpa] externals/org a8286a5a9e 015/101: org-element: Record origin buffer when parsing, ELPA Syncer, 2023/07/01
- [elpa] externals/org 5e94d5cef6 026/101: org-element-map: Allow FUN to be a lisp form, ELPA Syncer, 2023/07/01