diff options
author | Nicolas Goaziou <mail@nicolasgoaziou.fr> | 2017-06-29 16:29:20 +0200 |
---|---|---|
committer | Nicolas Goaziou <mail@nicolasgoaziou.fr> | 2017-06-29 16:29:20 +0200 |
commit | f409c13be16697a0ebda5d350a68e6351f5b6642 (patch) | |
tree | fcbf8e97da01be6be5eb75538df643eed45f8048 | |
parent | 582fc12d0e464e6ca4c697bf03f555e74aea5950 (diff) | |
download | org-mode-f409c13be16697a0ebda5d350a68e6351f5b6642.tar.gz |
Fix `org-check-before-invisible-edit' before first headline
* lisp/org.el (org-check-before-invisible-edit): Fix "Before first
heading" error.
Invisible characters can come from overlays and text properties. The
current implementation tries to remove outline overlays, even though
it may be something else.
Reported-by: John Kitchin <jkitchin@andrew.cmu.edu>
<http://lists.gnu.org/archive/html/emacs-orgmode/2017-06/msg00365.html>
-rw-r--r-- | lisp/org.el | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/lisp/org.el b/lisp/org.el index 96fe4eb..3a06da8 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -20195,10 +20195,16 @@ The detailed reaction depends on the user option `org-catch-invisible-edits'." (or (not (boundp 'visible-mode)) (not visible-mode)) (or (get-char-property (point) 'invisible) (get-char-property (max (point-min) (1- (point))) 'invisible))) - ;; OK, we need to take a closer look - (let* ((invisible-at-point (get-char-property (point) 'invisible)) - (invisible-before-point (unless (bobp) (get-char-property - (1- (point)) 'invisible))) + ;; OK, we need to take a closer look. Do not consider + ;; invisibility obtained through text properties (e.g., link + ;; fontification), as it cannot be toggled. + (let* ((invisible-at-point + (pcase (get-char-property-and-overlay (point) 'invisible) + (`(,value . ,(pred overlayp)) value))) + (invisible-before-point + (and (not (bobp)) + (pcase (get-char-property-and-overlay (1- (point)) 'invisible) + (`(,value . ,(pred overlayp)) value)))) (border-and-ok-direction (or ;; Check if we are acting predictably before invisible text @@ -20220,9 +20226,14 @@ The detailed reaction depends on the user option `org-catch-invisible-edits'." ;; Make the area visible (save-excursion (when invisible-before-point - (goto-char (previous-single-char-property-change - (point) 'invisible))) - (outline-show-subtree)) + (goto-char + (previous-single-char-property-change (point) 'invisible))) + ;; Remove whatever overlay is currently making yet-to-be + ;; edited text invisible. + (remove-overlays (point) + (org-end-of-subtree t t) + 'invisible + (or invisible-at-point invisible-before-point))) (cond ((eq org-catch-invisible-edits 'show) ;; That's it, we do the edit after showing |