Sfoglia il codice sorgente

org-fold-check-before-invisible-edit: Be smart about editing at border

*
lisp/org-fold.el (org-fold-check-before-invisible-edit--text-properties):
Consider `border-and-ok-direction' value when deciding whether to
throw an error and reveal the fold.  Never throw an error when editing
at border without affecting the text inside.

Fixes https://orgmode.org/list/m2ilqle995.fsf@gmail.com
Ihor Radchenko 3 anni fa
parent
commit
d2a459d259
1 ha cambiato i file con 10 aggiunte e 5 eliminazioni
  1. 10 5
      lisp/org-fold.el

+ 10 - 5
lisp/org-fold.el

@@ -1125,16 +1125,18 @@ The detailed reaction depends on the user option
 	     (and (not invisible-at-point) invisible-before-point
 		  (memq kind '(insert delete))))))
       (when (or invisible-at-point invisible-before-point)
-	(when (eq org-fold-catch-invisible-edits 'error)
+	(when (and (eq org-fold-catch-invisible-edits 'error)
+                   (not border-and-ok-direction))
 	  (user-error "Editing in invisible areas is prohibited, make them visible first"))
 	(if (and org-custom-properties-overlays
 		 (y-or-n-p "Display invisible properties in this buffer? "))
 	    (org-toggle-custom-properties-visibility)
 	  ;; Make the area visible
-          (save-excursion
-	    (org-fold-show-set-visibility 'local))
-          (when invisible-before-point
-            (org-with-point-at (1- (point)) (org-fold-show-set-visibility 'local)))
+          (unless (eq org-fold-catch-invisible-edits 'error)
+            (save-excursion
+	      (org-fold-show-set-visibility 'local))
+            (when invisible-before-point
+              (org-with-point-at (1- (point)) (org-fold-show-set-visibility 'local))))
 	  (cond
 	   ((eq org-fold-catch-invisible-edits 'show)
 	    ;; That's it, we do the edit after showing
@@ -1144,6 +1146,9 @@ The detailed reaction depends on the user option
 	   ((and (eq org-fold-catch-invisible-edits 'smart)
 		 border-and-ok-direction)
 	    (message "Unfolding invisible region around point before editing"))
+           (border-and-ok-direction
+            ;; Just continue editing.
+            nil)
 	   (t
 	    ;; Don't do the edit, make the user repeat it in full visibility
 	    (user-error "Edit in invisible region aborted, repeat to confirm with text visible"))))))))