GNU bug report logs - #9148
Make `comment-normalize-vars' more syntax-aware

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; Severity: wishlist; Reported by: Štěpán Němec <stepnem@HIDDEN>; dated Fri, 22 Jul 2011 14:57:02 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.
Severity set to 'wishlist' from 'normal' Request was from npostavs@HIDDEN to control <at> debbugs.gnu.org. Full text available.

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


Received: (at 9148) by debbugs.gnu.org; 2 Aug 2011 20:46:42 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Aug 02 16:46:42 2011
Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1QoLrN-0004Yp-Ha
	for submit <at> debbugs.gnu.org; Tue, 02 Aug 2011 16:46:41 -0400
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 <monnier@HIDDEN>) id 1QoLrL-0004Yh-Db
	for 9148 <at> 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"
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
Received: by ceviche.home (Postfix, from userid 20848)
	id 56A1E660CF; Tue,  2 Aug 2011 16:45:49 -0400 (EDT)
From: Stefan Monnier <monnier@HIDDEN>
To: =?utf-8?B?xaB0xJtww6FuIE7Em21lYw==?= <stepnem@HIDDEN>
Subject: Re: bug#9148: Make `comment-normalize-vars' more syntax-aware
Message-ID: <jwvmxfrzgza.fsf-monnier+emacs@HIDDEN>
References: <87ipqu5pwl.fsf@HIDDEN> <jwv62mg8nsh.fsf-monnier+emacs@HIDDEN>
	<87oc083xuw.fsf@HIDDEN> <jwvvcufej42.fsf-monnier+emacs@HIDDEN>
	<87bow74mrf.fsf@HIDDEN>
Date: Tue, 02 Aug 2011 16:45:48 -0400
In-Reply-To: <87bow74mrf.fsf@HIDDEN> (=?utf-8?B?IsWgdMSbcMOhbiBOxJtt?=
	=?utf-8?B?ZWMiJ3M=?= message of "Tue, 02 Aug 2011 21:49:24 +0200")
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: -2.1 (--)
X-Debbugs-Envelope-To: 9148
Cc: 9148 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.11
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: -2.1 (--)

>>> 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




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs@HIDDEN:
bug#9148; Package emacs. Full text available.

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


Received: (at 9148) by debbugs.gnu.org; 2 Aug 2011 19:54:34 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Aug 02 15:54:34 2011
Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1QoL2w-0002Oi-EB
	for submit <at> debbugs.gnu.org; Tue, 02 Aug 2011 15:54:34 -0400
Received: from mail-fx0-f44.google.com ([209.85.161.44])
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <stepnem@HIDDEN>) id 1QoL2u-0002OZ-DY
	for 9148 <at> debbugs.gnu.org; Tue, 02 Aug 2011 15:54:33 -0400
Received: by fxe6 with SMTP id 6so169619fxe.3
	for <9148 <at> debbugs.gnu.org>; Tue, 02 Aug 2011 12:54:02 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;
	h=from:to:cc:subject:in-reply-to:references:user-agent:date
	:message-id:mime-version:content-type:content-transfer-encoding;
	bh=SJLdzFIgwKaUVckWf7F501uRkbwBvlnEIqmcyQUJR+g=;
	b=XNFrUaoKEKRcWa3oMO4+4BEvpkGo5ySMg8JLzmQ5Ju1t47z73LLSt5OugrrvqIdIy2
	BkI3SsD0uhMh6bg0AVeVMTzEJjvcZqkTtWgP6Bb7VlFNgNJlCxhYROdlkKCP56ynbg/9
	5a2iXoXLFC7w2q7EUCTZE7qeNhyVDndVln8ok=
Received: by 10.223.145.22 with SMTP id b22mr9033809fav.95.1312314842057;
	Tue, 02 Aug 2011 12:54:02 -0700 (PDT)
