From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.bugs Subject: bug#9148: Make `comment-normalize-vars' more syntax-aware Date: Tue, 02 Aug 2011 16:45:48 -0400 Message-ID: References: <87ipqu5pwl.fsf@gmail.com> <87oc083xuw.fsf@gmail.com> <87bow74mrf.fsf@gmail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1312318005 19183 80.91.229.12 (2 Aug 2011 20:46:45 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 2 Aug 2011 20:46:45 +0000 (UTC) Cc: 9148@debbugs.gnu.org To: =?UTF-8?Q?=C5=A0t=C4=9Bp=C3=A1n_?= =?UTF-8?Q?N=C4=9Bmec?= Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Aug 02 22:46:40 2011 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1QoLrL-00034k-US for geb-bug-gnu-emacs@m.gmane.org; Tue, 02 Aug 2011 22:46:40 +0200 Original-Received: from localhost ([::1]:60660 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QoLrL-0002Gl-0G for geb-bug-gnu-emacs@m.gmane.org; Tue, 02 Aug 2011 16:46:39 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:49272) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QoLrH-0002GN-CP for bug-gnu-emacs@gnu.org; Tue, 02 Aug 2011 16:46:36 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QoLrF-0003dn-Nu for bug-gnu-emacs@gnu.org; Tue, 02 Aug 2011 16:46:35 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:39308) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QoLrF-0003df-Ee for bug-gnu-emacs@gnu.org; Tue, 02 Aug 2011 16:46:33 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1QoLri-0004ZU-Hh; Tue, 02 Aug 2011 16:47:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 02 Aug 2011 20:47:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 9148 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 9148-submit@debbugs.gnu.org id=B9148.131231800217541 (code B ref 9148); Tue, 02 Aug 2011 20:47:02 +0000 Original-Received: (at 9148) by debbugs.gnu.org; 2 Aug 2011 20:46:42 +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 1QoLrN-0004Yp-Ha for submit@debbugs.gnu.org; Tue, 02 Aug 2011 16:46:41 -0400 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.183] helo=ironport2-out.pppoe.ca) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QoLrL-0004Yh-Db for 9148@debbugs.gnu.org; Tue, 02 Aug 2011 16:46:40 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Av0EAOVhOE5FxKfe/2dsb2JhbABCp2d4gUABAQQBViMFCws0EhQYDSSHf8AOhkIEn0qEMQ X-IronPort-AV: E=Sophos;i="4.67,307,1309752000"; d="scan'208";a="128464327" Original-Received: from 69-196-167-222.dsl.teksavvy.com (HELO ceviche.home) ([69.196.167.222]) by ironport2-out.pppoe.ca with ESMTP/TLS/ADH-AES256-SHA; 02 Aug 2011 16:45:49 -0400 Original-Received: by ceviche.home (Postfix, from userid 20848) id 56A1E660CF; Tue, 2 Aug 2011 16:45:49 -0400 (EDT) In-Reply-To: <87bow74mrf.fsf@gmail.com> ("=?UTF-8?Q?=C5=A0t=C4=9Bp=C3=A1n_?= =?UTF-8?Q?N=C4=9Bmec?="'s message of "Tue, 02 Aug 2011 21:49:24 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Tue, 02 Aug 2011 16:47:02 -0400 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 1) 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:49844 Archived-At: >>> The point is that you can define a major mode with different syntax >>> tables in different parts of the text (using the syntax-table text >>> property), but instead of using that information to determine >>> comment-start and the other variables, `comment-normalize-vars' still >>> relies on `comment-start' being hard-coded (which doesn't really make >>> sense in a buffer with multiple comment syntaxes), even when >>> `comment-use-syntax' is set and the syntax-table information is >>> sufficient. >> But this is part of a much larger problem (multiple major modes in the >> same buffer). > Maybe, but the specific change to `comment-normalize-vars' (gather the > appropriate value for `comment-start' from the syntax-table at point > instead of prompting the user when `comment-use-syntax' is set) I > proposed would seem easy enough and fix this very problem. We could do that, yes, but unless we regularly flush the comment-start value we got, it will then keep using the first value found even on chunks using another language. >> Basically you're suggesting to use the syntax-table property as a way to >> specify the major mode used in each part and then teach newcomment.el to >> never use buffer-local variables but only the syntax-table around >> point. > More precisely and less ambitiously, I'm suggesting to do what > `comment-use-syntax' seems to be claiming already (that's also why I > still consider this a bug, not an enhancement request) -- to rely on > syntax-table instead of the regexp variables when manipulating comments. comment-use-syntax was less ambitious: it was mostly about using forward-comment. It does try to build some of the vars from the syntax-table, but mostly because comment-end-skip was new in newcomment.el and I needed the code to work with old packages ;-) But yes, comment-start could sometimes also be set from the syntax-table. I might accept a patch for it, tho I'm not completely sure how useful that would be. >> It might be a good idea, but it's a non-trivial change (and still >> leaves open the question of how to specify that I want //...\n for the >> C chunks and (*...*) for the Pascal chunks). > I don't understand. Again: the case I've described, the comment syntax > is unambiguously specified for every part of the buffer using the > syntax-table (either the buffer-local value, or the text property > value). The C chunks have the C syntax table as its value, the Pascal That's not unambiguous: the C syntax-table specifies several comment syntaxes (/*..*/ and //..\n) and so does the Pascal syntax table (even more combinations, IIRC). So comment-start-skip can be built from the syntax-table since it needs to match "any comment starter", but comment-start is more problematic since it would need to choose whose comment syntax to favor. > The only thing that's needed to fix this very use case is make > `comment-normalize-vars' set `comment-start' from the syntax-table when > `comment-use-syntax' is set, instead of forcing me to advise it and do > it myself. It'd still be ugly, but not more ugly than it already is now, > and certainly better than using advice. But if it's not a major mode used over the whole file, when do you flush the comment-start value you computed? Stefan