* is there a human readable way to display syntax table? @ 2008-10-12 14:52 Xah 2008-10-12 16:13 ` Nikolaj Schumacher ` (2 more replies) 0 siblings, 3 replies; 6+ messages in thread From: Xah @ 2008-10-12 14:52 UTC (permalink / raw) To: help-gnu-emacs when creating a syntax table while writing a new mode, i need to pick a syntax table to inherit. Is there a way to display the syntax table so that its human readible? I'm mostly interested in seeing which of the ascii chars's classes, in the standard-syntax-table, text-mode- syntaxt-table, or c-mode-syntax-table. If i eval (standard-syntax-table) or see the values of text-mode- syntaxt-table, it returns a internal format of over 10 thousand cryptic elements. Xah ∑ http://xahlee.org/ ☄ ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: is there a human readable way to display syntax table? 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> 2 siblings, 0 replies; 6+ messages in thread From: Nikolaj Schumacher @ 2008-10-12 16:13 UTC (permalink / raw) To: Xah; +Cc: help-gnu-emacs Xah <xahlee@gmail.com> wrote: > when creating a syntax table while writing a new mode, i need to pick > a syntax table to inherit. You don't need to. You can (if that saves you work). > I'm mostly interested in seeing which of the ascii chars's classes, in > the standard-syntax-table, text-mode- syntaxt-table, or > c-mode-syntax-table. (with-syntax-table c-mode-syntax-table (let ((c 0)) (while (< c ?~) (insert (format "%c: %c\n" c (char-syntax c))) (incf c)))) regards, Nikolaj Schumacher ^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: is there a human readable way to display syntax table? 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> 2 siblings, 0 replies; 6+ messages in thread From: Drew Adams @ 2008-10-12 16:18 UTC (permalink / raw) To: 'Xah', help-gnu-emacs > when creating a syntax table while writing a new mode, i need to pick > a syntax table to inherit. Is there a way to display the syntax table > so that its human readible? I'm mostly interested in seeing which of > the ascii chars's classes, in the standard-syntax-table, text-mode- > syntaxt-table, or c-mode-syntax-table. > > If i eval (standard-syntax-table) or see the values of text-mode- > syntaxt-table, it returns a internal format of over 10 thousand > cryptic elements. `C-h s', which is `describe-syntax', shows the current syntax table in human-readable form. ^ permalink raw reply [flat|nested] 6+ messages in thread
[parent not found: <mailman.885.1223828028.25473.help-gnu-emacs@gnu.org>]
* Re: is there a human readable way to display syntax table? [not found] ` <mailman.885.1223828028.25473.help-gnu-emacs@gnu.org> @ 2008-10-16 21:21 ` Xah 2008-10-17 13:50 ` Kevin Rodgers [not found] ` <mailman.1336.1224251466.25473.help-gnu-emacs@gnu.org> 0 siblings, 2 replies; 6+ messages in thread From: Xah @ 2008-10-16 21:21 UTC (permalink / raw) To: help-gnu-emacs Xah wrote: «I'm mostly interested in seeing which of the ascii chars's classes, in the standard-syntax-table, text-mode- syntaxt-table, or c-mode- syntax-table.» Nikolaj Schumacher wrote: > (with-syntax-tablec-mode-syntax-table > (let ((c 0)) > (while (< c ?~) > (insert (format "%c: %c\n" c (char-syntaxc))) > (incf c)))) Drew Adams wrote: «`C-h s', which is `describe-syntax', shows the current syntax table in human-readable form.» Thanks guys. 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? (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 ...) Xah ∑ http://xahlee.org/ ☄ ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: is there a human readable way to display syntax table? 2008-10-16 21:21 ` Xah @ 2008-10-17 13:50 ` Kevin Rodgers [not found] ` <mailman.1336.1224251466.25473.help-gnu-emacs@gnu.org> 1 sibling, 0 replies; 6+ messages in thread From: Kevin Rodgers @ 2008-10-17 13:50 UTC (permalink / raw) To: help-gnu-emacs 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 ^ permalink raw reply [flat|nested] 6+ messages in thread
[parent not found: <mailman.1336.1224251466.25473.help-gnu-emacs@gnu.org>]
* Re: is there a human readable way to display syntax table? [not found] ` <mailman.1336.1224251466.25473.help-gnu-emacs@gnu.org> @ 2008-10-17 18:36 ` Xah 0 siblings, 0 replies; 6+ messages in thread From: Xah @ 2008-10-17 18:36 UTC (permalink / raw) To: help-gnu-emacs Kevin Rodgers wrote: > From the "Syntax Basics" node of the Emacs Lisp manual: > ... Hi Kevin, Thanks for the manual pointers. I'm new in these areas so a reading with the manual didn't help. My specific question are: (1) when one create a new mode for a newLang, does he basically go thru the process of defining it using code similar to this (defvar newLang-mode-syntax-table (let ((st (make-syntax-table))) (modify-syntax-entry ?\" ". " st) (modify-syntax-entry ?\\ ". " st) ; more... st) ) and go thru each char in newLang and add a modify-syntax-entry? (2) does a syntax table supposed have a definition for every char in the unicode? This is kinda tedious as there are few thousand chars there. Where is the source code where one can see the root syntax table is defined? Xah ∑ http://xahlee.org/ ☄ ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2008-10-17 18:36 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 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 [not found] ` <mailman.1336.1224251466.25473.help-gnu-emacs@gnu.org> 2008-10-17 18:36 ` Xah
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).