Received: from localhost (176.119.broadband10.iol.cz [90.177.119.176])
	by mx.google.com with ESMTPS id o18sm54262fal.47.2011.08.02.12.53.59
	(version=TLSv1/SSLv3 cipher=OTHER);
	Tue, 02 Aug 2011 12:54:01 -0700 (PDT)
From: =?utf-8?B?xaB0xJtww6FuIE7Em21lYw==?= <stepnem@HIDDEN>
To: Stefan Monnier <monnier@HIDDEN>
Subject: Re: bug#9148: Make `comment-normalize-vars' more syntax-aware
In-Reply-To: <jwvvcufej42.fsf-monnier+emacs@HIDDEN> (Stefan Monnier's message
	of "Tue, 02 Aug 2011 15:03:54 -0400")
References: <87ipqu5pwl.fsf@HIDDEN> <jwv62mg8nsh.fsf-monnier+emacs@HIDDEN>
	<87oc083xuw.fsf@HIDDEN> <jwvvcufej42.fsf-monnier+emacs@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)
Date: Tue, 02 Aug 2011 21:49:24 +0200
Message-ID: <87bow74mrf.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: -3.7 (---)
X-Debbugs-Envelope-To: 9148
Cc: 9148 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.11
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.7 (---)

On Tue, 02 Aug 2011 21:03:54 +0200
Stefan Monnier wrote:

>> 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.

> 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.

> 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
chunks have the Pascal syntax table as its value (if there is such a
thing -- I don't use C or Pascal; in my specific case it was JavaScript
on one hand and a VimL[1]-like custom syntax with double quote comment
start and end-of-line comment end on the other).

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.


[1] The "language" used for Vim scripting.

--=20
=C5=A0t=C4=9Bp=C3=A1n




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs@HIDDEN:
bug#9148; Package emacs. Full text available.

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


Received: (at 9148) by debbugs.gnu.org; 2 Aug 2011 19:04:27 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Aug 02 15:04:27 2011
Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1QoKGQ-0000MN-Rr
	for submit <at> debbugs.gnu.org; Tue, 02 Aug 2011 15:04:26 -0400
Received: from relais.videotron.ca ([24.201.245.36])
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <monnier@HIDDEN>) id 1QoKGN-0000MF-Un
	for 9148 <at> debbugs.gnu.org; Tue, 02 Aug 2011 15:04:24 -0400
MIME-version: 1.0
Content-transfer-encoding: 7BIT
Content-type: text/plain; CHARSET=US-ASCII
Received: from ceviche.home ([70.80.89.35]) by vl-mo-mrz23.ip.videotron.ca
	(Sun Java(tm) System Messaging Server 6.3-8.01 (built Dec 16 2008;
	32bit))
	with ESMTP id <0LPB00746E8Z2FN0@HIDDEN> for
	9148 <at> debbugs.gnu.org; Tue, 02 Aug 2011 15:02:59 -0400 (EDT)
Received: by ceviche.home (Postfix, from userid 20848)	id 217CC660CF; Tue,
	02 Aug 2011 15:03:54 -0400 (EDT)
From: Stefan Monnier <monnier@HIDDEN>
To: =?utf-8?B?xaB0xJtww6FuIE7Em21lYw==?= <stepnem@HIDDEN>
Subject: Re: bug#9148: Make `comment-normalize-vars' more syntax-aware
Message-id: <jwvvcufej42.fsf-monnier+emacs@HIDDEN>
References: <87ipqu5pwl.fsf@HIDDEN> <jwv62mg8nsh.fsf-monnier+emacs@HIDDEN>
	<87oc083xuw.fsf@HIDDEN>
Date: Tue, 02 Aug 2011 15:03:54 -0400
In-reply-to: <87oc083xuw.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)
X-Spam-Score: -2.0 (--)
X-Debbugs-Envelope-To: 9148
Cc: 9148 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.11
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: -2.0 (--)

