all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Štěpán Němec" <stepnem@gmail.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: 9148@debbugs.gnu.org
Subject: bug#9148: Make `comment-normalize-vars' more syntax-aware
Date: Tue, 02 Aug 2011 21:49:24 +0200	[thread overview]
Message-ID: <87bow74mrf.fsf@gmail.com> (raw)
In-Reply-To: <jwvvcufej42.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Tue, 02 Aug 2011 15:03:54 -0400")

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.

-- 
Štěpán





  reply	other threads:[~2011-08-02 19:49 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-22 14:52 bug#9148: Make `comment-normalize-vars' more syntax-aware Štěpán Němec
2011-08-02  4:04 ` Stefan Monnier
2011-08-02 10:35   ` Štěpán Němec
2011-08-02 19:03     ` Stefan Monnier
2011-08-02 19:49       ` Štěpán Němec [this message]
2011-08-02 20:45         ` Stefan Monnier
2022-01-27 17:57 ` Lars Ingebrigtsen
2022-01-31 21:39   ` Štěpán Němec
2022-02-02 17:21     ` Lars Ingebrigtsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87bow74mrf.fsf@gmail.com \
    --to=stepnem@gmail.com \
    --cc=9148@debbugs.gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.