emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/org 717f83bf75: org-fold--reveal-outline-maybe: Fix wro


From: ELPA Syncer
Subject: [elpa] externals/org 717f83bf75: org-fold--reveal-outline-maybe: Fix wrong side of point error
Date: Mon, 9 May 2022 08:57:55 -0400 (EDT)

branch: externals/org
commit 717f83bf75820a65da7534a29b36bbf3d918064d
Author: Ihor Radchenko <yantar92@gmail.com>
Commit: Ihor Radchenko <yantar92@gmail.com>

    org-fold--reveal-outline-maybe: Fix wrong side of point error
    
    * lisp/org-fold.el (org-fold--reveal-outline-maybe): Widen the buffer
    before testing headline validity.  Otherwise, `goto-char' may not move
    where expected in narrowed buffer.
---
 lisp/org-fold.el | 63 ++++++++++++++++++++++++++++----------------------------
 1 file changed, 32 insertions(+), 31 deletions(-)

diff --git a/lisp/org-fold.el b/lisp/org-fold.el
index 7d4bb56203..acf7c07614 100644
--- a/lisp/org-fold.el
+++ b/lisp/org-fold.el
@@ -932,37 +932,38 @@ This function is intended to be used as a member of
 This function is intended to be used as :fragile property of
 `org-fold-outline' spec.  See `org-fold-core--specs' for details."
   (save-match-data
-    (save-excursion
-      (goto-char (car region))
-      ;; The line before beginning of the fold should be either a
-      ;; headline or a list item.
-      (backward-char)
-      (beginning-of-line)
-      ;; Make sure that headline is not partially hidden
-      (unless (org-fold-folded-p nil 'headline)
-        (org-fold-region (max (point-min) (1- (point)))
-                 (let ((endl (line-end-position)))
-                   (save-excursion
-                     (goto-char endl)
-                     (skip-chars-forward "\n\t\r ")
-                     ;; Unfold blank lines.
-                     (if (or (and (looking-at-p "\\*")
-                                  (> (point) (1+ endl)))
-                             (eq (point) (point-max)))
-                         (point)
-                       endl)))
-                 nil 'headline))
-      ;; Never hide level 1 headlines
-      (save-excursion
-        (goto-char (line-end-position))
-        (when (re-search-forward (rx bol "* ") (cdr region) t)
-          (org-fold-region (match-beginning 0) (line-end-position) nil 
'headline)))
-      ;; Check the validity of headline
-      (unless (let ((case-fold-search t))
-               (looking-at (rx-to-string
-                             `(or (regex ,(org-item-re))
-                                 (regex ,org-outline-regexp-bol)))))
-       t))))
+    (org-with-wide-buffer
+     (goto-char (car region))
+     ;; The line before beginning of the fold should be either a
+     ;; headline or a list item.
+     (backward-char)
+     (beginning-of-line)
+     ;; Make sure that headline is not partially hidden
+     (unless (org-fold-folded-p nil 'headline)
+       (org-fold-region
+        (max (point-min) (1- (point)))
+        (let ((endl (line-end-position)))
+          (save-excursion
+            (goto-char endl)
+            (skip-chars-forward "\n\t\r ")
+            ;; Unfold blank lines.
+            (if (or (and (looking-at-p "\\*")
+                         (> (point) (1+ endl)))
+                    (eq (point) (point-max)))
+                (point)
+              endl)))
+        nil 'headline))
+     ;; Never hide level 1 headlines
+     (save-excursion
+       (goto-char (line-end-position))
+       (when (re-search-forward (rx bol "* ") (cdr region) t)
+         (org-fold-region (match-beginning 0) (line-end-position) nil 
'headline)))
+     ;; Check the validity of headline
+     (unless (let ((case-fold-search t))
+              (looking-at (rx-to-string
+                            `(or (regex ,(org-item-re))
+                                (regex ,org-outline-regexp-bol)))))
+       t))))
 
 (defun org-fold--reveal-drawer-or-block-maybe (region spec)
   "Reveal folded drawer/block (according to SPEC) in REGION when needed.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]