aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Yates2019-10-03 18:55:35 +0200
committerLars Ingebrigtsen2019-10-03 18:55:35 +0200
commitf12fcdf4cd878b7b3f1221c5818fe221cb339724 (patch)
treeb9ed505faef7c4c1755d5fd7c1bdb8a53b2d51d8
parentbbbced061fbd335da162fbeb023476765b2d9f55 (diff)
downloademacs-f12fcdf4cd878b7b3f1221c5818fe221cb339724.tar.gz
emacs-f12fcdf4cd878b7b3f1221c5818fe221cb339724.zip
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
-rw-r--r--lisp/progmodes/hideshow.el8
1 files changed, 5 insertions, 3 deletions
diff --git a/lisp/progmodes/hideshow.el b/lisp/progmodes/hideshow.el
index 0fb5c555125..c4c75a6c040 100644
--- a/lisp/progmodes/hideshow.el
+++ b/lisp/progmodes/hideshow.el
@@ -551,11 +551,13 @@ Original match data is restored upon return."
551(defun hs-hide-comment-region (beg end &optional repos-end) 551(defun hs-hide-comment-region (beg end &optional repos-end)
552 "Hide a region from BEG to END, marking it as a comment. 552 "Hide a region from BEG to END, marking it as a comment.
553Optional arg REPOS-END means reposition at end." 553Optional arg REPOS-END means reposition at end."
554 (let ((beg-eol (progn (goto-char beg) (line-end-position))) 554 (let ((goal-col (current-column))
555 (beg-bol (progn (goto-char beg) (line-beginning-position)))
556 (beg-eol (line-end-position))
555 (end-eol (progn (goto-char end) (line-end-position)))) 557 (end-eol (progn (goto-char end) (line-end-position))))
556 (hs-discard-overlays beg-eol end-eol) 558 (hs-discard-overlays beg-eol end-eol)
557 (hs-make-overlay beg-eol end-eol 'comment beg end)) 559 (hs-make-overlay beg-eol end-eol 'comment beg end)
558 (goto-char (if repos-end end beg))) 560 (goto-char (if repos-end end (min end (+ beg-bol goal-col))))))
559 561
560(defun hs-hide-block-at-point (&optional end comment-reg) 562(defun hs-hide-block-at-point (&optional end comment-reg)
561 "Hide block if on block beginning. 563 "Hide block if on block beginning.