unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#9148: Make `comment-normalize-vars' more syntax-aware
@ 2011-07-22 14:52 Štěpán Němec
  2011-08-02  4:04 ` Stefan Monnier
  2022-01-27 17:57 ` Lars Ingebrigtsen
  0 siblings, 2 replies; 9+ messages in thread
From: Štěpán Němec @ 2011-07-22 14:52 UTC (permalink / raw)
  To: 9148

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.

-- 
Štěpán





^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2022-02-02 17:21 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).