GNU bug report logs - #10856
24.0.93; hs-hide-block changes cursor column when collapsing a comment

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Reported by: John Yates <john@HIDDEN>; dated Mon, 20 Feb 2012 14:05:04 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 20 Feb 2012 14:04:56 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Feb 20 09:04:56 2012
Received: from localhost ([127.0.0.1]:47034 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.72)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1RzTrL-0008HR-O7
	for submit <at> debbugs.gnu.org; Mon, 20 Feb 2012 09:04:56 -0500
Received: from eggs.gnu.org ([140.186.70.92]:35152)
	by debbugs.gnu.org with esmtp (Exim 4.72)
	(envelope-from <john.yates.sheets@HIDDEN>) id 1RzTrJ-0008HE-M4
	for submit <at> debbugs.gnu.org; Mon, 20 Feb 2012 09:04:54 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <john.yates.sheets@HIDDEN>) id 1RzTp6-0003Dm-NT
	for submit <at> debbugs.gnu.org; Mon, 20 Feb 2012 09:02:37 -0500
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM,
	RCVD_IN_DNSWL_LOW,T_DKIM_INVALID autolearn=unavailable version=3.3.2
Received: from lists.gnu.org ([140.186.70.17]:33991)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <john.yates.sheets@HIDDEN>) id 1RzTp6-0003Di-Lz
	for submit <at> debbugs.gnu.org; Mon, 20 Feb 2012 09:02:36 -0500
Received: from eggs.gnu.org ([140.186.70.92]:33765)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <john.yates.sheets@HIDDEN>) id 1RzTox-0007ny-9e
	for bug-gnu-emacs@HIDDEN; Mon, 20 Feb 2012 09:02:36 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <john.yates.sheets@HIDDEN>) id 1RzTow-0003Cf-C5
	for bug-gnu-emacs@HIDDEN; Mon, 20 Feb 2012 09:02:27 -0500
Received: from mail-gy0-f169.google.com ([209.85.160.169]:62432)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <john.yates.sheets@HIDDEN>) id 1RzTov-0003Bm-Uv
	for bug-gnu-emacs@HIDDEN; Mon, 20 Feb 2012 09:02:26 -0500
Received: by ghrr18 with SMTP id r18so3072487ghr.0
	for <bug-gnu-emacs@HIDDEN>; Mon, 20 Feb 2012 06:02:25 -0800 (PST)
Received-SPF: pass (google.com: domain of john.yates.sheets@HIDDEN
	designates 10.50.153.198 as permitted sender)
	client-ip=10.50.153.198; 
Authentication-Results: mr.google.com; spf=pass (google.com: domain of
	john.yates.sheets@HIDDEN designates 10.50.153.198 as
	permitted sender) smtp.mail=john.yates.sheets@HIDDEN;
	dkim=pass header.i=john.yates.sheets@HIDDEN
Received: from mr.google.com ([10.50.153.198])
	by 10.50.153.198 with SMTP id vi6mr12676058igb.30.1329746545417
	(num_hops = 1); Mon, 20 Feb 2012 06:02:25 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;
	h=mime-version:sender:date:x-google-sender-auth:message-id:subject
	:from:to:content-type:content-transfer-encoding;
	bh=qKxIAaiFwvmiI1gUAPaokLK23hwfkBN0FKgLmh3H6BI=;
	b=MezeJqn5VLQzoDvD52Ti1uVUqnzNSboKb+K4OEXmVLp7LvIjczUQPPxNNYhOm5Isq+
	jv7Jl7UT6O8SVSOrhdYRzGtL7R+ukbYSxJxej72m/pWGbnRn0/2pOAhifGqEYRft4IgF
	F14UvRIn3rUjKgQ0vJ9kXIs+CynmFOt5KhhVM=
MIME-Version: 1.0
Received: by 10.50.153.198 with SMTP id vi6mr10258616igb.30.1329746545212;
	Mon, 20 Feb 2012 06:02:25 -0800 (PST)
Received: by 10.231.133.199 with HTTP; Mon, 20 Feb 2012 06:02:25 -0800 (PST)
Date: Mon, 20 Feb 2012 09:02:25 -0500
X-Google-Sender-Auth: Oiry9vTL6yCm0EBTeIrFfAUs-7s
Message-ID: <CAJnXXohay2Q-LGt+VWoSXPeo=3VkNiofSmoqLBDH_GTJU-qHzA@HIDDEN>
Subject: 24.0.93; hs-hide-block changes cursor column when collapsing a comment
From: John Yates <john@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3)
X-Received-From: 140.186.70.17
X-Spam-Score: -3.4 (---)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.13
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -3.4 (---)

When hs-show-block reveals a collapsed comment block it preserves the
position of the cursor. =A0This 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))))))




Acknowledgement sent to John Yates <john@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#10856; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Fri, 31 Oct 2014 17:00:04 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.