[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#10856: 24.0.93; hs-hide-block changes cursor column when collapsing
From: |
John Yates |
Subject: |
bug#10856: 24.0.93; hs-hide-block changes cursor column when collapsing a comment |
Date: |
Mon, 20 Feb 2012 09:02:25 -0500 |
When hs-show-block reveals a collapsed comment block it preserves the
position of the cursor. This honors the "principle of least
astonishment". By contrast when hs-hide-block collapses a comment
block it moves the cursor to the comment's left boundary. This is
unexpected and a jarring asymmetry w.r.t. hs-show-block.
The following patch maintain the cursor column whenever possible:
--- cur/hideshow.el
+++ fix/hideshow.el
@@ -552,11 +552,13 @@
(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))))))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- bug#10856: 24.0.93; hs-hide-block changes cursor column when collapsing a comment,
John Yates <=