From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: John Yates Newsgroups: gmane.emacs.bugs 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 Message-ID: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1329746599 1130 80.91.229.3 (20 Feb 2012 14:03:19 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 20 Feb 2012 14:03:19 +0000 (UTC) To: 10856@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Feb 20 15:03:17 2012 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1RzTpg-0002Ij-0n for geb-bug-gnu-emacs@m.gmane.org; Mon, 20 Feb 2012 15:03:12 +0100 Original-Received: from localhost ([::1]:58045 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RzTpf-0007wH-H6 for geb-bug-gnu-emacs@m.gmane.org; Mon, 20 Feb 2012 09:03:11 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:33885) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RzTpU-0007oq-60 for bug-gnu-emacs@gnu.org; Mon, 20 Feb 2012 09:03:09 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RzTpO-0003Ge-FV for bug-gnu-emacs@gnu.org; Mon, 20 Feb 2012 09:03:00 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:43411) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RzTpO-0003GU-DR for bug-gnu-emacs@gnu.org; Mon, 20 Feb 2012 09:02:54 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1RzTrU-0008Hp-OZ for bug-gnu-emacs@gnu.org; Mon, 20 Feb 2012 09:05:05 -0500 X-Loop: help-debbugs@gnu.org Resent-From: John Yates Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 20 Feb 2012 14:05:04 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 10856 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.132974669631836 (code B ref -1); Mon, 20 Feb 2012 14:05:04 +0000 Original-Received: (at submit) by debbugs.gnu.org; 20 Feb 2012 14:04:56 +0000 Original-Received: from localhost ([127.0.0.1]:47034 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1RzTrL-0008HR-O7 for submit@debbugs.gnu.org; Mon, 20 Feb 2012 09:04:56 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:35152) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1RzTrJ-0008HE-M4 for submit@debbugs.gnu.org; Mon, 20 Feb 2012 09:04:54 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RzTp6-0003Dm-NT for submit@debbugs.gnu.org; Mon, 20 Feb 2012 09:02:37 -0500 Original-Received: from lists.gnu.org ([140.186.70.17]:33991) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RzTp6-0003Di-Lz for submit@debbugs.gnu.org; Mon, 20 Feb 2012 09:02:36 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:33765) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RzTox-0007ny-9e for bug-gnu-emacs@gnu.org; Mon, 20 Feb 2012 09:02:36 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RzTow-0003Cf-C5 for bug-gnu-emacs@gnu.org; Mon, 20 Feb 2012 09:02:27 -0500 Original-Received: from mail-gy0-f169.google.com ([209.85.160.169]:62432) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RzTov-0003Bm-Uv for bug-gnu-emacs@gnu.org; Mon, 20 Feb 2012 09:02:26 -0500 Original-Received: by ghrr18 with SMTP id r18so3072487ghr.0 for ; Mon, 20 Feb 2012 06:02:25 -0800 (PST) Received-SPF: pass (google.com: domain of john.yates.sheets@gmail.com 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@gmail.com designates 10.50.153.198 as permitted sender) smtp.mail=john.yates.sheets@gmail.com; dkim=pass header.i=john.yates.sheets@gmail.com Original-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= Original-Received: by 10.50.153.198 with SMTP id vi6mr10258616igb.30.1329746545212; Mon, 20 Feb 2012 06:02:25 -0800 (PST) Original-Received: by 10.231.133.199 with HTTP; Mon, 20 Feb 2012 06:02:25 -0800 (PST) X-Google-Sender-Auth: Oiry9vTL6yCm0EBTeIrFfAUs-7s 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-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:57026 Archived-At: 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))))))