> 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).

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.

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).


        Stefan




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs@HIDDEN:
bug#9148; Package emacs. Full text available.

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


Received: (at 9148) by debbugs.gnu.org; 2 Aug 2011 10:40:12 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Aug 02 06:40:12 2011
Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1QoCOR-0001td-9o
	for submit <at> debbugs.gnu.org; Tue, 02 Aug 2011 06:40:11 -0400
Received: from mail-ew0-f44.google.com ([209.85.215.44])
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <stepnem@HIDDEN>) id 1QoCOO-0001tU-Jo
	for 9148 <at> debbugs.gnu.org; Tue, 02 Aug 2011 06:40:09 -0400
Received: by ewy19 with SMTP id 19so3646597ewy.3
	for <9148 <at> debbugs.gnu.org>; Tue, 02 Aug 2011 03:39:40 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;
	h=from:to:cc:subject:in-reply-to:references:user-agent:date
	:message-id:mime-version:content-type:content-transfer-encoding;
	bh=EhXgNvfCP7TJ+5EI7bWo6OIDAQsC/TDsIyj2W/nXjtU=;
	b=Sj02cKSjSHf2i3fBTkou+DXcWLZr7cVkC4BLoYqF261lJhy4jhvatdRvuwpdzt4qMi
	SLbrbpQ0Av9hagIL9Ivo27q4Obr08DrxA0oCDkiQ+0xlcyO3gmH6ZdILM09UM3NmixFD
	Ak6kFd/0WNvqLN/yY36wydZmwUUeMOFS+4w+U=
Received: by 10.204.101.10 with SMTP id a10mr1792364bko.183.1312281580254;
	Tue, 02 Aug 2011 03:39:40 -0700 (PDT)
Received: from localhost (176.119.broadband10.iol.cz [90.177.119.176])
	by mx.google.com with ESMTPS id x1sm1865692fah.0.2011.08.02.03.39.38
	(version=TLSv1/SSLv3 cipher=OTHER);
	Tue, 02 Aug 2011 03:39:39 -0700 (PDT)
From: =?utf-8?B?xaB0xJtww6FuIE7Em21lYw==?= <stepnem@HIDDEN>
To: Stefan Monnier <monnier@HIDDEN>
Subject: Re: bug#9148: Make `comment-normalize-vars' more syntax-aware
In-Reply-To: <jwv62mg8nsh.fsf-monnier+emacs@HIDDEN> (Stefan Monnier's message
	of "Tue, 02 Aug 2011 00:04:03 -0400")
References: <87ipqu5pwl.fsf@HIDDEN> <jwv62mg8nsh.fsf-monnier+emacs@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)
Date: Tue, 02 Aug 2011 12:35:03 +0200
Message-ID: <87oc083xuw.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: -3.7 (---)
X-Debbugs-Envelope-To: 9148
Cc: 9148 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.11
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.7 (---)

On Tue, 02 Aug 2011 06:04:03 +0200
Stefan Monnier wrote:

