From 3bcfed071deca0e9c5e8dd298b28bfd5903c6f9a Mon Sep 17 00:00:00 2001 From: Kaushal Modi Date: Wed, 14 Jun 2017 11:20:05 -0400 Subject: [PATCH] Fix breakage due to outline-invisible-p defn change in emacs 26+ * lisp/org.el (org-invisible-p): New function. Restore the behavior of outline-invisible-p prior to the following commint on emacs master . * lisp/org.el (org-cycle-internal-local) (org-clean-visibility-after-subtree-move, org-goto) (org-get-location, org-move-subtree-down, org-copy-subtree) (org-paste-subtree, org-next-link, org-mark-ring-goto) (org-todo, org-deadline, org-schedule, org-set-tags) (org-truely-invisible-p, org-invisible-p2) (org-forward-heading-same-level, org-forward-paragraph) (org-backward-paragraph, org-down-element) (org-bookmark-jump-unhide, org-mark-jump-unhide): * lisp/org-list.el (org-insert-item): * lisp/org-crypt.el (org-encrypt-entry, org-decrypt-entry): * lisp/org-clock.el (org-clock-load): * lisp/org-archive.el (org-archive-subtree) (org-archive-to-archive-sibling, org-toggle-archive-tag) (org-archive-set-tag): * contrib/lisp/org-drill.el (org-drill-hide-subheadings-if): Use org-invisible-p instead of outline-invisible-p. Reference: --- contrib/lisp/org-drill.el | 4 +-- lisp/org-archive.el | 30 +++++++++--------- lisp/org-clock.el | 2 +- lisp/org-crypt.el | 4 +-- lisp/org-list.el | 4 +-- lisp/org.el | 65 ++++++++++++++++++++++----------------- 6 files changed, 59 insertions(+), 50 deletions(-) diff --git a/contrib/lisp/org-drill.el b/contrib/lisp/org-drill.el index a78b8068c..fb578ab86 100644 --- a/contrib/lisp/org-drill.el +++ b/contrib/lisp/org-drill.el @@ -1455,7 +1455,7 @@ How well did you do? %s" ;; (save-excursion ;; (org-map-entries ;; (lambda () -;; (when (and (not (outline-invisible-p)) +;; (when (and (not (org-invisible-p)) ;; (> (org-current-level) drill-entry-level)) ;; (setq drill-heading (org-get-heading t)) ;; (unless (and (= (org-current-level) (1+ drill-entry-level)) @@ -1480,7 +1480,7 @@ the current topic." (save-excursion (org-map-entries (lambda () - (when (and (not (outline-invisible-p)) + (when (and (not (org-invisible-p)) (> (org-current-level) drill-entry-level)) (when (or (/= (org-current-level) (1+ drill-entry-level)) (funcall test)) diff --git a/lisp/org-archive.el b/lisp/org-archive.el index 4ce81aabe..ce1f35df3 100644 --- a/lisp/org-archive.el +++ b/lisp/org-archive.el @@ -204,17 +204,19 @@ if LOCATION is not given, the value of `org-archive-location' is used." ;;;###autoload (defun org-archive-subtree (&optional find-done) "Move the current subtree to the archive. -The archive can be a certain top-level heading in the current file, or in -a different file. The tree will be moved to that location, the subtree -heading be marked DONE, and the current time will be added. +The archive can be a certain top-level heading in the current +file, or in a different file. The tree will be moved to that +location, the subtree heading be marked DONE, and the current +time will be added. -When called with a single prefix argument FIND-DONE, find whole trees without any -open TODO items and archive them (after getting confirmation from the user). -When called with a double prefix argument, find whole trees with timestamps before -today and archive them (after getting confirmation from the user). -If the cursor is not at a headline when these commands are called, try all level -1 trees. If the cursor is on a headline, only try the direct children of -this heading." +When called with a single prefix argument FIND-DONE, find whole +trees without any open TODO items and archive them (after getting +confirmation from the user). When called with a double prefix +argument, find whole trees with timestamps before today and +archive them (after getting confirmation from the user). If the +cursor is not at a headline when these commands are called, try +all level 1 trees. If the cursor is on a headline, only try the +direct children of this heading." (interactive "P") (if (and (org-region-active-p) org-loop-over-headlines-in-active-region) (let ((cl (if (eq org-loop-over-headlines-in-active-region 'start-level) @@ -224,7 +226,7 @@ this heading." `(progn (setq org-map-continue-from (progn (org-back-to-heading) (point))) (org-archive-subtree ,find-done)) org-loop-over-headlines-in-active-region - cl (if (outline-invisible-p) (org-end-of-subtree nil t)))) + cl (if (org-invisible-p) (org-end-of-subtree nil t)))) (cond ((equal find-done '(4)) (org-archive-all-done)) ((equal find-done '(16)) (org-archive-all-old)) @@ -416,7 +418,7 @@ Archiving time is retained in the ARCHIVE_TIME node property." (when (org-at-heading-p) (org-archive-to-archive-sibling))) org-loop-over-headlines-in-active-region - cl (if (outline-invisible-p) (org-end-of-subtree nil t)))) + cl (if (org-invisible-p) (org-end-of-subtree nil t)))) (save-restriction (widen) (let (b e pos leader level) @@ -564,7 +566,7 @@ the children that do not contain any open TODO items." (org-map-entries `(org-toggle-archive-tag ,find-done) org-loop-over-headlines-in-active-region - cl (if (outline-invisible-p) (org-end-of-subtree nil t)))) + cl (if (org-invisible-p) (org-end-of-subtree nil t)))) (if find-done (org-archive-all-done 'tag) (let (set) @@ -585,7 +587,7 @@ the children that do not contain any open TODO items." (org-map-entries 'org-archive-set-tag org-loop-over-headlines-in-active-region - cl (if (outline-invisible-p) (org-end-of-subtree nil t)))) + cl (if (org-invisible-p) (org-end-of-subtree nil t)))) (org-toggle-tag org-archive-tag 'on))) ;;;###autoload diff --git a/lisp/org-clock.el b/lisp/org-clock.el index b8fa71b50..9ca98b0e1 100644 --- a/lisp/org-clock.el +++ b/lisp/org-clock.el @@ -2964,7 +2964,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 (outline-invisible-p) (org-show-context)))))) + (when (org-invisible-p) (org-show-context)))))) (_ nil))))) ;; Suggested bindings diff --git a/lisp/org-crypt.el b/lisp/org-crypt.el index 4439c947c..3c431e4fd 100644 --- a/lisp/org-crypt.el +++ b/lisp/org-crypt.el @@ -176,7 +176,7 @@ See `org-crypt-disable-auto-save'." (let ((start-heading (point))) (org-end-of-meta-data) (unless (looking-at-p "-----BEGIN PGP MESSAGE-----") - (let ((folded (outline-invisible-p)) + (let ((folded (org-invisible-p)) (crypt-key (org-crypt-key-for-heading)) (beg (point))) (goto-char start-heading) @@ -204,7 +204,7 @@ See `org-crypt-disable-auto-save'." (heading-was-invisible-p (save-excursion (outline-end-of-heading) - (outline-invisible-p)))) + (org-invisible-p)))) (org-end-of-meta-data) (when (looking-at "-----BEGIN PGP MESSAGE-----") (org-crypt-check-auto-save) diff --git a/lisp/org-list.el b/lisp/org-list.el index ec5c016bd..a3e26256f 100644 --- a/lisp/org-list.el +++ b/lisp/org-list.el @@ -154,8 +154,8 @@ (declare-function org-timer-item "org-timer" (&optional arg)) (declare-function org-trim "org" (s &optional keep-lead)) (declare-function org-uniquify "org" (list)) +(declare-function org-invisible-p "org" (&optional pos)) (declare-function outline-flag-region "outline" (from to flag)) -(declare-function outline-invisible-p "outline" (&optional pos)) (declare-function outline-next-heading "outline" ()) (declare-function outline-previous-heading "outline" ()) @@ -2256,7 +2256,7 @@ item is invisible." (unless (or (not itemp) (save-excursion (goto-char itemp) - (outline-invisible-p))) + (org-invisible-p))) (if (save-excursion (goto-char itemp) (org-at-item-timer-p)) diff --git a/lisp/org.el b/lisp/org.el index f4d06bc70..c4eaf45dd 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -6983,6 +6983,11 @@ Use `\\[org-edit-special]' to edit table.el tables")) (defvar org-called-with-limited-levels nil "Non-nil when `org-with-limited-levels' is currently active.") +(defun org-invisible-p (&optional pos) + "Non-nil if the character after POS is invisible. +If POS is nil, use `point' instead." + (get-char-property (or pos (point)) 'invisible)) + (defun org-cycle-internal-local () "Do the local cycling action." (let ((goal-column 0) eoh eol eos has-children children-skipped struct) @@ -7026,7 +7031,7 @@ Use `\\[org-edit-special]' to edit table.el tables")) (save-excursion (goto-char eos) (outline-next-heading) - (when (outline-invisible-p) (org-flag-heading nil)))) + (when (org-invisible-p) (org-flag-heading nil)))) ((and (or (>= eol eos) (not (string-match "\\S-" (buffer-substring eol eos)))) (or has-children @@ -7060,7 +7065,7 @@ Use `\\[org-edit-special]' to edit table.el tables")) (save-excursion (goto-char eos) (outline-next-heading) - (when (outline-invisible-p) (org-flag-heading nil))) + (when (org-invisible-p) (org-flag-heading nil))) (setq org-cycle-subtree-status 'children) (unless (org-before-first-heading-p) (run-hook-with-args 'org-cycle-hook 'children))) @@ -7234,9 +7239,9 @@ This function is the default value of the hook `org-cycle-hook'." ;; Properly fold already folded siblings (goto-char (point-min)) (while (re-search-forward re nil t) - (when (and (not (outline-invisible-p)) + (when (and (not (org-invisible-p)) (save-excursion - (goto-char (point-at-eol)) (outline-invisible-p))) + (goto-char (point-at-eol)) (org-invisible-p))) (outline-hide-entry)))) (org-cycle-show-empty-lines 'overview) (org-cycle-hide-drawers 'overview))))) @@ -7589,7 +7594,7 @@ With a prefix argument, use the alternative interface: e.g., if (progn (org-mark-ring-push org-goto-start-pos) (goto-char selected-point) - (when (or (outline-invisible-p) (org-invisible-p2)) + (when (or (org-invisible-p) (org-invisible-p2)) (org-show-context 'org-goto))) (message "Quit")))) @@ -7630,7 +7635,7 @@ or nil." (if (and (boundp 'org-goto-start-pos) (integer-or-marker-p org-goto-start-pos)) (progn (goto-char org-goto-start-pos) - (when (outline-invisible-p) + (when (org-invisible-p) (org-show-set-visibility 'lineage))) (goto-char (point-min))) (let (org-special-ctrl-a/e) (org-beginning-of-line)) @@ -8542,7 +8547,7 @@ case." (setq beg (point))) (save-match-data (save-excursion (outline-end-of-heading) - (setq folded (outline-invisible-p))) + (setq folded (org-invisible-p))) (progn (org-end-of-subtree nil t) (unless (eobp) (backward-char)))) (outline-next-heading) @@ -8638,7 +8643,7 @@ useful if the caller implements cut-and-paste as copy-then-paste-then-cut." (if nosubtrees (outline-next-heading) (save-excursion (outline-end-of-heading) - (setq folded (outline-invisible-p))) + (setq folded (org-invisible-p))) (ignore-errors (org-forward-heading-same-level (1- n) t)) (org-end-of-subtree t t))) ;; Include the end of an inlinetask @@ -8691,7 +8696,7 @@ When REMOVE is non-nil, remove the subtree from the clipboard." (substitute-command-keys "The kill is not a (set of) tree(s) - please use \\[yank] to yank anyway"))) (org-with-limited-levels - (let* ((visp (not (outline-invisible-p))) + (let* ((visp (not (org-invisible-p))) (txt tree) (^re_ "\\(\\*+\\)[ \t]*") (old-level (if (string-match org-outline-regexp-bol txt) @@ -8748,7 +8753,7 @@ When REMOVE is non-nil, remove the subtree from the clipboard." (goto-char beg) (skip-chars-forward " \t\n\r") (setq beg (point)) - (when (and (outline-invisible-p) visp) + (when (and (org-invisible-p) visp) (save-excursion (outline-show-heading))) ;; Shift if necessary (unless (= shift 0) @@ -10600,7 +10605,7 @@ If the link is in hidden text, expose it." (if (funcall srch-fun org-any-link-re nil t) (progn (goto-char (match-beginning 0)) - (when (outline-invisible-p) (org-show-context))) + (when (org-invisible-p) (org-show-context))) (goto-char pos) (setq org-link-search-failed t) (message "No further link found")))) @@ -11307,7 +11312,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 (outline-invisible-p) (org-invisible-p2)) (org-show-context 'mark-goto)))) + (when (or (org-invisible-p) (org-invisible-p2)) (org-show-context 'mark-goto)))) (defun org-add-angle-brackets (s) (unless (equal (substring s 0 1) "<") (setq s (concat "<" s))) @@ -12546,7 +12551,7 @@ When called through ELisp, arg is also interpreted in the following way: (org-map-entries `(org-todo ,arg) org-loop-over-headlines-in-active-region - cl (when (outline-invisible-p) (org-end-of-subtree nil t)))) + cl (when (org-invisible-p) (org-end-of-subtree nil t)))) (when (equal arg '(16)) (setq arg 'nextset)) (when (equal arg -1) (org-cancel-repeater) (setq arg nil)) (let ((org-blocker-hook org-blocker-hook) @@ -13457,7 +13462,7 @@ can either be an Org date like \"2011-07-24\" or a delta like \"+2d\"." (if (eq org-loop-over-headlines-in-active-region 'start-level) 'region-start-level 'region) - (lambda () (when (outline-invisible-p) (org-end-of-subtree nil t)))) + (lambda () (when (org-invisible-p) (org-end-of-subtree nil t)))) (org--deadline-or-schedule arg 'deadline time))) (defun org-schedule (arg &optional time) @@ -13474,7 +13479,7 @@ either be an Org date like \"2011-07-24\" or a delta like \"+2d\"." (if (eq org-loop-over-headlines-in-active-region 'start-level) 'region-start-level 'region) - (lambda () (when (outline-invisible-p) (org-end-of-subtree nil t)))) + (lambda () (when (org-invisible-p) (org-end-of-subtree nil t)))) (org--deadline-or-schedule arg 'scheduled time))) (defun org-get-scheduled-time (pom &optional inherit) @@ -15021,7 +15026,7 @@ When JUST-ALIGN is non-nil, only align tags." #'org-set-tags org-loop-over-headlines-in-active-region cl - '(when (outline-invisible-p) (org-end-of-subtree nil t)))) + '(when (org-invisible-p) (org-end-of-subtree nil t)))) (let ((org-setting-tags t)) (if arg (save-excursion @@ -24032,16 +24037,18 @@ interactive command with similar behavior." "Check if point is at a character currently not visible. This version does not only check the character property, but also `visible-mode'." - ;; Early versions of noutline don't have `outline-invisible-p'. (unless (bound-and-true-p visible-mode) - (outline-invisible-p))) + (org-invisible-p))) (defun org-invisible-p2 () - "Check if point is at a character currently not visible." + "Check if point is at a character currently not visible. + +If the point is at EOL (and not at the beginning of a buffer too), +move it back by one char before doing this check." (save-excursion - (when (and (eolp) (not (bobp))) (backward-char 1)) - ;; Early versions of noutline don't have `outline-invisible-p'. - (outline-invisible-p))) + (when (and (eolp) (not (bobp))) + (backward-char 1)) + (org-invisible-p))) (defun org-back-to-heading (&optional invisible-ok) "Call `outline-back-to-heading', but provide a better error message." @@ -24311,7 +24318,7 @@ non-nil it will also look at invisible ones." (cond ((< l level) (setq count 0)) ((and (= l level) (or invisible-ok - (not (outline-invisible-p + (not (org-invisible-p (line-beginning-position))))) (cl-decf count) (when (= l level) (setq result (point))))))) @@ -24447,7 +24454,7 @@ item, etc. It also provides some special moves for convenience: ;; With no contents, just skip element. ((not contents-begin) (goto-char end)) ;; If contents are invisible, skip the element altogether. - ((outline-invisible-p (line-end-position)) + ((org-invisible-p (line-end-position)) (cl-case type (headline (org-with-limited-levels (outline-next-visible-heading 1))) @@ -24534,7 +24541,7 @@ convenience: (org-backward-paragraph)) (t (goto-char (or post-affiliated begin)))) ;; Ensure we never leave point invisible. - (when (outline-invisible-p (point)) (beginning-of-visual-line)))) + (when (org-invisible-p (point)) (beginning-of-visual-line)))) (defun org-forward-element () "Move forward by one element. @@ -24611,7 +24618,7 @@ Move to the previous element at the same level, when possible." (forward-char)) ((memq (org-element-type element) org-element-greater-elements) ;; If contents are hidden, first disclose them. - (when (outline-invisible-p (line-end-position)) (org-cycle)) + (when (org-invisible-p (line-end-position)) (org-cycle)) (goto-char (or (org-element-property :contents-begin element) (user-error "No content for this element")))) (t (user-error "No inner element"))))) @@ -25092,15 +25099,15 @@ ELEMENT is the element at point." (defun org-bookmark-jump-unhide () "Unhide the current position, to show the bookmark location." (and (derived-mode-p 'org-mode) - (or (outline-invisible-p) + (or (org-invisible-p) (save-excursion (goto-char (max (point-min) (1- (point)))) - (outline-invisible-p))) + (org-invisible-p))) (org-show-context 'bookmark-jump))) (defun org-mark-jump-unhide () "Make the point visible with `org-show-context' after jumping to the mark." (when (and (derived-mode-p 'org-mode) - (outline-invisible-p)) + (org-invisible-p)) (org-show-context 'mark-goto))) (eval-after-load "simple"