From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Dima Kogan Newsgroups: gmane.emacs.bugs Subject: bug#8036: [PATCH] Prevent hide-show mode from getting confused by braces in comments Date: Sun, 13 Feb 2011 23:02:57 -0800 Message-ID: <20110213230257.784a9843@smart> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="MP_/FpMwibEevf+++6Yh2XCaGd5" X-Trace: dough.gmane.org 1297693993 8779 80.91.229.12 (14 Feb 2011 14:33:13 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 14 Feb 2011 14:33:13 +0000 (UTC) To: 8036@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Feb 14 15:33:09 2011 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PozU1-0001KB-72 for geb-bug-gnu-emacs@m.gmane.org; Mon, 14 Feb 2011 15:33:05 +0100 Original-Received: from localhost ([127.0.0.1]:41616 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PozTy-0006pH-0v for geb-bug-gnu-emacs@m.gmane.org; Mon, 14 Feb 2011 09:32:54 -0500 Original-Received: from [140.186.70.92] (port=35254 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PouO5-0007g9-Cm for bug-gnu-emacs@gnu.org; Mon, 14 Feb 2011 04:06:30 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PouO3-0000SE-Pb for bug-gnu-emacs@gnu.org; Mon, 14 Feb 2011 04:06:29 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:38293) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PouO3-0000S5-Lq for bug-gnu-emacs@gnu.org; Mon, 14 Feb 2011 04:06:27 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1PotwY-0006gM-Ar; Mon, 14 Feb 2011 03:38:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Dima Kogan Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 14 Feb 2011 08:38:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 8036 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.129767263825636 (code B ref -1); Mon, 14 Feb 2011 08:38:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 14 Feb 2011 08:37:18 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Potvp-0006fQ-OH for submit@debbugs.gnu.org; Mon, 14 Feb 2011 03:37:18 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PosK5-0003oI-Vh for submit@debbugs.gnu.org; Mon, 14 Feb 2011 01:54:14 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PosSj-00029j-VG for submit@debbugs.gnu.org; Mon, 14 Feb 2011 02:03:10 -0500 Original-Received: from lists.gnu.org ([199.232.76.165]:39156) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PosSj-00029f-QT for submit@debbugs.gnu.org; Mon, 14 Feb 2011 02:03:09 -0500 Original-Received: from [140.186.70.92] (port=52319 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PosSi-00069d-IX for bug-gnu-emacs@gnu.org; Mon, 14 Feb 2011 02:03:09 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PosSh-000291-HE for bug-gnu-emacs@gnu.org; Mon, 14 Feb 2011 02:03:08 -0500 Original-Received: from ibar.cds.caltech.edu ([131.215.42.49]:55646) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PosSh-00027P-5G for bug-gnu-emacs@gnu.org; Mon, 14 Feb 2011 02:03:07 -0500 Original-Received: from smart (cpe-76-175-234-46.socal.res.rr.com [76.175.234.46]) (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by ibar.cds.caltech.edu (Postfix) with ESMTP id 16DE6BA81F7 for ; Sun, 13 Feb 2011 23:03:01 -0800 (PST) X-Mailer: Claws Mail 3.7.6 (GTK+ 2.20.1; x86_64-pc-linux-gnu) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 131.215.42.49 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 199.232.76.165 X-Mailman-Approved-At: Mon, 14 Feb 2011 03:37:16 -0500 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Mon, 14 Feb 2011 03:38:02 -0500 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 140.186.70.43 X-Mailman-Approved-At: Mon, 14 Feb 2011 09:32:47 -0500 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: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:44117 Archived-At: --MP_/FpMwibEevf+++6Yh2XCaGd5 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Content-Disposition: inline Emacs bug #700 (http://debbugs.gnu.org/cgi/bugreport.cgi?bug=700) contained a patch by Dmitry Bolshakov addressing 2 issues in hide-show minor mode. The fix to one of the issues got integrated into the code base, but the other one fell through the cracks, I think. The issue it fixes is to prevent hide-show mode from parsing braces inside comments. These braces can confuse the parser, since they don't necessarily match up. I'm attaching Dmitry's test case that demonstrates the issue, and his patch to fix it. dima --MP_/FpMwibEevf+++6Yh2XCaGd5 Content-Type: application/x-perl Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename=unbalanced-braces-test.pl IyEvdXNyL2Jpbi9wZXJsCgp1c2Ugc3RyaWN0OwoKIyBsZWZ0IGJyYWNlIGluc2lkZSBjb21tZW50 cyB7IGNhdXNlIGVycm9yCnN1YiBibGFibGEgewoJZm9yIChteSAkaSA9IDA7ICRpIDwgMTA7ICRp KyspIHsKCQlwcmludGYoIlwkaSBpcyAlZFxuIiwgJGkpOwoJfQp9Cgo= --MP_/FpMwibEevf+++6Yh2XCaGd5 Content-Type: text/x-patch Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=hs.patch --- hideshow.el.original_emacs_22.2 2008-01-10 12:15:42.000000000 -0800 +++ hideshow_my.el 2008-08-12 15:39:12.000000000 -0700 @@ -541,7 +541,10 @@ (q ;; `q' is the point at the end of the block (progn (hs-forward-sexp mdata 1) - (end-of-line) + ;; see http://www.emacswiki.org/cgi-bin/wiki/HideShow and search page for "hs-block-includes-last-line" + ;(forward-line -1) + ;(end-of-line) + (backward-char 1) ; better (point))) ov) (when (and (< p (point)) (> (count-lines p q) 1)) @@ -672,10 +675,13 @@ (forward-comment (buffer-size)) (and (< (point) maxp) (re-search-forward hs-block-start-regexp maxp t))) - (if (> arg 1) - (hs-hide-level-recursive (1- arg) minp maxp) - (goto-char (match-beginning hs-block-start-mdata-select)) - (hs-hide-block-at-point t))) + (when (not (nth 4 (syntax-ppss))) ; not inside comments + (if (> arg 1) + (hs-hide-level-recursive (1- arg) minp maxp) + (goto-char (match-beginning hs-block-start-mdata-select)) + (hs-hide-block-at-point t)) + ) + ) (goto-char maxp)) (defmacro hs-life-goes-on (&rest body) --MP_/FpMwibEevf+++6Yh2XCaGd5--