>> Unfortunately, even though there is a `comment-use-syntax' variable
>> which is apparently supposed to indicate that the comment functions
>> should rely on syntax information instead of `comment-prefix' and
>> friends, one piece is missing -- the function `comment-normalize-vars',
>> called at invocation of functions like {comment,uncomment}-region, still
>> requires `comment-start' to be set explicitly even though the syntax
>> information is sufficient and `comment-use-syntax' set.
>
> I'm not sure I understand the problem.  Can you give a more concrete
> example where you get undesirable behavior?
> Setting comment-start is usually needed to tell Emacs *which* of the
> major mode's comment syntaxes to use (so it's only theoretically
> unneeded if the syntax-table only include a single comment syntax).

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.

--=20
=C5=A0t=C4=9Bp=C3=A1n




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs@HIDDEN:
bug#9148; Package emacs. Full text available.

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


Received: (at 9148) by debbugs.gnu.org; 2 Aug 2011 04:04:33 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Aug 02 00:04:33 2011
Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1Qo6DY-0000TW-P9
	for submit <at> debbugs.gnu.org; Tue, 02 Aug 2011 00:04:33 -0400
Received: from ironport2-out.teksavvy.com ([206.248.154.181]
	helo=ironport2-out.pppoe.ca)
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <monnier@HIDDEN>) id 1Qo6DW-0000TO-G0
	for 9148 <at> debbugs.gnu.org; Tue, 02 Aug 2011 00:04:31 -0400
X-IronPort-Anti-Spam-Filtered: true
X-IronPort-Anti-Spam-Result: Av0EADF2N05FxKfe/2dsb2JhbABCp194gUABAQQBViMFCws0EhQYDSSHf8EPhkIEn0qEMQ
X-IronPort-AV: E=Sophos;i="4.67,304,1309752000"; d="scan'208";a="128373872"
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 00:04:04 -0400
Received: by ceviche.home (Postfix, from userid 20848)
	id C52B7660CF; Tue,  2 Aug 2011 00:04:03 -0400 (EDT)
From: Stefan Monnier <monnier@HIDDEN>
To: =?utf-8?B?xaB0xJtww6FuIE7Em21lYw==?= <stepnem@HIDDEN>
Subject: Re: bug#9148: Make `comment-normalize-vars' more syntax-aware
Message-ID: <jwv62mg8nsh.fsf-monnier+emacs@HIDDEN>
References: <87ipqu5pwl.fsf@HIDDEN>
Date: Tue, 02 Aug 2011 00:04:03 -0400
In-Reply-To: <87ipqu5pwl.fsf@HIDDEN> (=?utf-8?B?IsWgdMSbcMOhbiBOxJtt?=
	=?utf-8?B?ZWMiJ3M=?= message of "Fri, 22 Jul 2011 16:52:10 +0200")
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: -2.1 (--)
X-Debbugs-Envelope-To: 9148
Cc: 9148 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.11
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: -2.1 (--)

