branch: externals/org commit fa7530c7b4468b04e7deade96be1873c696a9dc3 Author: Ihor Radchenko <yanta...@gmail.com> Commit: Ihor Radchenko <yanta...@gmail.com>
Rename old function call to use org-fold --- lisp/ob-core.el | 14 +++-- lisp/ob-lilypond.el | 4 +- lisp/ob-ref.el | 4 +- lisp/ol.el | 13 ++-- lisp/org-agenda.el | 43 +++++++------- lisp/org-archive.el | 12 ++-- lisp/org-capture.el | 2 +- lisp/org-clock.el | 10 ++-- lisp/org-colview.el | 6 +- lisp/org-compat.el | 29 +++++---- lisp/org-crypt.el | 8 +-- lisp/org-element.el | 1 + lisp/org-feed.el | 4 +- lisp/org-footnote.el | 6 +- lisp/org-goto.el | 6 +- lisp/org-id.el | 4 +- lisp/org-keys.el | 26 ++++---- lisp/org-lint.el | 3 +- lisp/org-list.el | 10 ++-- lisp/org-macs.el | 40 +++---------- lisp/org-mobile.el | 2 +- lisp/org-mouse.el | 4 +- lisp/org-refile.el | 2 +- lisp/org-src.el | 6 +- lisp/org-timer.el | 2 +- lisp/org.el | 135 +++++++++++++++++++++++------------------- lisp/ox-org.el | 2 +- testing/lisp/test-org-list.el | 2 +- testing/lisp/test-org.el | 78 ++++++++++++------------ 29 files changed, 241 insertions(+), 237 deletions(-) diff --git a/lisp/ob-core.el b/lisp/ob-core.el index 239a57f96d..6590eeee71 100644 --- a/lisp/ob-core.el +++ b/lisp/ob-core.el @@ -26,7 +26,9 @@ (require 'cl-lib) (require 'ob-eval) (require 'org-macs) +(require 'org-fold) (require 'org-compat) +(require 'org-cycle) (defconst org-babel-exeext (if (memq system-type '(windows-nt cygwin)) @@ -50,7 +52,7 @@ (declare-function org-babel-ref-split-args "ob-ref" (arg-string)) (declare-function org-babel-tangle-comment-links "ob-tangle" (&optional info)) (declare-function org-current-level "org" ()) -(declare-function org-cycle "org" (&optional arg)) +(declare-function org-cycle "org-cycle" (&optional arg)) (declare-function org-edit-src-code "org-src" (&optional code edit-buffer-name)) (declare-function org-edit-src-exit "org-src" ()) (declare-function org-element-at-point "org-element" (&optional pom cached-only)) @@ -75,7 +77,7 @@ (declare-function org-next-block "org" (arg &optional backward block-regexp)) (declare-function org-open-at-point "org" (&optional in-emacs reference-buffer)) (declare-function org-previous-block "org" (arg &optional block-regexp)) -(declare-function org-show-context "org" (&optional key)) +(declare-function org-fold-show-context "org-fold" (&optional key)) (declare-function org-src-coderef-format "org-src" (&optional element)) (declare-function org-src-coderef-regexp "org-src" (fmt &optional label)) (declare-function org-src-get-lang-mode "org-src" (lang)) @@ -945,7 +947,7 @@ arguments and pop open the results in a preview buffer." (insert (concat header " " (or arg ""))) (cons header arg))) -(add-hook 'org-tab-first-hook 'org-babel-header-arg-expand) +(add-hook 'org-cycle-tab-first-hook 'org-babel-header-arg-expand) ;;;###autoload (defun org-babel-load-in-session (&optional _arg info) @@ -1469,7 +1471,7 @@ portions of results lines." (push ov org-babel-hide-result-overlays))))) ;; org-tab-after-check-for-cycling-hook -(add-hook 'org-tab-first-hook #'org-babel-hide-result-toggle-maybe) +(add-hook 'org-cycle-tab-first-hook #'org-babel-hide-result-toggle-maybe) ;; Remove overlays when changing major mode (add-hook 'org-mode-hook (lambda () (add-hook 'change-major-mode-hook @@ -1817,7 +1819,7 @@ If the point is not on a source block then return nil." (let ((point (org-babel-find-named-block name))) (if point ;; Taken from `org-open-at-point'. - (progn (org-mark-ring-push) (goto-char point) (org-show-context)) + (progn (org-mark-ring-push) (goto-char point) (org-fold-show-context)) (message "source-code block `%s' not found in this buffer" name)))) (defun org-babel-find-named-block (name) @@ -1857,7 +1859,7 @@ to `org-babel-named-src-block-regexp'." (let ((point (org-babel-find-named-result name))) (if point ;; taken from `org-open-at-point' - (progn (goto-char point) (org-show-context)) + (progn (goto-char point) (org-fold-show-context)) (message "result `%s' not found in this buffer" name)))) (defun org-babel-find-named-result (name) diff --git a/lisp/ob-lilypond.el b/lisp/ob-lilypond.el index 15538b5037..df128441a3 100644 --- a/lisp/ob-lilypond.el +++ b/lisp/ob-lilypond.el @@ -34,7 +34,7 @@ ;;; Code: (require 'ob) -(declare-function org-show-all "org" (&optional types)) +(declare-function org-fold-show-all "org-fold" (&optional types)) (defalias 'lilypond-mode 'LilyPond-mode) @@ -279,7 +279,7 @@ LINE is the erroneous line." (setq case-fold-search nil) (if (search-forward line nil t) (progn - (org-show-all) + (org-fold-show-all) (set-mark (point)) (goto-char (- (point) (length line)))) (goto-char temp)))) diff --git a/lisp/ob-ref.el b/lisp/ob-ref.el index db8ced6b69..1a77e39b17 100644 --- a/lisp/ob-ref.el +++ b/lisp/ob-ref.el @@ -62,8 +62,8 @@ (declare-function org-id-find-id-file "org-id" (id)) (declare-function org-id-find-id-in-file "org-id" (id file &optional markerp)) (declare-function org-in-commented-heading-p "org" (&optional no-inheritance)) -(declare-function org-show-context "org" (&optional key)) (declare-function org-narrow-to-subtree "org" (&optional element)) +(declare-function org-fold-show-context "org-fold" (&optional key)) (defvar org-babel-update-intermediate nil "Update the in-buffer results of code blocks executed to resolve references.") @@ -104,7 +104,7 @@ Emacs Lisp representation of the value of the variable." (pop-to-buffer-same-window (marker-buffer m)) (goto-char m) (move-marker m nil) - (org-show-context) + (org-fold-show-context) t)))) (defun org-babel-ref-headline-body () diff --git a/lisp/ol.el b/lisp/ol.el index 1b2bb9a9a2..4cc813d5b6 100644 --- a/lisp/ol.el +++ b/lisp/ol.el @@ -29,6 +29,7 @@ (require 'org-compat) (require 'org-macs) +(require 'org-fold) (defvar clean-buffer-list-kill-buffer-names) (defvar org-agenda-buffer-name) @@ -66,10 +67,10 @@ (declare-function org-mode "org" ()) (declare-function org-occur "org" (regexp &optional keep-previous callback)) (declare-function org-open-file "org" (path &optional in-emacs line search)) -(declare-function org-overview "org" ()) +(declare-function org-cycle-overview "org-cycle" ()) (declare-function org-restart-font-lock "org" ()) (declare-function org-run-like-in-org-mode "org" (cmd)) -(declare-function org-show-context "org" (&optional key)) +(declare-function org-fold-show-context "org-fold" (&optional key)) (declare-function org-src-coderef-format "org-src" (&optional element)) (declare-function org-src-coderef-regexp "org-src" (fmt &optional label)) (declare-function org-src-edit-buffer-p "org-src" (&optional buffer)) @@ -700,7 +701,7 @@ followed by another \"%[A-F0-9]{2}\" group." (make-indirect-buffer (current-buffer) indirect-buffer-name 'clone)))) - (with-current-buffer indirect-buffer (org-overview)) + (with-current-buffer indirect-buffer (org-cycle-overview)) indirect-buffer)))) (defun org-link--search-radio-target (target) @@ -718,7 +719,7 @@ White spaces are not significant." (let ((object (org-element-context))) (when (eq (org-element-type object) 'radio-target) (goto-char (org-element-property :begin object)) - (org-show-context 'link-search) + (org-fold-show-context 'link-search) (throw :radio-match nil)))) (goto-char origin) (user-error "No match for radio target: %s" target)))) @@ -1257,7 +1258,7 @@ of matched result, which is either `dedicated' or `fuzzy'." (error "No match for fuzzy expression: %s" normalized))) ;; Disclose surroundings of match, if appropriate. (when (and (derived-mode-p 'org-mode) (not stealth)) - (org-show-context 'link-search)) + (org-fold-show-context 'link-search)) type)) (defun org-link-heading-search-string (&optional string) @@ -1430,7 +1431,7 @@ is non-nil, move backward." (`nil nil) (link (goto-char (org-element-property :begin link)) - (when (org-invisible-p) (org-show-context)) + (when (org-invisible-p) (org-fold-show-context)) (throw :found t))))) (goto-char pos) (setq org-link--search-failed t) diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el index c138807dad..eca56a01e1 100644 --- a/lisp/org-agenda.el +++ b/lisp/org-agenda.el @@ -47,6 +47,7 @@ (require 'cl-lib) (require 'ol) +(require 'org-fold-core) (require 'org) (require 'org-macs) (require 'org-refile) @@ -9393,7 +9394,7 @@ When called with a prefix argument, include all archive files as well." (push-mark) (goto-char pos) (when (derived-mode-p 'org-mode) - (org-show-context 'agenda) + (org-fold-show-context 'agenda) (recenter (/ (window-height) 2)) (org-back-to-heading t) (let ((case-fold-search nil)) @@ -9682,7 +9683,7 @@ displayed Org file fills the frame." (widen) (goto-char pos) (when (derived-mode-p 'org-mode) - (org-show-context 'agenda) + (org-fold-show-context 'agenda) (run-hooks 'org-agenda-after-show-hook))))) (defun org-agenda-goto-mouse (ev) @@ -9698,7 +9699,7 @@ if it was hidden in the outline." (interactive "P") (let ((win (selected-window))) (org-agenda-goto t) - (when full-entry (org-show-entry)) + (when full-entry (org-fold-show-entry)) (select-window win))) (defvar org-agenda-show-window nil) @@ -9717,12 +9718,12 @@ fold drawers." (select-window org-agenda-show-window) (ignore-errors (scroll-up))) (org-agenda-goto t) - (org-show-entry) + (org-fold-show-entry) (if arg (org-cycle-hide-drawers 'children) (org-with-wide-buffer (narrow-to-region (org-entry-beginning-position) (org-entry-end-position)) - (org-show-all '(drawers)))) + (org-fold-show-all '(drawers)))) (setq org-agenda-show-window (selected-window))) (select-window win))) @@ -9753,7 +9754,7 @@ if it was hidden in the outline." (set-window-start (selected-window) (point-at-bol)) (cond ((= more 0) - (org-flag-subtree t) + (org-fold-subtree t) (save-excursion (org-back-to-heading) (run-hook-with-args 'org-cycle-hook 'folded)) @@ -9761,20 +9762,20 @@ if it was hidden in the outline." ((and (called-interactively-p 'any) (= more 1)) (message "Remote: show with default settings")) ((= more 2) - (outline-show-entry) - (org-show-children) + (org-fold-show-entry) + (org-fold-show-children) (save-excursion (org-back-to-heading) (run-hook-with-args 'org-cycle-hook 'children)) (message "Remote: CHILDREN")) ((= more 3) - (outline-show-subtree) + (org-fold-show-subtree) (save-excursion (org-back-to-heading) (run-hook-with-args 'org-cycle-hook 'subtree)) (message "Remote: SUBTREE")) ((> more 3) - (outline-show-subtree) + (org-fold-show-subtree) (message "Remote: SUBTREE AND ALL DRAWERS"))) (select-window win))) @@ -9906,7 +9907,7 @@ the same tree node, and the headline of the tree node in the Org file." (with-current-buffer buffer (widen) (goto-char pos) - (org-show-context 'agenda) + (org-fold-show-context 'agenda) (let ((current-prefix-arg arg)) (call-interactively 'org-todo) ;; Make sure that log is recorded in current undo. @@ -9947,7 +9948,7 @@ the same tree node, and the headline of the tree node in the Org file." (with-current-buffer buffer (widen) (goto-char pos) - (org-show-context 'agenda) + (org-fold-show-context 'agenda) (org-add-note)))) (defun org-agenda-change-all-lines (newhead hdmarker @@ -10096,7 +10097,7 @@ When called programmatically, FORCE-DIRECTION can be `set', `up', (with-current-buffer buffer (widen) (goto-char pos) - (org-show-context 'agenda) + (org-fold-show-context 'agenda) (org-priority force-direction) (end-of-line 1) (setq newhead (org-get-heading))) @@ -10120,7 +10121,7 @@ When called programmatically, FORCE-DIRECTION can be `set', `up', (with-current-buffer buffer (widen) (goto-char pos) - (org-show-context 'agenda) + (org-fold-show-context 'agenda) (if tag (org-toggle-tag tag onoff) (call-interactively #'org-set-tags-command)) @@ -10145,7 +10146,7 @@ When called programmatically, FORCE-DIRECTION can be `set', `up', (with-current-buffer buffer (widen) (goto-char pos) - (org-show-context 'agenda) + (org-fold-show-context 'agenda) (call-interactively 'org-set-property)))))) (defun org-agenda-set-effort () @@ -10164,7 +10165,7 @@ When called programmatically, FORCE-DIRECTION can be `set', `up', (with-current-buffer buffer (widen) (goto-char pos) - (org-show-context 'agenda) + (org-fold-show-context 'agenda) (call-interactively 'org-set-effort) (end-of-line 1) (setq newhead (org-get-heading))) @@ -10186,7 +10187,7 @@ When called programmatically, FORCE-DIRECTION can be `set', `up', (with-current-buffer buffer (widen) (goto-char pos) - (org-show-context 'agenda) + (org-fold-show-context 'agenda) (call-interactively 'org-toggle-archive-tag) (end-of-line 1) (setq newhead (org-get-heading))) @@ -10393,7 +10394,7 @@ ARG is passed through to `org-deadline'." (with-current-buffer (marker-buffer marker) (widen) (goto-char pos) - (org-show-context 'agenda) + (org-fold-show-context 'agenda) (org-clock-in arg) (setq newhead (org-get-heading))) (org-agenda-change-all-lines newhead hdmarker)) @@ -10482,7 +10483,7 @@ buffer, display it in another window." (find-file-noselect org-agenda-diary-file)) (require 'org-datetree) (org-datetree-find-date-create d1) - (org-reveal t)) + (org-fold-reveal t)) (t (user-error "Invalid selection character `%c'" char))))) (defcustom org-agenda-insert-diary-strategy 'date-tree @@ -10584,7 +10585,7 @@ the resulting entry will not be shown. When TEXT is empty, switch to (message "%s entry added to %s" (capitalize (symbol-name type)) (abbreviate-file-name org-agenda-diary-file))) - (org-reveal t) + (org-fold-reveal t) (message "Please finish entry here")))) (defun org-agenda-insert-diary-as-top-level (text) @@ -10622,7 +10623,7 @@ a timestamp can be added there." (unless (bolp) (insert "\n")) (unless (looking-at-p "^[ \t]*$") (save-excursion (insert "\n"))) (when org-adapt-indentation (indent-to-column col))) - (org-show-set-visibility 'lineage)) + (org-fold-show-set-visibility 'lineage)) (defun org-agenda-diary-entry () "Make a diary entry, like the `i' command from the calendar. diff --git a/lisp/org-archive.el b/lisp/org-archive.el index 6ea16f8c1e..1026a295ee 100644 --- a/lisp/org-archive.el +++ b/lisp/org-archive.el @@ -324,7 +324,7 @@ direct children of this heading." (org-todo-regexp tr-org-todo-regexp) (org-todo-line-regexp tr-org-todo-line-regexp)) (goto-char (point-min)) - (org-show-all '(headings blocks)) + (org-fold-show-all '(headings blocks)) (if (and heading (not (and datetree-date (not datetree-subheading-p)))) (progn (if (re-search-forward @@ -339,7 +339,7 @@ direct children of this heading." (insert (if datetree-date "" "\n") heading "\n") (end-of-line 0)) ;; Make the subtree visible - (outline-show-subtree) + (org-fold-show-subtree) (if org-archive-reversed-order (progn (org-back-to-heading t) @@ -417,7 +417,7 @@ direct children of this heading." (if (eq this-buffer buffer) (concat "under heading: " heading) (concat "in file: " (abbreviate-file-name afile))))))) - (org-reveal) + (org-fold-reveal) (if (looking-at "^[ \t]*$") (outline-next-visible-heading 1)))) @@ -487,13 +487,13 @@ Archiving time is retained in the ARCHIVE_TIME node property." (format-time-string (substring (cdr org-time-stamp-formats) 1 -1))) (outline-up-heading 1 t) - (org-flag-subtree t) + (org-fold-subtree t) (org-cycle-show-empty-lines 'folded) (when org-provide-todo-statistics ;; Update TODO statistics of parent. (org-update-parent-todo-statistics)) (goto-char pos))) - (org-reveal) + (org-fold-reveal) (if (looking-at "^[ \t]*$") (outline-next-visible-heading 1)))) @@ -602,7 +602,7 @@ the children that do not contain any open TODO items." (save-excursion (org-back-to-heading t) (setq set (org-toggle-tag org-archive-tag)) - (when set (org-flag-subtree t))) + (when set (org-fold-subtree t))) (and set (beginning-of-line 1)) (message "Subtree %s" (if set "archived" "unarchived")))))) diff --git a/lisp/org-capture.el b/lisp/org-capture.el index bbb37eb27a..1324ffab4c 100644 --- a/lisp/org-capture.el +++ b/lisp/org-capture.el @@ -1129,7 +1129,7 @@ may have been stored before." (org-switch-to-buffer-other-window (org-capture-get-indirect-buffer (org-capture-get :buffer) "CAPTURE")) (widen) - (org-show-all) + (org-fold-show-all) (goto-char (org-capture-get :pos)) (setq-local outline-level 'org-outline-level) (pcase (org-capture-get :type) diff --git a/lisp/org-clock.el b/lisp/org-clock.el index 6f441c18e1..583b302376 100644 --- a/lisp/org-clock.el +++ b/lisp/org-clock.el @@ -1035,7 +1035,7 @@ CLOCK is a cons cell of the form (MARKER START-TIME)." (let ((element (org-element-at-point))) (when (eq (org-element-type element) 'drawer) (when (> (org-element-property :end element) (car clock)) - (org-hide-drawer-toggle 'off nil element)) + (org-fold-hide-drawer-toggle 'off nil element)) (throw 'exit nil))))))))))) (defun org-clock-resolve (clock &optional prompt-fn last-valid fail-quietly) @@ -1843,10 +1843,10 @@ With prefix arg SELECT, offer recently clocked tasks for selection." (pop-to-buffer-same-window (marker-buffer m)) (if (or (< m (point-min)) (> m (point-max))) (widen)) (goto-char m) - (org-show-entry) + (org-fold-show-entry) (org-back-to-heading t) (recenter org-clock-goto-before-context) - (org-reveal) + (org-fold-reveal) (if recent (message "No running clock, this is the most recently clocked task")) (run-hooks 'org-clock-goto-hook))) @@ -2140,7 +2140,7 @@ in the buffer and update it." (org-clock-remove-overlays) (when arg (org-find-dblock "clocktable") - (org-show-entry)) + (org-fold-show-entry)) (pcase (org-in-clocktable-p) (`nil (org-create-dblock @@ -3125,7 +3125,7 @@ The details of what will be saved are regulated by the variable (let ((org-clock-in-resume 'auto-restart) (org-clock-auto-clock-resolution nil)) (org-clock-in) - (when (org-invisible-p) (org-show-context)))))) + (when (org-invisible-p) (org-fold-show-context)))))) (_ nil))))) (defun org-clock-kill-emacs-query () diff --git a/lisp/org-colview.el b/lisp/org-colview.el index 15cab35f0e..c8443c135c 100644 --- a/lisp/org-colview.el +++ b/lisp/org-colview.el @@ -159,8 +159,8 @@ See `org-columns-summary-types' for details.") (defun org-columns-content () "Switch to contents view while in columns view." (interactive) - (org-overview) - (org-content)) + (org-cycle-overview) + (org-cycle-content)) (org-defkey org-columns-map "c" #'org-columns-content) (org-defkey org-columns-map "o" #'org-overview) @@ -701,7 +701,7 @@ FUN is a function called with no argument." (move-beginning-of-line 2) (org-at-heading-p))))) (unwind-protect (funcall fun) - (when hide-body (outline-hide-entry))))) + (when hide-body (org-fold-hide-entry))))) (defun org-columns-previous-allowed-value () "Switch to the previous allowed value for this column." diff --git a/lisp/org-compat.el b/lisp/org-compat.el index b35e66b84e..ed2ae62f4e 100644 --- a/lisp/org-compat.el +++ b/lisp/org-compat.el @@ -50,18 +50,20 @@ (declare-function org-end-of-subtree "org" (&optional invisible-ok to-heading)) (declare-function org-get-heading "org" (&optional no-tags no-todo no-priority no-comment)) (declare-function org-get-tags "org" (&optional pos local)) -(declare-function org-hide-block-toggle "org" (&optional force no-error element)) +(declare-function org-fold-hide-block-toggle "org-fold" (&optional force no-error element)) (declare-function org-link-display-format "ol" (s)) (declare-function org-link-set-parameters "ol" (type &rest rest)) (declare-function org-log-into-drawer "org" ()) (declare-function org-make-tag-string "org" (tags)) (declare-function org-reduced-level "org" (l)) (declare-function org-return "org" (&optional indent arg interactive)) -(declare-function org-show-context "org" (&optional key)) +(declare-function org-fold-show-context "org-fold" (&optional key)) (declare-function org-table-end "org-table" (&optional table-type)) (declare-function outline-next-heading "outline" ()) (declare-function speedbar-line-directory "speedbar" (&optional depth)) (declare-function table--at-cell-p "table" (position &optional object at-column)) +(declare-function org-fold-region "org-fold" (from to flag &optional spec)) +(declare-function org-fold-show-all "org-fold" (&optional types)) (defvar calendar-mode-map) (defvar org-complex-heading-regexp) @@ -72,6 +74,7 @@ (defvar org-table-dataline-regexp) (defvar org-table-tab-recognizes-table.el) (defvar org-table1-hline-regexp) +(defvar org-fold-core-style) ;;; Emacs < 29 compatibility @@ -656,7 +659,7 @@ use of this function is for the stuck project list." (defun org-show-block-all () "Unfold all blocks in the current buffer." (interactive) - (remove-overlays nil nil 'invisible 'org-hide-block)) + (org-fold-show-all '(blocks))) (make-obsolete 'org-show-block-all "use `org-show-all' instead." @@ -699,7 +702,7 @@ When optional argument ELEMENT is a parsed drawer, as returned by When buffer positions BEG and END are provided, hide or show that region as a drawer without further ado." (declare (obsolete "use `org-hide-drawer-toggle' instead." "9.4")) - (if (and beg end) (org-flag-region beg end flag 'outline) + (if (and beg end) (org-fold-region beg end flag (if (eq org-fold-core-style 'text-properties) 'drawer 'outline)) (let ((drawer (or element (and (save-excursion @@ -708,12 +711,12 @@ region as a drawer without further ado." (org-element-at-point))))) (when (memq (org-element-type drawer) '(drawer property-drawer)) (let ((post (org-element-property :post-affiliated drawer))) - (org-flag-region + (org-fold-region (save-excursion (goto-char post) (line-end-position)) (save-excursion (goto-char (org-element-property :end drawer)) (skip-chars-backward " \t\n") (line-end-position)) - flag 'outline) + flag (if (eq org-fold-core-style 'text-properties) 'drawer 'outline)) ;; When the drawer is hidden away, make sure point lies in ;; a visible part of the buffer. (when (invisible-p (max (1- (point)) (point-min))) @@ -725,7 +728,7 @@ Unlike to `org-hide-block-toggle', this function does not throw an error. Return a non-nil value when toggling is successful." (declare (obsolete "use `org-hide-block-toggle' instead." "9.4")) (interactive) - (org-hide-block-toggle nil t)) + (org-fold-hide-block-toggle nil t)) (defun org-hide-block-toggle-all () "Toggle the visibility of all blocks in the current buffer." @@ -741,7 +744,7 @@ an error. Return a non-nil value when toggling is successful." (save-excursion (save-match-data (goto-char (match-beginning 0)) - (org-hide-block-toggle))))))) + (org-fold-hide-block-toggle))))))) (defun org-return-indent () "Goto next table row or insert a newline and indent. @@ -973,7 +976,7 @@ This also applied for speedbar access." (add-hook 'imenu-after-jump-hook (lambda () (when (derived-mode-p 'org-mode) - (org-show-context 'org-goto)))) + (org-fold-show-context 'org-goto)))) (add-hook 'org-mode-hook (lambda () (setq imenu-create-index-function 'org-imenu-get-tree))))) @@ -1038,7 +1041,7 @@ To get rid of the restriction, use `\\[org-agenda-remove-restriction-lock]'." (define-key speedbar-file-key-map ">" 'org-agenda-remove-restriction-lock) (define-key speedbar-file-key-map "\C-c\C-x>" 'org-agenda-remove-restriction-lock) (add-hook 'speedbar-visiting-tag-hook - (lambda () (and (derived-mode-p 'org-mode) (org-show-context 'org-goto)))))) + (lambda () (and (derived-mode-p 'org-mode) (org-fold-show-context 'org-goto)))))) ;;;; Add Log @@ -1152,7 +1155,7 @@ ELEMENT is the element at point." (or (org-invisible-p) (save-excursion (goto-char (max (point-min) (1- (point)))) (org-invisible-p))) - (org-show-context 'bookmark-jump))) + (org-fold-show-context 'bookmark-jump))) ;; Make `bookmark-jump' shows the jump location if it was hidden. (add-hook 'bookmark-after-jump-hook #'org-bookmark-jump-unhide) @@ -1217,7 +1220,7 @@ key." (defun org--ecb-show-context (&rest _) "Make hierarchy visible when jumping into location from ECB tree buffer." (when (derived-mode-p 'org-mode) - (org-show-context))) + (org-fold-show-context))) ;;;; Simple @@ -1225,7 +1228,7 @@ key." "Make the point visible with `org-show-context' after jumping to the mark." (when (and (derived-mode-p 'org-mode) (org-invisible-p)) - (org-show-context 'mark-goto))) + (org-fold-show-context 'mark-goto))) (advice-add 'pop-to-mark-command :after #'org-mark-jump-unhide) diff --git a/lisp/org-crypt.el b/lisp/org-crypt.el index 41813cb184..b2542ab43a 100644 --- a/lisp/org-crypt.el +++ b/lisp/org-crypt.el @@ -73,7 +73,7 @@ (declare-function org-end-of-meta-data "org" (&optional full)) (declare-function org-end-of-subtree "org" (&optional invisible-ok to-heading)) (declare-function org-entry-get "org" (pom property &optional inherit literal-nil)) -(declare-function org-flag-subtree "org" (flag)) +(declare-function org-fold-subtree "org-fold" (flag)) (declare-function org-make-tags-matcher "org" (match)) (declare-function org-previous-visible-heading "org" (arg)) (declare-function org-scan-tags "org" (action matcher todo-only &optional start-level)) @@ -243,7 +243,7 @@ Assume `epg-context' is set." (error (error-message-string err))))) (when folded-heading (goto-char folded-heading) - (org-flag-subtree t)) + (org-fold-subtree t)) nil))))) ;;;###autoload @@ -280,7 +280,7 @@ Assume `epg-context' is set." 'org-crypt-text encrypted-text)) (when folded-heading (goto-char folded-heading) - (org-flag-subtree t)) + (org-fold-subtree t)) nil))) (_ nil))) @@ -313,7 +313,7 @@ Assume `epg-context' is set." 'org-mode-hook (lambda () (add-hook 'before-save-hook 'org-encrypt-entries nil t)))) -(add-hook 'org-reveal-start-hook 'org-decrypt-entry) +(add-hook 'org-fold-reveal-start-hook 'org-decrypt-entry) (provide 'org-crypt) diff --git a/lisp/org-element.el b/lisp/org-element.el index fc4e0e43a0..e23d6483f7 100644 --- a/lisp/org-element.el +++ b/lisp/org-element.el @@ -70,6 +70,7 @@ (require 'org-list) (require 'org-macs) (require 'org-table) +(require 'org-fold-core) (declare-function org-at-heading-p "org" (&optional _)) (declare-function org-escape-code-in-string "org-src" (s)) diff --git a/lisp/org-feed.el b/lisp/org-feed.el index a5fea08882..d634f9c417 100644 --- a/lisp/org-feed.el +++ b/lisp/org-feed.el @@ -412,8 +412,8 @@ it can be a list structured like an entry in `org-feed-alist'." ;; Normalize the visibility of the inbox tree (goto-char inbox-pos) - (org-flag-subtree t) - (org-show-children) + (org-fold-subtree t) + (org-fold-show-children) ;; Hooks and messages (when org-feed-save-after-adding (save-buffer)) diff --git a/lisp/org-footnote.el b/lisp/org-footnote.el index b55f6d98e7..a4c9ae7705 100644 --- a/lisp/org-footnote.el +++ b/lisp/org-footnote.el @@ -52,7 +52,7 @@ (declare-function org-inside-LaTeX-fragment-p "org" ()) (declare-function org-inside-latex-macro-p "org" ()) (declare-function org-mark-ring-push "org" (&optional pos buffer)) -(declare-function org-show-context "org" (&optional key)) +(declare-function org-fold-show-context "org-fold" (&optional key)) (declare-function outline-next-heading "outline") (defvar electric-indent-mode) @@ -555,7 +555,7 @@ value if point was successfully moved." (goto-char def-start) (looking-at (format "\\[fn:%s[]:]" (regexp-quote label))) (goto-char (match-end 0)) - (org-show-context 'link-search) + (org-fold-show-context 'link-search) (when (derived-mode-p 'org-mode) (message "%s" (substitute-command-keys "Edit definition and go back with \ @@ -581,7 +581,7 @@ value if point was successfully moved." (user-error "Reference is outside narrowed part of buffer"))) (org-mark-ring-push) (goto-char start) - (org-show-context 'link-search))) + (org-fold-show-context 'link-search))) ;;;; Getters diff --git a/lisp/org-goto.el b/lisp/org-goto.el index 860b0a3de4..cd50000377 100644 --- a/lisp/org-goto.el +++ b/lisp/org-goto.el @@ -222,13 +222,13 @@ position or nil." " Just type for auto-isearch." " n/p/f/b/u to navigate, q to quit."))))) (org-fit-window-to-buffer (get-buffer-window "*Org Help*")) - (org-overview) + (org-cycle-overview) (setq buffer-read-only t) (if (and (boundp 'org-goto-start-pos) (integer-or-marker-p org-goto-start-pos)) (progn (goto-char org-goto-start-pos) (when (org-invisible-p) - (org-show-set-visibility 'lineage))) + (org-fold-show-set-visibility 'lineage))) (goto-char (point-min))) (let (org-special-ctrl-a/e) (org-beginning-of-line)) (message "Select location and press RET") @@ -279,7 +279,7 @@ With a prefix argument, use the alternative interface: e.g., if (org-mark-ring-push org-goto-start-pos) (goto-char selected-point) (when (or (org-invisible-p) (org-invisible-p2)) - (org-show-context 'org-goto))) + (org-fold-show-context 'org-goto))) (message "Quit")))) (provide 'org-goto) diff --git a/lisp/org-id.el b/lisp/org-id.el index a8f8eb4ebf..0331b7c1df 100644 --- a/lisp/org-id.el +++ b/lisp/org-id.el @@ -333,7 +333,7 @@ Move the cursor to that entry in that buffer." (pop-to-buffer-same-window (marker-buffer m)) (goto-char m) (move-marker m nil) - (org-show-context))) + (org-fold-show-context))) ;;;###autoload (defun org-id-find (id &optional markerp) @@ -745,7 +745,7 @@ or filename if no title." (funcall cmd (marker-buffer m))) (goto-char m) (move-marker m nil) - (org-show-context))) + (org-fold-show-context))) (org-link-set-parameters "id" :follow #'org-id-open) diff --git a/lisp/org-keys.el b/lisp/org-keys.el index b8e9ddd938..782ffa8710 100644 --- a/lisp/org-keys.el +++ b/lisp/org-keys.el @@ -67,8 +67,8 @@ (declare-function org-ctrl-c-tab "org" (&optional arg)) (declare-function org-cut-special "org" ()) (declare-function org-cut-subtree "org" (&optional n)) -(declare-function org-cycle "org" (&optional arg)) -(declare-function org-cycle-agenda-files "org" ()) +(declare-function org-cycle "org-cycle" (&optional arg)) +(declare-function org-cycle-agenda-files "org-cycle" ()) (declare-function org-date-from-calendar "org" ()) (declare-function org-dynamic-block-insert-dblock "org" (&optional arg)) (declare-function org-dblock-update "org" (&optional arg)) @@ -94,7 +94,7 @@ (declare-function org-fill-paragraph "org" (&optional justify region)) (declare-function org-find-file-at-mouse "org" (ev)) (declare-function org-footnote-action "org" (&optional special)) -(declare-function org-force-cycle-archived "org" ()) +(declare-function org-cycle-force-archived "org-cycle" ()) (declare-function org-force-self-insert "org" (n)) (declare-function org-forward-element "org" ()) (declare-function org-forward-heading-same-level "org" (arg &optional invisible-ok)) @@ -143,8 +143,8 @@ (declare-function org-priority "org" (&optional action show)) (declare-function org-promote-subtree "org" ()) (declare-function org-redisplay-inline-images "org" ()) -(declare-function org-refile "org" (&optional arg1 default-buffer rfloc msg)) -(declare-function org-refile-copy "org" ()) +(declare-function org-refile "org-refile" (&optional arg1 default-buffer rfloc msg)) +(declare-function org-refile-copy "org-refile" ()) (declare-function org-refile-reverse "org-refile" (&optional arg default-buffer rfloc msg)) (declare-function org-reftex-citation "org" ()) (declare-function org-reload "org" (&optional arg1)) @@ -152,7 +152,7 @@ (declare-function org-resolve-clocks "org" (&optional only-dangling-p prompt-fn last-valid)) (declare-function org-return "org" (&optional indent)) (declare-function org-return-and-maybe-indent "org" ()) -(declare-function org-reveal "org" (&optional siblings)) +(declare-function org-fold-reveal "org-fold" (&optional siblings)) (declare-function org-schedule "org" (arg &optional time)) (declare-function org-self-insert-command "org" (N)) (declare-function org-set-effort "org" (&optional increment value)) @@ -172,9 +172,9 @@ (declare-function org-shiftright "org" (&optional arg)) (declare-function org-shifttab "org" (&optional arg)) (declare-function org-shiftup "org" (&optional arg)) -(declare-function org-show-all "org" (&optional types)) -(declare-function org-show-children "org" (&optional level)) -(declare-function org-show-subtree "org" ()) +(declare-function org-fold-show-all "org-fold" (&optional types)) +(declare-function org-fold-show-children "org-fold" (&optional level)) +(declare-function org-fold-show-subtree "org-fold" ()) (declare-function org-sort "org" (&optional with-case)) (declare-function org-sparse-tree "org" (&optional arg type)) (declare-function org-table-copy-down "org" (n)) @@ -423,7 +423,7 @@ COMMANDS is a list of alternating OLDDEF NEWDEF command names." (define-key org-mode-map [menu-bar show] 'undefined) (define-key org-mode-map [remap outline-mark-subtree] #'org-mark-subtree) -(define-key org-mode-map [remap outline-show-subtree] #'org-show-subtree) +(define-key org-mode-map [remap outline-show-subtree] #'org-fold-show-subtree) (define-key org-mode-map [remap outline-forward-same-level] #'org-forward-heading-same-level) (define-key org-mode-map [remap outline-backward-same-level] @@ -437,14 +437,14 @@ COMMANDS is a list of alternating OLDDEF NEWDEF command names." #'org-next-visible-heading) (define-key org-mode-map [remap outline-previous-visible-heading] #'org-previous-visible-heading) -(define-key org-mode-map [remap show-children] #'org-show-children) +(define-key org-mode-map [remap outline-show-children] #'org-fold-show-children) ;;;; Make `C-c C-x' a prefix key (org-defkey org-mode-map (kbd "C-c C-x") (make-sparse-keymap)) ;;;; TAB key with modifiers (org-defkey org-mode-map (kbd "TAB") #'org-cycle) -(org-defkey org-mode-map (kbd "C-c C-<tab>") #'org-force-cycle-archived) +(org-defkey org-mode-map (kbd "C-c C-<tab>") #'org-cycle-force-archived) ;; Override text-mode binding to expose `complete-symbol' for ;; pcomplete functionality. (org-defkey org-mode-map (kbd "M-TAB") nil) @@ -544,7 +544,7 @@ COMMANDS is a list of alternating OLDDEF NEWDEF command names." ;;;; All the other keys (org-defkey org-mode-map (kbd "|") #'org-force-self-insert) -(org-defkey org-mode-map (kbd "C-c C-r") #'org-reveal) +(org-defkey org-mode-map (kbd "C-c C-r") #'org-fold-reveal) (org-defkey org-mode-map (kbd "C-M-t") #'org-transpose-element) (org-defkey org-mode-map (kbd "M-}") #'org-forward-element) (org-defkey org-mode-map (kbd "ESC }") #'org-forward-element) diff --git a/lisp/org-lint.el b/lisp/org-lint.el index b21412be12..cce6fddbd4 100644 --- a/lisp/org-lint.el +++ b/lisp/org-lint.el @@ -91,6 +91,7 @@ (require 'ol) (require 'org-attach) (require 'org-macro) +(require 'org-fold) (require 'ox) (require 'seq) @@ -264,7 +265,7 @@ CHECKERS is the list of checkers used." (let ((l (org-lint--current-line))) (switch-to-buffer-other-window org-lint--source-buffer) (org-goto-line l) - (org-show-set-visibility 'local) + (org-fold-show-set-visibility 'local) (recenter))) (defun org-lint--show-source () diff --git a/lisp/org-list.el b/lisp/org-list.el index f1ab2ca764..05a73a6093 100644 --- a/lisp/org-list.el +++ b/lisp/org-list.el @@ -79,6 +79,7 @@ (require 'cl-lib) (require 'org-macs) (require 'org-compat) +(require 'org-fold-core) (defvar org-M-RET-may-split-line) (defvar org-adapt-indentation) @@ -138,7 +139,8 @@ (declare-function org-previous-line-empty-p "org" ()) (declare-function org-reduced-level "org" (L)) (declare-function org-set-tags "org" (tags)) -(declare-function org-show-subtree "org" ()) +(declare-function org-fold-show-subtree "org-fold" ()) +(declare-function org-fold-region "org-fold" (from to flag &optional spec)) (declare-function org-sort-remove-invisible "org" (S)) (declare-function org-time-string-to-seconds "org" (s)) (declare-function org-timer-hms-to-secs "org-timer" (hms)) @@ -2029,7 +2031,7 @@ Possible values are: `folded', `children' or `subtree'. See ((eq view 'folded) (let ((item-end (org-list-get-item-end-before-blank item struct))) ;; Hide from eol - (org-flag-region (save-excursion (goto-char item) (line-end-position)) + (org-fold-region (save-excursion (goto-char item) (line-end-position)) item-end t 'outline))) ((eq view 'children) ;; First show everything. @@ -2042,7 +2044,7 @@ Possible values are: `folded', `children' or `subtree'. See ((eq view 'subtree) ;; Show everything (let ((item-end (org-list-get-item-end item struct))) - (org-flag-region item item-end nil 'outline))))) + (org-fold-region item item-end nil 'outline))))) (defun org-list-item-body-column (item) "Return column at which body of ITEM should start." @@ -2455,7 +2457,7 @@ subtree, ignoring planning line and any drawer following it." (save-restriction (save-excursion (org-narrow-to-subtree) - (org-show-subtree) + (org-fold-show-subtree) (goto-char (point-min)) (let ((end (point-max))) (while (< (point) end) diff --git a/lisp/org-macs.el b/lisp/org-macs.el index f63458f703..7703e09e44 100644 --- a/lisp/org-macs.el +++ b/lisp/org-macs.el @@ -35,11 +35,16 @@ (require 'format-spec) (declare-function org-mode "org" ()) -(declare-function org-show-context "org" (&optional key)) +(declare-function org-agenda-files "org" (&optional unrestricted archives)) +(declare-function org-fold-show-context "org-fold" (&optional key)) +(declare-function org-fold-save-outline-visibility "org-fold" (use-markers &rest body)) +(declare-function org-fold-next-visibility-change "org-fold" (&optional pos limit ignore-hidden-p previous-p)) +(declare-function org-fold-folded-p "org-fold" (&optional pos limit ignore-hidden-p previous-p)) (declare-function string-collate-lessp "org-compat" (s1 s2 &optional locale ignore-case)) (defvar org-ts-regexp0) (defvar ffap-url-regexp) +(defvar org-fold-core-style) ;;; Macros @@ -117,38 +122,7 @@ (declare (debug (body))) `(let ((inhibit-read-only t)) ,@body)) -(defmacro org-save-outline-visibility (use-markers &rest body) - "Save and restore outline visibility around BODY. -If USE-MARKERS is non-nil, use markers for the positions. This -means that the buffer may change while running BODY, but it also -means that the buffer should stay alive during the operation, -because otherwise all these markers will point to nowhere." - (declare (debug (form body)) (indent 1)) - (org-with-gensyms (data invisible-types markers?) - `(let* ((,invisible-types '(org-hide-block outline)) - (,markers? ,use-markers) - (,data - (mapcar (lambda (o) - (let ((beg (overlay-start o)) - (end (overlay-end o)) - (type (overlay-get o 'invisible))) - (and beg end - (> end beg) - (memq type ,invisible-types) - (list (if ,markers? (copy-marker beg) beg) - (if ,markers? (copy-marker end t) end) - type)))) - (org-with-wide-buffer - (overlays-in (point-min) (point-max)))))) - (unwind-protect (progn ,@body) - (org-with-wide-buffer - (dolist (type ,invisible-types) - (remove-overlays (point-min) (point-max) 'invisible type)) - (pcase-dolist (`(,beg ,end ,type) (delq nil ,data)) - (org-flag-region beg end t type) - (when ,markers? - (set-marker beg nil) - (set-marker end nil)))))))) +(defalias 'org-save-outline-visibility #'org-fold-save-outline-visibility) (defmacro org-with-wide-buffer (&rest body) "Execute body while temporarily widening the buffer." diff --git a/lisp/org-mobile.el b/lisp/org-mobile.el index 5cfaa7fe0a..dd53333999 100644 --- a/lisp/org-mobile.el +++ b/lisp/org-mobile.el @@ -1064,7 +1064,7 @@ be returned that indicates what went wrong." (progn ;; Workaround a `org-insert-heading-respect-content' bug ;; which prevents correct insertion when point is invisible - (org-show-subtree) + (org-fold-show-subtree) (end-of-line 1) (org-insert-heading-respect-content t) (org-demote)) diff --git a/lisp/org-mouse.el b/lisp/org-mouse.el index 2d8136b752..912efb7705 100644 --- a/lisp/org-mouse.el +++ b/lisp/org-mouse.el @@ -1007,10 +1007,10 @@ This means, between the beginning of line and the point." (with-current-buffer buffer (widen) (goto-char pos) - (org-show-hidden-entry) + (org-fold-show-hidden-entry) (save-excursion (and (outline-next-heading) - (org-flag-heading nil))) ; show the next heading + (org-fold-heading nil))) ; show the next heading (org-back-to-heading) (setq marker (point-marker)) (goto-char (max (point-at-bol) (- (point-at-eol) anticol))) diff --git a/lisp/org-refile.el b/lisp/org-refile.el index 5ad73422ef..6f2b019ad6 100644 --- a/lisp/org-refile.el +++ b/lisp/org-refile.el @@ -521,7 +521,7 @@ prefix argument (`C-u C-u C-u C-c C-w')." (goto-char (cond (pos) ((org-notes-order-reversed-p) (point-min)) (t (point-max)))) - (org-show-context 'org-goto)) + (org-fold-show-context 'org-goto)) (if regionp (progn (org-kill-new (buffer-substring region-start region-end)) diff --git a/lisp/org-src.el b/lisp/org-src.el index 663ccb334e..cc49181618 100644 --- a/lisp/org-src.el +++ b/lisp/org-src.el @@ -1358,8 +1358,10 @@ EVENT is passed to `mouse-set-point'." (goto-char beg) (cond ;; Block is hidden; move at start of block. - ((cl-some (lambda (o) (eq (overlay-get o 'invisible) 'org-hide-block)) - (overlays-at (point))) + ((if (eq org-fold-core-style 'text-properties) + (org-fold-folded-p nil 'block) + (cl-some (lambda (o) (eq (overlay-get o 'invisible) 'org-hide-block)) + (overlays-at (point)))) (beginning-of-line 0)) (write-back (org-src--goto-coordinates coordinates beg end)))) ;; Clean up left-over markers and restore window configuration. diff --git a/lisp/org-timer.el b/lisp/org-timer.el index a6f3648fad..0c9350e76a 100644 --- a/lisp/org-timer.el +++ b/lisp/org-timer.el @@ -478,7 +478,7 @@ Try to use an Org header, otherwise use the buffer name." (with-current-buffer (marker-buffer marker) (org-with-wide-buffer (goto-char hdmarker) - (org-show-entry) + (org-fold-show-entry) (or (ignore-errors (org-get-heading)) (buffer-name (buffer-base-buffer)))))))) ((derived-mode-p 'org-mode) diff --git a/lisp/org.el b/lisp/org.el index 4ad5dc5a54..c02508738c 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -96,6 +96,9 @@ (require 'ol) (require 'oc) (require 'org-table) +(require 'org-fold) + +(require 'org-cycle) ;; `org-outline-regexp' ought to be a defconst but is let-bound in ;; some places -- e.g. see the macro `org-with-limited-levels'. @@ -4670,7 +4673,7 @@ The following commands are available: t)) (when org-startup-with-inline-images (org-display-inline-images)) (when org-startup-with-latex-preview (org-latex-preview '(16))) - (unless org-inhibit-startup-visibility-stuff (org-set-startup-visibility)) + (unless org-inhibit-startup-visibility-stuff (org-cycle-set-startup-visibility)) (when org-startup-truncated (setq truncate-lines t)) (when org-startup-numerated (require 'org-num) (org-num-mode 1)) (when org-startup-indented (require 'org-indent) (org-indent-mode 1)))) @@ -5865,7 +5868,7 @@ frame is not changed." (pop-to-buffer ibuf)) (t (error "Invalid value"))) (narrow-to-region beg end) - (org-show-all '(headings drawers blocks)) + (org-fold-show-all '(headings drawers blocks)) (goto-char pos) (run-hook-with-args 'org-cycle-hook 'all) (and (window-live-p cwin) (select-window cwin)))) @@ -5977,10 +5980,15 @@ unconditionally." ;; When INVISIBLE-OK is non-nil, ensure newly created headline ;; is visible. (unless invisible-ok - (pcase (get-char-property-and-overlay (point) 'invisible) - (`(outline . ,o) - (move-overlay o (overlay-start o) (line-end-position 0))) - (_ nil)))) + (if (eq org-fold-core-style 'text-properties) + (cond + ((org-fold-folded-p (line-beginning-position) 'headline) + (org-fold-region (line-end-position 0) (line-end-position) nil 'headline)) + (t nil)) + (pcase (get-char-property-and-overlay (point) 'invisible) + (`(outline . ,o) + (move-overlay o (overlay-start o) (line-end-position 0))) + (_ nil))))) ;; At a headline... ((org-at-heading-p) (cond ((bolp) @@ -6522,7 +6530,7 @@ case." (goto-char (point-min)) ;; First check if there are no even levels (when (re-search-forward "^\\(\\*\\*\\)+ " nil t) - (org-show-set-visibility 'canonical) + (org-fold-show-set-visibility 'canonical) (error "Not all levels are odd in this file. Conversion not possible")) (when (yes-or-no-p "Are you sure you want to globally change levels to odd-even? ") (let ((outline-regexp org-outline-regexp) @@ -6615,9 +6623,9 @@ case." (setq txt (buffer-substring beg end)) (org-save-markers-in-region beg end) (delete-region beg end) - (org-remove-empty-overlays-at beg) - (unless (= beg (point-min)) (org-flag-region (1- beg) beg nil 'outline)) - (unless (bobp) (org-flag-region (1- (point)) (point) nil 'outline)) + (when (eq org-fold-core-style 'overlays) (org-remove-empty-overlays-at beg)) + (unless (= beg (point-min)) (org-fold-region (1- beg) beg nil 'outline)) + (unless (bobp) (org-fold-region (1- (point)) (point) nil 'outline)) (and (not (bolp)) (looking-at "\n") (forward-char 1)) (let ((bbb (point))) (insert-before-markers txt) @@ -6628,9 +6636,9 @@ case." (org-skip-whitespace) (move-marker ins-point nil) (if folded - (org-flag-subtree t) - (org-show-entry) - (org-show-children)) + (org-fold-subtree t) + (org-fold-show-entry) + (org-fold-show-children)) (org-clean-visibility-after-subtree-move) ;; move back to the initial column we were at (move-to-column col)))) @@ -6988,7 +6996,7 @@ with the original repeater." (insert template) (org-mode) (goto-char (point-min)) - (org-show-subtree) + (org-fold-show-subtree) (and idprop (if org-clone-delete-id (org-entry-delete nil "ID") (org-id-get-create t))) @@ -7260,7 +7268,7 @@ function is being called interactively." (point)) what "children") (goto-char start) - (outline-show-subtree) + (org-fold-show-subtree) (outline-next-heading)) (t ;; we will sort the top-level entries in this file @@ -7276,7 +7284,7 @@ function is being called interactively." (setq end (point-max)) (setq what "top-level") (goto-char start) - (org-show-all '(headings drawers blocks)))) + (org-fold-show-all '(headings drawers blocks)))) (setq beg (point)) (when (>= beg end) (goto-char start) (user-error "Nothing to sort")) @@ -7860,7 +7868,7 @@ If the file does not exist, throw an error." (funcall (cdr (assq 'file org-link-frame-setup)) file) (widen) (cond (line (org-goto-line line) - (when (derived-mode-p 'org-mode) (org-reveal))) + (when (derived-mode-p 'org-mode) (org-fold-reveal))) (search (condition-case err (org-link-search search) ;; Save position before error-ing out so user @@ -8156,7 +8164,7 @@ or to another Org file, automatically push the old position onto the ring." (setq m (car p)) (pop-to-buffer-same-window (marker-buffer m)) (goto-char m) - (when (or (org-invisible-p) (org-invisible-p2)) (org-show-context 'mark-goto)))) + (when (or (org-invisible-p) (org-invisible-p2)) (org-fold-show-context 'mark-goto)))) ;;; Following specific links @@ -10167,7 +10175,7 @@ as well.") "Make a compact tree showing all matches of REGEXP. The tree will show the lines where the regexp matches, and any other context -defined in `org-show-context-detail', which see. +defined in `org-fold-show-context-detail', which see. When optional argument KEEP-PREVIOUS is non-nil, highlighting and exposing done by a previous call to `org-occur' will be kept, to allow stacking of @@ -10189,7 +10197,7 @@ The function must neither move point nor alter narrowing." (when (or (not keep-previous) ; do not want to keep (not org-occur-highlights)) ; no previous matches ;; hide everything - (org-overview)) + (org-cycle-overview)) (let ((case-fold-search (if (eq org-occur-case-fold-search 'smart) (isearch-no-upper-case-p regexp t) org-occur-case-fold-search))) @@ -10199,12 +10207,12 @@ The function must neither move point nor alter narrowing." (setq cnt (1+ cnt)) (when org-highlight-sparse-tree-matches (org-highlight-new-match (match-beginning 0) (match-end 0))) - (org-show-context 'occur-tree))))) + (org-fold-show-context 'occur-tree))))) (when org-remove-highlights-with-change (add-hook 'before-change-functions 'org-remove-occur-highlights nil 'local)) (unless org-sparse-tree-open-archived-trees - (org-hide-archived-subtrees (point-min) (point-max))) + (org-fold-hide-archived-subtrees (point-min) (point-max))) (run-hooks 'org-occur-hook) (when (called-interactively-p 'interactive) (message "%d match(es) for regexp %s" cnt regexp)) @@ -10488,7 +10496,7 @@ headlines matching this string." (save-excursion (goto-char (point-min)) (when (eq action 'sparse-tree) - (org-overview) + (org-cycle-overview) (org-remove-occur-highlights)) (if (org-element--cache-active-p) (let ((fast-re (concat "^" @@ -10537,7 +10545,7 @@ headlines matching this string." (org-get-heading) (match-end 0) (org-highlight-new-match (match-beginning 1) (match-end 1))) - (org-show-context 'tags-tree)) + (org-fold-show-context 'tags-tree)) ((eq action 'agenda) (let* ((effort (org-entry-get (point) org-effort-property)) (effort-minutes (when effort (save-match-data (org-duration-to-minutes effort))))) @@ -10663,7 +10671,7 @@ headlines matching this string." (org-get-heading) (match-end 0) (org-highlight-new-match (match-beginning 1) (match-end 1))) - (org-show-context 'tags-tree)) + (org-fold-show-context 'tags-tree)) ((eq action 'agenda) (setq txt (org-agenda-format-item "" @@ -10701,7 +10709,7 @@ headlines matching this string." (and (= (point) lspos) (end-of-line 1)))))) (when (and (eq action 'sparse-tree) (not org-sparse-tree-open-archived-trees)) - (org-hide-archived-subtrees (point-min) (point-max))) + (org-fold-hide-archived-subtrees (point-min) (point-max))) (nreverse rtn))) (defun org-remove-uninherited-tags (tags) @@ -12549,7 +12557,7 @@ drawer is immediately hidden." (inhibit-read-only t)) (unless (bobp) (insert "\n")) (insert ":PROPERTIES:\n:END:") - (org-flag-region (line-end-position 0) (point) t 'outline) + (org-fold-region (line-end-position 0) (point) t (if (eq org-fold-core-style 'text-properties) 'drawer 'outline)) (when (or (eobp) (= begin (point-min))) (insert "\n")) (org-indent-region begin (point)))))) @@ -14392,7 +14400,7 @@ When SUPPRESS-TMP-DELAY is non-nil, suppress delays like (message "No clock to adjust") (save-excursion (org-goto-marker-or-bmk clfixpos) - (org-show-subtree) + (org-fold-show-subtree) (when (re-search-forward clrgx nil t) (goto-char (match-beginning 1)) (let (org-clock-adjust-closest) @@ -15894,7 +15902,7 @@ either not currently on a tagged headline or on a tag." If the cursor is in a table looking at whitespace, the whitespace is overwritten, and the table is not marked as requiring realignment." (interactive "p") - (org-check-before-invisible-edit 'insert) + (org-fold-check-before-invisible-edit 'insert) (cond ((and org-use-speed-commands (let ((kv (this-command-keys-vector))) @@ -15964,7 +15972,7 @@ still be marked for re-alignment if the field did fill the entire column, because, in this case the deletion might narrow the column." (interactive "p") (save-match-data - (org-check-before-invisible-edit 'delete-backward) + (org-fold-check-before-invisible-edit 'delete-backward) (if (and (= N 1) (not overwrite-mode) (not (org-region-active-p)) @@ -15984,7 +15992,7 @@ still be marked for re-alignment if the field did fill the entire column, because, in this case the deletion might narrow the column." (interactive "p") (save-match-data - (org-check-before-invisible-edit 'delete) + (org-fold-check-before-invisible-edit 'delete) (cond ((or (/= N 1) (eq (char-after) ?|) @@ -16170,11 +16178,11 @@ When ARG is a numeric prefix, show contents of this level." ((integerp arg) (let ((arg2 (if org-odd-levels-only (1- (* 2 arg)) arg))) (message "Content view to level: %d" arg) - (org-content (prefix-numeric-value arg2)) + (org-cycle-content (prefix-numeric-value arg2)) (org-cycle-show-empty-lines t) (setq org-cycle-global-status 'overview) (run-hook-with-args 'org-cycle-hook 'overview))) - (t (call-interactively 'org-global-cycle)))) + (t (call-interactively 'org-cycle-global)))) (defun org-shiftmetaleft () "Promote subtree or delete table column. @@ -16328,14 +16336,14 @@ this function returns t, nil otherwise." (setq beg (point-at-bol)) (beginning-of-line 2) (while (and (not (eobp)) ;; this is like `next-line' - (get-char-property (1- (point)) 'invisible)) + (org-invisible-p (1- (point)))) (beginning-of-line 2)) (setq end (point)) (goto-char beg) (goto-char (point-at-eol)) (setq end (max end (point))) (while (re-search-forward re end t) - (when (get-char-property (match-beginning 0) 'invisible) + (when (org-invisible-p (match-beginning 0)) (throw 'exit t)))) nil)))) @@ -16623,11 +16631,18 @@ this numeric value." (interactive "r") (let ((result "")) (while (/= beg end) - (if (invisible-p beg) - (setq beg (next-single-char-property-change beg 'invisible nil end)) + (if (eq org-fold-core-style 'text-properties) + (progn + (while (org-invisible-p beg) + (setq beg (org-fold-next-visibility-change beg end))) + (let ((next (org-fold-next-visibility-change beg end))) + (setq result (concat result (buffer-substring beg next))) + (setq beg next))) + (when (invisible-p beg) + (setq beg (next-single-char-property-change beg 'invisible nil end))) (let ((next (next-single-char-property-change beg 'invisible nil end))) - (setq result (concat result (buffer-substring beg next))) - (setq beg next)))) + (setq result (concat result (buffer-substring beg next))) + (setq beg next)))) (setq deactivate-mark t) (kill-new result) (message "Visible strings have been copied to the kill ring."))) @@ -17001,14 +17016,14 @@ Use `\\[org-edit-special]' to edit table.el tables"))) (cond (org-finish-function (let ((org-note-abort t)) (funcall org-finish-function))) ((org-before-first-heading-p) - (org-show-branches-buffer) - (org-hide-archived-subtrees (point-min) (point-max))) + (org-fold-show-branches-buffer) + (org-fold-hide-archived-subtrees (point-min) (point-max))) (t (let ((beg (progn (org-back-to-heading) (point))) (end (save-excursion (org-end-of-subtree t t) (point)))) - (outline-hide-subtree) - (outline-show-branches) - (org-hide-archived-subtrees beg end))))) + (org-fold-hide-subtree) + (org-fold-show-branches) + (org-fold-hide-archived-subtrees beg end))))) (defun org-delete-indentation (&optional arg) "Join current line to previous and fix whitespace at join. @@ -17131,7 +17146,7 @@ object (e.g., within a comment). In these case, you need to use (org-auto-align-tags (org-align-tags)) (t (org--align-tags-here tags-column))) ;preserve tags column (end-of-line) - (org-show-entry) + (org-fold-show-entry) (org--newline indent arg interactive) (when string (save-excursion (insert (org-trim string)))))) ;; In a list, make sure indenting keeps trailing text within. @@ -17169,11 +17184,11 @@ level to hide." (call-interactively #'org-table-toggle-column-width)) ((org-before-first-heading-p) (save-excursion - (org-flag-above-first-heading) - (outline-hide-sublevels (or arg 1)))) + (org-fold-flag-above-first-heading) + (org-fold-hide-sublevels (or arg 1)))) (t - (outline-hide-subtree) - (org-show-children arg)))) + (org-fold-hide-subtree) + (org-fold-show-children arg)))) (defun org-ctrl-c-star () "Compute table, or change heading status of lines. @@ -17308,7 +17323,7 @@ Calls `org-insert-heading', `org-insert-item' or `org-table-wrap-region', depending on context. When called with an argument, unconditionally call `org-insert-heading'." (interactive "P") - (org-check-before-invisible-edit 'insert) + (org-fold-check-before-invisible-edit 'insert) (or (run-hook-with-args-until-success 'org-metareturn-hook) (call-interactively (cond (arg #'org-insert-heading) ((org-at-table-p) #'org-table-wrap-region) @@ -17328,8 +17343,8 @@ an argument, unconditionally call `org-insert-heading'." ["Cycle Visibility" org-cycle :active (or (bobp) (outline-on-heading-p))] ["Cycle Global Visibility" org-shifttab :active (not (org-at-table-p))] ["Sparse Tree..." org-sparse-tree t] - ["Reveal Context" org-reveal t] - ["Show All" org-show-all t] + ["Reveal Context" org-fold-reveal t] + ["Show All" org-fold-show-all t] "--" ["Subtree to indirect buffer" org-tree-to-indirect-buffer t]) "--" @@ -17788,7 +17803,7 @@ With prefix arg UNCOMPILED, load the uncompiled versions." (when (or (> marker (point-max)) (< marker (point-min))) (widen)) (goto-char marker) - (org-show-context 'org-goto)) + (org-fold-show-context 'org-goto)) (if bookmark (bookmark-jump bookmark) (error "Cannot find location")))) @@ -18025,7 +18040,7 @@ block from point." regexp))) (add-hook 'occur-mode-find-occurrence-hook - (lambda () (when (derived-mode-p 'org-mode) (org-reveal)))) + (lambda () (when (derived-mode-p 'org-mode) (org-fold-reveal)))) (defun org-occur-link-in-agenda-files () "Create a link and search for it in the agendas. @@ -18961,7 +18976,7 @@ Throw an error if no block is found." (cl-decf count)))) (if (= count 0) (prog1 (goto-char (org-element-property :post-affiliated last-element)) - (save-match-data (org-show-context))) + (save-match-data (org-fold-show-context))) (goto-char origin) (user-error "No %s code blocks" (if backward "previous" "further"))))) @@ -19442,7 +19457,7 @@ depending on context." ((or (not org-special-ctrl-k) (bolp) (not (org-at-heading-p))) - (when (and (get-char-property (line-end-position) 'invisible) + (when (and (org-invisible-p (line-end-position)) org-ctrl-k-protect-subtree (or (eq org-ctrl-k-protect-subtree 'error) (not (y-or-n-p "Kill hidden subtree along with headline? ")))) @@ -19530,7 +19545,7 @@ interactive command with similar behavior." (or (looking-at org-outline-regexp) (re-search-forward org-outline-regexp-bol end t)) (while (and (< (point) end) (looking-at org-outline-regexp)) - (org-flag-subtree t) + (org-fold-subtree t) (org-cycle-show-empty-lines 'folded) (condition-case nil (outline-forward-same-level 1) @@ -19587,7 +19602,7 @@ interactive command with similar behavior." (fboundp 'org-inlinetask-end-p) (org-inlinetask-end-p)) (org-inlinetask-goto-beginning) - (setq found (and (or invisible-ok (not (org-invisible-p))) + (setq found (and (or invisible-ok (not (org-fold-folded-p))) (point)))))) (goto-char found) found))) @@ -20624,9 +20639,9 @@ Started from `gnus-info-find-node'." ;;; Finish up -(add-hook 'org-mode-hook ;remove overlays when changing major mode +(add-hook 'org-mode-hook ;remove folds when changing major mode (lambda () (add-hook 'change-major-mode-hook - 'org-show-all 'append 'local))) + 'org-fold-show-all 'append 'local))) (provide 'org) diff --git a/lisp/ox-org.el b/lisp/ox-org.el index 3d3c4fe6a6..96d22d178e 100644 --- a/lisp/ox-org.el +++ b/lisp/ox-org.el @@ -329,7 +329,7 @@ Return output file name." newbuf) (with-current-buffer work-buffer (org-font-lock-ensure) - (org-show-all) + (org-fold-show-all) (setq newbuf (htmlize-buffer))) (with-current-buffer newbuf (when org-org-htmlized-css-url diff --git a/testing/lisp/test-org-list.el b/testing/lisp/test-org-list.el index e21409ca5c..a9490692ea 100644 --- a/testing/lisp/test-org-list.el +++ b/testing/lisp/test-org-list.el @@ -627,7 +627,7 @@ b. Item 2<point>" #+BEGIN_CENTER Text2 #+END_CENTER" - (org-hide-block-all) + (org-fold-hide-block-all) (let ((invisible-property-1 (progn (search-forward "Text1") diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el index 6aecc3af86..0a47618caa 100644 --- a/testing/lisp/test-org.el +++ b/testing/lisp/test-org.el @@ -3787,7 +3787,7 @@ SCHEDULED: <2017-05-06 Sat> (should-not (org-test-with-temp-text "#+BEGIN_CENTER\nContents\n#+END_CENTER" (let ((org-special-ctrl-a/e t)) - (org-hide-block-toggle) + (org-fold-hide-block-toggle) (org-end-of-line) (eobp)))) ;; Get past invisible characters at the end of line. @@ -3935,7 +3935,7 @@ SCHEDULED: <2017-05-06 Sat> (should (= 6 (org-test-with-temp-text "#+begin_center\nP1\n\nP2\n#+end_center\nP3" - (org-hide-block-toggle) + (org-fold-hide-block-toggle) (org-forward-paragraph) (org-current-line)))) ;; On an item or a footnote definition, move past the first element @@ -4055,7 +4055,7 @@ SCHEDULED: <2017-05-06 Sat> (bobp))) (should (org-test-with-temp-text "#+begin_center\nP1\n\nP2\n#+end_center\n" - (org-hide-block-toggle) + (org-fold-hide-block-toggle) (goto-char (point-max)) (org-backward-paragraph) (bobp))) @@ -8057,108 +8057,110 @@ CLOSED: %s ;;; Visibility (ert-deftest test-org/hide-drawer-toggle () - "Test `org-hide-drawer-toggle' specifications." + "Test `org-fold-hide-drawer-toggle' specifications." ;; Error when not at a drawer. (should-error (org-test-with-temp-text ":fake-drawer:\ncontents" - (org-hide-drawer-toggle 'off) + (org-fold-hide-drawer-toggle 'off) (get-char-property (line-end-position) 'invisible))) (should-error (org-test-with-temp-text "#+begin_example\n<point>:D:\nc\n:END:\n#+end_example" - (org-hide-drawer-toggle t))) + (org-fold-hide-drawer-toggle t))) ;; Hide drawer. (should (org-test-with-temp-text ":drawer:\ncontents\n:end:" - (org-hide-drawer-toggle) + (org-fold-show-all) + (org-fold-hide-drawer-toggle) (get-char-property (line-end-position) 'invisible))) ;; Show drawer unconditionally when optional argument is `off'. (should-not (org-test-with-temp-text ":drawer:\ncontents\n:end:" - (org-hide-drawer-toggle) - (org-hide-drawer-toggle 'off) + (org-fold-hide-drawer-toggle) + (org-fold-hide-drawer-toggle 'off) (get-char-property (line-end-position) 'invisible))) ;; Hide drawer unconditionally when optional argument is non-nil. (should (org-test-with-temp-text ":drawer:\ncontents\n:end:" - (org-hide-drawer-toggle t) + (org-fold-hide-drawer-toggle t) (get-char-property (line-end-position) 'invisible))) ;; Do not hide drawer when called from final blank lines. (should-not (org-test-with-temp-text ":drawer:\ncontents\n:end:\n\n<point>" - (org-hide-drawer-toggle) + (org-fold-show-all) + (org-fold-hide-drawer-toggle) (goto-char (point-min)) (get-char-property (line-end-position) 'invisible))) ;; Don't leave point in an invisible part of the buffer when hiding ;; a drawer away. (should-not (org-test-with-temp-text ":drawer:\ncontents\n<point>:end:" - (org-hide-drawer-toggle) + (org-fold-hide-drawer-toggle) (get-char-property (point) 'invisible)))) (ert-deftest test-org/hide-block-toggle () - "Test `org-hide-block-toggle' specifications." + "Test `org-fold-hide-block-toggle' specifications." ;; Error when not at a block. (should-error (org-test-with-temp-text "#+BEGIN_QUOTE\ncontents" - (org-hide-block-toggle 'off) + (org-fold-hide-block-toggle 'off) (get-char-property (line-end-position) 'invisible))) ;; Hide block. (should (org-test-with-temp-text "#+BEGIN_CENTER\ncontents\n#+END_CENTER" - (org-hide-block-toggle) + (org-fold-hide-block-toggle) (get-char-property (line-end-position) 'invisible))) (should (org-test-with-temp-text "#+BEGIN_EXAMPLE\ncontents\n#+END_EXAMPLE" - (org-hide-block-toggle) + (org-fold-hide-block-toggle) (get-char-property (line-end-position) 'invisible))) ;; Show block unconditionally when optional argument is `off'. (should-not (org-test-with-temp-text "#+BEGIN_QUOTE\ncontents\n#+END_QUOTE" - (org-hide-block-toggle) - (org-hide-block-toggle 'off) + (org-fold-hide-block-toggle) + (org-fold-hide-block-toggle 'off) (get-char-property (line-end-position) 'invisible))) (should-not (org-test-with-temp-text "#+BEGIN_QUOTE\ncontents\n#+END_QUOTE" - (org-hide-block-toggle 'off) + (org-fold-hide-block-toggle 'off) (get-char-property (line-end-position) 'invisible))) ;; Hide block unconditionally when optional argument is non-nil. (should (org-test-with-temp-text "#+BEGIN_QUOTE\ncontents\n#+END_QUOTE" - (org-hide-block-toggle t) + (org-fold-hide-block-toggle t) (get-char-property (line-end-position) 'invisible))) (should (org-test-with-temp-text "#+BEGIN_QUOTE\ncontents\n#+END_QUOTE" - (org-hide-block-toggle) - (org-hide-block-toggle t) + (org-fold-hide-block-toggle) + (org-fold-hide-block-toggle t) (get-char-property (line-end-position) 'invisible))) ;; Do not hide block when called from final blank lines. (should-not (org-test-with-temp-text "#+BEGIN_QUOTE\ncontents\n#+END_QUOTE\n\n<point>" - (org-hide-block-toggle) + (org-fold-hide-block-toggle) (goto-char (point-min)) (get-char-property (line-end-position) 'invisible))) ;; Don't leave point in an invisible part of the buffer when hiding ;; a block away. (should-not (org-test-with-temp-text "#+BEGIN_QUOTE\ncontents\n<point>#+END_QUOTE" - (org-hide-block-toggle) + (org-fold-hide-block-toggle) (get-char-property (point) 'invisible)))) (ert-deftest test-org/hide-block-toggle-maybe () - "Test `org-hide-block-toggle-maybe' specifications." + "Test `org-fold-hide-block-toggle' specifications." (should (org-test-with-temp-text "#+BEGIN: dynamic\nContents\n#+END:" - (org-hide-block-toggle-maybe))) - (should-not - (org-test-with-temp-text "Paragraph" (org-hide-block-toggle-maybe)))) + (org-hide-block-toggle))) + (should-error + (org-test-with-temp-text "Paragraph" (org-hide-block-toggle)))) (ert-deftest test-org/show-set-visibility () - "Test `org-show-set-visibility' specifications." + "Test `org-fold-show-set-visibility' specifications." ;; Do not throw an error before first heading. (should (org-test-with-temp-text "Preamble\n* Headline" - (org-show-set-visibility 'tree) + (org-fold-show-set-visibility 'tree) t)) ;; Test all visibility spans, both on headline and in entry. (let ((list-visible-lines @@ -8180,7 +8182,7 @@ CLOSED: %s " (org-cycle t) (search-forward (if headerp "Self" "Match")) - (org-show-set-visibility state) + (org-fold-show-set-visibility state) (goto-char (point-min)) (let (result (line 0)) (while (not (eobp)) @@ -8211,24 +8213,24 @@ CLOSED: %s ;; visible. (should-not (org-test-with-temp-text "#+BEGIN_QUOTE\nText\n#+END_QUOTE" - (org-hide-block-toggle) + (org-fold-hide-block-toggle) (search-forward "Text") - (org-show-set-visibility 'minimal) + (org-fold-show-set-visibility 'minimal) (org-invisible-p2))) (should-not (org-test-with-temp-text ":DRAWER:\nText\n:END:" - (org-hide-drawer-toggle) + (org-fold-hide-drawer-toggle) (search-forward "Text") - (org-show-set-visibility 'minimal) + (org-fold-show-set-visibility 'minimal) (org-invisible-p2))) (should-not (org-test-with-temp-text "#+BEGIN_QUOTE\n<point>:DRAWER:\nText\n:END:\n#+END_QUOTE" - (org-hide-drawer-toggle) + (org-fold-hide-drawer-toggle) (forward-line -1) - (org-hide-block-toggle) + (org-fold-hide-block-toggle) (search-forward "Text") - (org-show-set-visibility 'minimal) + (org-fold-show-set-visibility 'minimal) (org-invisible-p2)))) (ert-deftest test-org/copy-visible ()