emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] master f12fcdf: Preserve point better in hs-hide-comment-r


From: Lars Ingebrigtsen
Subject: [Emacs-diffs] master f12fcdf: Preserve point better in hs-hide-comment-region
Date: Thu, 3 Oct 2019 12:55:46 -0400 (EDT)

branch: master
commit f12fcdf4cd878b7b3f1221c5818fe221cb339724
Author: John Yates <address@hidden>
Commit: Lars Ingebrigtsen <address@hidden>

    Preserve point better in hs-hide-comment-region
    
    * lisp/progmodes/hideshow.el (hs-hide-comment-region): Preserve point
    better when collapsing the region (bug#10856).
    
    Copyright-paperwork-exempt: yes
---
 lisp/progmodes/hideshow.el | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/lisp/progmodes/hideshow.el b/lisp/progmodes/hideshow.el
index 0fb5c55..c4c75a6 100644
--- a/lisp/progmodes/hideshow.el
+++ b/lisp/progmodes/hideshow.el
@@ -551,11 +551,13 @@ Original match data is restored upon return."
 (defun hs-hide-comment-region (beg end &optional repos-end)
   "Hide a region from BEG to END, marking it as a comment.
 Optional arg REPOS-END means reposition at end."
-  (let ((beg-eol (progn (goto-char beg) (line-end-position)))
+  (let ((goal-col (current-column))
+        (beg-bol (progn (goto-char beg) (line-beginning-position)))
+        (beg-eol (line-end-position))
         (end-eol (progn (goto-char end) (line-end-position))))
     (hs-discard-overlays beg-eol end-eol)
-    (hs-make-overlay beg-eol end-eol 'comment beg end))
-  (goto-char (if repos-end end beg)))
+    (hs-make-overlay beg-eol end-eol 'comment beg end)
+    (goto-char (if repos-end end (min end (+ beg-bol goal-col))))))
 
 (defun hs-hide-block-at-point (&optional end comment-reg)
   "Hide block if on block beginning.



reply via email to

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