]> git.eshelyaron.com Git - emacs.git/commitdiff
Backport: Rectify allout-widgets region undecoration so item at start is not missed.
authorKen Manheimer <ken.manheimer@gmail.com>
Sun, 5 Jul 2020 20:38:13 +0000 (16:38 -0400)
committerKen Manheimer <ken.manheimer@gmail.com>
Mon, 20 Jul 2020 18:31:27 +0000 (14:31 -0400)
* lisp/allout-widgets.el (allout-widgets-undecorate-region):
Reorganize the loop so an item at the start is not skipped.

(cherry picked from commit 33d85cb768b40794bffcd9ab22fbdec1211a74e5)

lisp/allout-widgets.el

index 5460551106b290b4f38e16915f6f523fed0d7f73..2a8dced5e9cdf8f0213eaf88b75e3491c3401a6d 100644 (file)
@@ -2060,19 +2060,22 @@ Optional FORCE means force reassignment of the region property."
 ;;;_   > allout-widgets-undecorate-region (start end)
 (defun allout-widgets-undecorate-region (start end)
   "Eliminate widgets and decorations for all items in region from START to END."
-  (let ((next start)
-        widget)
+  (let (done next widget
+        (end (or end (point-max))))
     (save-excursion
       (goto-char start)
-      (while (<  (setq next (next-single-char-property-change next
-                                                              'display
-                                                              (current-buffer)
-                                                              end))
-                 end)
-        (goto-char next)
-        (when (setq widget (allout-get-item-widget))
-          ;; if the next-property/overly progression got us to a widget:
-          (allout-widgets-undecorate-item widget t))))))
+      (while (not done)
+        (when (and (allout-on-current-heading-p)
+                   (setq widget (allout-get-item-widget)))
+            (if widget
+                (allout-widgets-undecorate-item widget t)))
+        (goto-char (setq next
+                         (next-single-char-property-change (point)
+                                                           'display
+                                                           (current-buffer)
+                                                           end)))
+        (if (>= next end)
+            (setq done t))))))
 ;;;_   > allout-widgets-undecorate-text (text)
 (defun allout-widgets-undecorate-text (text)
   "Eliminate widgets and decorations for all items in TEXT."