From: Kevin Rodgers <kevin.d.rodgers@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: is there a human readable way to display syntax table?
Date: Fri, 17 Oct 2008 07:50:54 -0600 [thread overview]
Message-ID: <gda57n$qvv$1@ger.gmane.org> (raw)
In-Reply-To: <5e70cb60-bbe9-4e9f-8d37-5e8f2786d81b@42g2000pry.googlegroups.com>
Xah wrote:
> When i write a new mode from the ground up (not using derived-mode or
> generic mode), how do i go about defining the syntax table?
>
> For example, i'm writing a mode for the LSL language, which uses a
> sytax like C/Java.
>
> So, i start by copying example from text-mode:
>
> (defvar text-mode-syntax-table
> (let ((st (make-syntax-table)))
> (modify-syntax-entry ?\" ". " st)
> (modify-syntax-entry ?\\ ". " st)
> ;; We add `p' so that M-c on 'hello' leads to 'Hello' rather than
> 'hello'.
> (modify-syntax-entry ?' "w p" st)
> st)
> "Syntax table used while in `text-mode'.")
>
> In my case, the LSL is basically ascii based lang. So, do i go thru
> each printable ascii char, and add a modify-syntax-entry for it using
> the above template?
>
> Another question... i tried to study syntax table, which is a char
> table, which is a specialized vector with extra things ... not so easy
> to understand... but looking at the syntax table for text mode, it has
> some 800 entries. Is a syntax table meant to cover all unicode char?
From the "Syntax Basics" node of the Emacs Lisp manual:
A syntax table is a char-table (*note Char-Tables::). The element at
index C describes the character with code C. The element's value
should be a list that encodes the syntax of the character in question.
...
A syntax table can inherit the data for some characters from the
standard syntax table, while specifying other characters itself. The
"inherit" syntax class means "inherit this character's syntax from the
standard syntax table." Just changing the standard syntax for a
character affects all syntax tables that inherit from it.
From the "Char-Tables" node:
A char-table is much like a vector, except that it is indexed by
character codes. Any valid character code, without modifiers, can be
used as an index in a char-table. You can access a char-table's
elements with `aref' and `aset', as with any array. In addition, a
char-table can have "extra slots" to hold additional data not
associated with particular character codes. Char-tables are constants
when evaluated.
...
-- Function: make-char-table subtype &optional init
Return a newly created char-table, with subtype SUBTYPE. Each
element is initialized to INIT, which defaults to `nil'. You
cannot alter the subtype of a char-table after the char-table is
created.
There is no argument to specify the length of the char-table,
because all char-tables have room for any valid character code as
an index.
> (am avoiding copying from c mode's syntax table for the moment so i
> get more understanding by doing more from the basics... the cc-mode
> source seems much complex to dig ...)
--
Kevin Rodgers
Denver, Colorado, USA
next prev parent reply other threads:[~2008-10-17 13:50 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-10-12 14:52 is there a human readable way to display syntax table? Xah
2008-10-12 16:13 ` Nikolaj Schumacher
2008-10-12 16:18 ` Drew Adams
[not found] ` <mailman.885.1223828028.25473.help-gnu-emacs@gnu.org>
2008-10-16 21:21 ` Xah
2008-10-17 13:50 ` Kevin Rodgers [this message]
[not found] ` <mailman.1336.1224251466.25473.help-gnu-emacs@gnu.org>
2008-10-17 18:36 ` Xah
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='gda57n$qvv$1@ger.gmane.org' \
--to=kevin.d.rodgers@gmail.com \
--cc=help-gnu-emacs@gnu.org \
/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.