all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Arjan Bos <Arjan.Bos@icu.nl>
Cc: monnier@iro.umontreal.ca
Subject: Re: syntax table entries for comments
Date: Wed, 10 Sep 2003 15:35:54 +0200	[thread overview]
Message-ID: <3F5F28BA.3020704@icu.nl> (raw)
In-Reply-To: <jwv3cf6gk5e.fsf@noir.iro.umontreal.ca>

Stefan Monnier wrote:

>> The second one is a single-line comment that consists of two
>>hyphens, like:
>>   -- this is a comment.
> 
> 
> Emacs does not properly support this, as you've discovered.
To bad. At least I won't have to look for it in the docs anymore.

> 
> 
>>(defvar nrx-mode-syntax-table nil
>>   "Syntax table in use in NRX-mode buffers.")
> 
> 
>>(defun nrx-create-syntax-table ()
>>   (if nrx-mode-syntax-table
>>       ()
>>     (setq nrx-mode-syntax-table (make-syntax-table))
>>     (modify-syntax-entry ?. "." nrx-mode-syntax-table)
>>     (modify-syntax-entry ?- ". 12b" nrx-mode-syntax-table)
>>     (modify-syntax-entry ?/ ". 14" nrx-mode-syntax-table)
>>     (modify-syntax-entry ?* ". 23" nrx-mode-syntax-table)
>>     (modify-syntax-entry ?\n "> b" nrx-mode-syntax-table)
>>     (modify-syntax-entry ?\' "\"" nrx-mode-syntax-table))
> 
> 
>>   (set-syntax-table nrx-mode-syntax-table))
> 
> 
> Could you tell me the place from which this code was inspired so we can
> fix it ?  It should look like:
> 
>    (defvar nrx-mode-syntax-table
>      (let ((st (make-syntax-table)))
>        (modify-syntax-entry ...)
>        (modify-syntax-entry ...)
>        ...
>        st))
> 
> and the `set-syntax-table' is commonly done implicitly by
> `define-derived-mode'.

I found it via Emacs Wiki. On page 
http://www.emacswiki.org/cgi-bin/wiki/ModeTutorial, they link to the 
following mode tutorial:

http://two-wugs.net/emacs/mode-tutorial.html
which I followed and used as an inspiration.

Could you please enlighten me as to why your way is better? I'm no 
(e)lisp expert, but I'm doing allright with a bit of voodoo programming[1].
> 
> 
>>This works but also renders the combination -* and *- as comment start and
>>end, which is wrong. Could anyone please tell me what I'm missing?
> 
> 
> Nothing, really, other than the fact that it's a limitation of current
> syntax-tables.  You can either hack on src/syntax.c to add support for
> such cases, or use font-lock-syntactic-keywords to recognize `--'
> and mark it as a comment starter.
I tried the latter, but then strings within the `--' comment will undo 
the comment highlighting. So I'll try to voodoo hack src/syntax.c


Thanks a lot,

Arjan Bos

[1] voodoo programming: Change something and see if it works. Keep on 
changing things until it does what you want.
This way I can change most sources with only a minimum of knowledge 
about the language it's written in, by repeating the constructs already 
used. Downside is of course that you don't learn new language 
constructs. ;-)

  reply	other threads:[~2003-09-10 13:35 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-09-08  5:39 syntax table entries for comments Arjan Bos
2003-09-09 13:34 ` Stefan Monnier
2003-09-10 13:35   ` Arjan Bos [this message]
2003-09-10 15:04     ` Stefan Monnier
2003-09-11  5:48       ` Arjan Bos

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=3F5F28BA.3020704@icu.nl \
    --to=arjan.bos@icu.nl \
    --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.