> Unfortunately, even though there is a `comment-use-syntax' variable
> which is apparently supposed to indicate that the comment functions
> should rely on syntax information instead of `comment-prefix' and
> friends, one piece is missing -- the function `comment-normalize-vars',
> called at invocation of functions like {comment,uncomment}-region, still
> requires `comment-start' to be set explicitly even though the syntax
> information is sufficient and `comment-use-syntax' set.

I'm not sure I understand the problem.  Can you give a more concrete
example where you get undesirable behavior?
Setting comment-start is usually needed to tell Emacs *which* of the
major mode's comment syntaxes to use (so it's only theoretically
unneeded if the syntax-table only include a single comment syntax).


        Stefan




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs@HIDDEN:
bug#9148; Package emacs. Full text available.

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


Received: (at submit) by debbugs.gnu.org; 22 Jul 2011 14:56:55 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Jul 22 10:56:55 2011
Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1QkH9r-0002o6-2A
	for submit <at> debbugs.gnu.org; Fri, 22 Jul 2011 10:56:55 -0400
Received: from eggs.gnu.org ([140.186.70.92])
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <stepnem@HIDDEN>) id 1QkH9o-0002nu-VZ
	for submit <at> debbugs.gnu.org; Fri, 22 Jul 2011 10:56:53 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <stepnem@HIDDEN>) id 1QkH9i-0003nx-OB
	for submit <at> debbugs.gnu.org; Fri, 22 Jul 2011 10:56:47 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) 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.1
Received: from lists.gnu.org ([140.186.70.17]:35585)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <stepnem@HIDDEN>) id 1QkH9i-0003nt-Mg
	for submit <at> debbugs.gnu.org; Fri, 22 Jul 2011 10:56:46 -0400
Received: from eggs.gnu.org ([140.186.70.92]:45833)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <stepnem@HIDDEN>) id 1QkH9h-0002HT-IC
	for bug-gnu-emacs@HIDDEN; Fri, 22 Jul 2011 10:56:46 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <stepnem@HIDDEN>) id 1QkH9f-0003nK-OW
	for bug-gnu-emacs@HIDDEN; Fri, 22 Jul 2011 10:56:45 -0400
Received: from mail-fx0-f52.google.com ([209.85.161.52]:52723)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <stepnem@HIDDEN>) id 1QkH9f-0003n3-J0
	for bug-gnu-emacs@HIDDEN; Fri, 22 Jul 2011 10:56:43 -0400
Received: by fxd18 with SMTP id 18so4367424fxd.39
	for <bug-gnu-emacs@HIDDEN>; Fri, 22 Jul 2011 07:56:42 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;
	h=from:to:subject:date:message-id:mime-version:content-type
	:content-transfer-encoding;
	bh=d0JPKLUd30kD96EXXLwRvT5lrGjWxP/wd4f0lT9KV90=;
	b=GwMYXj5sncEU5g9ez5TisJhgMHaECQkLGEqZVC/OLlrm0tTVCRSdpfSUuqEv/5BD0/
	XawWv8PfobHYoQWTBiD2Kf4A9vn5EBmHE2GGJ96xaJ8YIq4DNsIv2mLfQr5i8p3dif+l
	wiFWNlDhP1Hw3RKuxgI/8lipPHZfBIjs4tXHc=
Received: by 10.223.29.10 with SMTP id o10mr2237940fac.87.1311346602260;
	Fri, 22 Jul 2011 07:56:42 -0700 (PDT)
Received: from localhost (176.119.broadband10.iol.cz [90.177.119.176])
	by mx.google.com with ESMTPS id a18sm2090962faa.30.2011.07.22.07.56.39
	(version=TLSv1/SSLv3 cipher=OTHER);
	Fri, 22 Jul 2011 07:56:40 -0700 (PDT)
From: =?utf-8?B?xaB0xJtww6FuIE7Em21lYw==?= <stepnem@HIDDEN>
To: bug-gnu-emacs <bug-gnu-emacs@HIDDEN>
Subject: Make `comment-normalize-vars' more syntax-aware
Date: Fri, 22 Jul 2011 16:52:10 +0200
Message-ID: <87ipqu5pwl.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3)
X-Received-From: 140.186.70.17
X-Spam-Score: -4.8 (----)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.11
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: -4.8 (----)

Problem:
--------

Emacs currently provides relatively decent support for major modes with
multiple syntaxes, mainly via the `syntax-table' text property.

Unfortunately, even though there is a `comment-use-syntax' variable
which is apparently supposed to indicate that the comment functions
should rely on syntax information instead of `comment-prefix' and
friends, one piece is missing -- the function `comment-normalize-vars',
called at invocation of functions like {comment,uncomment}-region, still
requires `comment-start' to be set explicitly even though the syntax
information is sufficient and `comment-use-syntax' set.

Suggested solution:
-------------------

Modify `comment-normalize-vars' so that it uses the syntax information
(current syntax table, `syntax-table' text property) _only_, whenever
`comment-use-syntax' is set and this is possible.

Use case:
---------

Consider a major mode with two or more clearly separate syntaxes (Org
mode source blocks could be one example), including comments.

Even though it is possible to provide the different text extents with
different values of the `syntax-table' text property, the only way to
work around `comment-normalize-vars' not relying on them currently seems
something like the following:

(defadvice comment-normalize-vars (around use-syntax-info activate)
  (set (make-local-variable 'comment-start)
       (determine-comment-start-based-on-syntax-info))
  ad-do-it)

...which is evil, ugly and doesn't scale.

--=20
=C5=A0t=C4=9Bp=C3=A1n




Acknowledgement sent to Štěpán Němec <stepnem@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs@HIDDEN:
bug#9148; 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: Mon, 25 Nov 2019 12:00:02 UTC

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