* What is this syntax for in php-mode.el
@ 2007-04-20 1:26 Lennart Borgman (gmail)
2007-04-20 7:24 ` Edward O'Connor
0 siblings, 1 reply; 8+ messages in thread
From: Lennart Borgman (gmail) @ 2007-04-20 1:26 UTC (permalink / raw)
To: help-gnu-emacs@gnu.org
I am looking at php-mode.el from Turadg. I can not understand this:
(defconst php-font-lock-syntactic-keywords
(if xemacsp nil
;; Mark shell-style comments. font-lock handles this in a
;; separate pass from normal syntactic scanning (somehow), so we
;; get a chance to mark these in addition to C and C++ style
;; comments. This only works in GNU Emacs, not XEmacs 21 which
;; seems to ignore this same code if we try to use it.
(list
;; Mark _all_ # chars as being comment-start. That will be
;; ignored when inside a quoted string.
'("\\(\#\\)"
(1 (11 . nil)))
;; Mark all newlines ending a line with # as being comment-end.
;; This causes a problem, premature end-of-comment, when '#'
;; appears inside a multiline C-style comment. Oh well.
'("#.*\\([\n]\\)"
(1 (12 . nil)))
)))
What is it for? Does php use # as a comment somewhere?
And what about the format for the list entries? I tried to look at
font-lock-syntactic-keywords, but I can not see that these entries
follows the spec there.
How does this work?
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: What is this syntax for in php-mode.el
2007-04-20 1:26 Lennart Borgman (gmail)
@ 2007-04-20 7:24 ` Edward O'Connor
2007-04-20 12:24 ` Lennart Borgman (gmail)
[not found] ` <mailman.2303.1177072165.7795.help-gnu-emacs@gnu.org>
0 siblings, 2 replies; 8+ messages in thread
From: Edward O'Connor @ 2007-04-20 7:24 UTC (permalink / raw)
To: help-gnu-emacs
Lennart asked:
> What is it for? Does php use # as a comment somewhere?
PHP has (at least) three comment syntaxes:
/* ... */
// ... EOL
# ... EOL
Ted
--
Edward O'Connor
hober0@gmail.com
Ense petit placidam sub libertate quietem.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: What is this syntax for in php-mode.el
2007-04-20 7:24 ` Edward O'Connor
@ 2007-04-20 12:24 ` Lennart Borgman (gmail)
[not found] ` <mailman.2303.1177072165.7795.help-gnu-emacs@gnu.org>
1 sibling, 0 replies; 8+ messages in thread
From: Lennart Borgman (gmail) @ 2007-04-20 12:24 UTC (permalink / raw)
To: Edward O'Connor; +Cc: help-gnu-emacs
Edward O'Connor wrote:
> Lennart asked:
>
>> What is it for? Does php use # as a comment somewhere?
>
> PHP has (at least) three comment syntaxes:
>
> /* ... */
> // ... EOL
> # ... EOL
Thanks Ted. Now I only wonder about that strange
font-lock-syntactic-keywords spec that I can not find in the Emacs lisp
manual.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: What is this syntax for in php-mode.el
[not found] ` <mailman.2303.1177072165.7795.help-gnu-emacs@gnu.org>
@ 2007-04-20 13:08 ` Robert D. Crawford
2007-04-20 14:17 ` Lennart Borgman (gmail)
0 siblings, 1 reply; 8+ messages in thread
From: Robert D. Crawford @ 2007-04-20 13:08 UTC (permalink / raw)
To: help-gnu-emacs
"Lennart Borgman (gmail)" <lennart.borgman@gmail.com> writes:
> Thanks Ted. Now I only wonder about that strange
> font-lock-syntactic-keywords spec that I can not find in the Emacs
> lisp manual.
This might help, fetched with apropos:
font-lock-syntactic-keywords is a variable defined in `font-lock.el'.
Its value is nil
Documentation:
A list of the syntactic keywords to put syntax properties on.
The value can be the list itself, or the name of a function or variable
whose value is the list.
See `font-lock-keywords' for a description of the form of this list;
only the differences are stated here. MATCH-HIGHLIGHT should be of the form:
(SUBEXP SYNTAX OVERRIDE LAXMATCH)
where SYNTAX can be a string (as taken by `modify-syntax-entry'), a syntax
table, a cons cell (as returned by `string-to-syntax') or an expression whose
value is such a form. OVERRIDE cannot be `prepend' or `append'.
Here are two examples of elements of `font-lock-syntactic-keywords'
and what they do:
("\\$\\(#\\)" 1 ".")
gives a hash character punctuation syntax (".") when following a
dollar-sign character. Hash characters in other contexts will still
follow whatever the syntax table says about the hash character.
("\\('\\).\\('\\)"
(1 "\"")
(2 "\""))
gives a pair single-quotes, which surround a single character, a SYNTAX of
"\"" (meaning string quote syntax). Single-quote characters in other
contexts will not be affected.
This is normally set via `font-lock-defaults'.
--
Robert D. Crawford rdc1x@comcast.net
This fortune was brought to you by the people at Hewlett-Packard.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: What is this syntax for in php-mode.el
2007-04-20 13:08 ` Robert D. Crawford
@ 2007-04-20 14:17 ` Lennart Borgman (gmail)
0 siblings, 0 replies; 8+ messages in thread
From: Lennart Borgman (gmail) @ 2007-04-20 14:17 UTC (permalink / raw)
To: Robert D. Crawford; +Cc: help-gnu-emacs
Robert D. Crawford wrote:
> "Lennart Borgman (gmail)" <lennart.borgman@gmail.com> writes:
>
>> Thanks Ted. Now I only wonder about that strange
>> font-lock-syntactic-keywords spec that I can not find in the Emacs
>> lisp manual.
>
> This might help, fetched with apropos:
>
> font-lock-syntactic-keywords is a variable defined in `font-lock.el'.
> Its value is nil
>
>
> Documentation:
> A list of the syntactic keywords to put syntax properties on.
> The value can be the list itself, or the name of a function or variable
> whose value is the list.
>
> See `font-lock-keywords' for a description of the form of this list;
> only the differences are stated here. MATCH-HIGHLIGHT should be of the form:
>
> (SUBEXP SYNTAX OVERRIDE LAXMATCH)
>
> where SYNTAX can be a string (as taken by `modify-syntax-entry'), a syntax
> table, a cons cell (as returned by `string-to-syntax') or an expression whose
> value is such a form. OVERRIDE cannot be `prepend' or `append'.
>
> Here are two examples of elements of `font-lock-syntactic-keywords'
> and what they do:
>
> ("\\$\\(#\\)" 1 ".")
>
> gives a hash character punctuation syntax (".") when following a
> dollar-sign character. Hash characters in other contexts will still
> follow whatever the syntax table says about the hash character.
>
> ("\\('\\).\\('\\)"
> (1 "\"")
> (2 "\""))
>
> gives a pair single-quotes, which surround a single character, a SYNTAX of
> "\"" (meaning string quote syntax). Single-quote characters in other
> contexts will not be affected.
>
> This is normally set via `font-lock-defaults'.
Maybe. My trouble is that I can not fit something like the below into
this format:
(list
;; Mark _all_ # chars as being comment-start. That will be
;; ignored when inside a quoted string.
'("\\(\#\\)"
(1 (11 . nil)))
;; Mark all newlines ending a line with # as being comment-end.
;; This causes a problem, premature end-of-comment, when '#'
;; appears inside a multiline C-style comment. Oh well.
'("#.*?\\([\n]\\)"
(1 (12 . nil)))
This code works except for trouble of the kind noted in the comment. I
am trying to understand if there is any way around this problem.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: What is this syntax for in php-mode.el
[not found] <mailman.2283.1177032673.7795.help-gnu-emacs@gnu.org>
@ 2007-04-20 14:56 ` Stefan Monnier
2007-04-20 16:16 ` Lennart Borgman (gmail)
0 siblings, 1 reply; 8+ messages in thread
From: Stefan Monnier @ 2007-04-20 14:56 UTC (permalink / raw)
To: help-gnu-emacs
> I am looking at php-mode.el from Turadg. I can not understand this:
> (defconst php-font-lock-syntactic-keywords
> (if xemacsp nil
> ;; Mark shell-style comments. font-lock handles this in a
> ;; separate pass from normal syntactic scanning (somehow), so we
> ;; get a chance to mark these in addition to C and C++ style
> ;; comments. This only works in GNU Emacs, not XEmacs 21 which
> ;; seems to ignore this same code if we try to use it.
> (list
> ;; Mark _all_ # chars as being comment-start. That will be
> ;; ignored when inside a quoted string.
> '("\\(\#\\)"
> (1 (11 . nil)))
> ;; Mark all newlines ending a line with # as being comment-end.
> ;; This causes a problem, premature end-of-comment, when '#'
> ;; appears inside a multiline C-style comment. Oh well.
> '("#.*\\([\n]\\)"
> (1 (12 . nil)))
> )))
> What is it for? Does php use # as a comment somewhere?
> And what about the format for the list entries? I tried to look at
> font-lock-syntactic-keywords, but I can not see that these entries follows
> the spec there.
> How does this work?
Please tell the author that he doesn't need this gymnastics.
Just set # to comment-starter in the syntax-table and be done with it.
Make sure it has the comment-style (a or b) corresponding to the one of \n
(presumably it's b, if I read the problem-comment above correctly):
(modify-syntax-entry ?# "< b" php-mode-syntax-table)
-- Stefan
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: What is this syntax for in php-mode.el
2007-04-20 14:56 ` What is this syntax for in php-mode.el Stefan Monnier
@ 2007-04-20 16:16 ` Lennart Borgman (gmail)
2007-04-20 16:39 ` Lennart Borgman (gmail)
0 siblings, 1 reply; 8+ messages in thread
From: Lennart Borgman (gmail) @ 2007-04-20 16:16 UTC (permalink / raw)
To: Stefan Monnier; +Cc: help-gnu-emacs
Stefan Monnier wrote:
> Please tell the author that he doesn't need this gymnastics.
> Just set # to comment-starter in the syntax-table and be done with it.
> Make sure it has the comment-style (a or b) corresponding to the one of \n
> (presumably it's b, if I read the problem-comment above correctly):
>
> (modify-syntax-entry ?# "< b" php-mode-syntax-table)
But as Ted pointed out before PHP has 3 comment styles, the two from
C/C++ and then the shell comment style above. Is it really possible to
handle this with the syntax table?
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: What is this syntax for in php-mode.el
2007-04-20 16:16 ` Lennart Borgman (gmail)
@ 2007-04-20 16:39 ` Lennart Borgman (gmail)
0 siblings, 0 replies; 8+ messages in thread
From: Lennart Borgman (gmail) @ 2007-04-20 16:39 UTC (permalink / raw)
Cc: help-gnu-emacs, Stefan Monnier
Lennart Borgman (gmail) wrote:
> Stefan Monnier wrote:
>
>> Please tell the author that he doesn't need this gymnastics.
>> Just set # to comment-starter in the syntax-table and be done with it.
>> Make sure it has the comment-style (a or b) corresponding to the one
>> of \n
>> (presumably it's b, if I read the problem-comment above correctly):
>>
>> (modify-syntax-entry ?# "< b" php-mode-syntax-table)
>
>
> But as Ted pointed out before PHP has 3 comment styles, the two from
> C/C++ and then the shell comment style above. Is it really possible to
> handle this with the syntax table?
And maybe I should have tested first ...
Thanks Stefan, it works.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2007-04-20 16:39 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <mailman.2283.1177032673.7795.help-gnu-emacs@gnu.org>
2007-04-20 14:56 ` What is this syntax for in php-mode.el Stefan Monnier
2007-04-20 16:16 ` Lennart Borgman (gmail)
2007-04-20 16:39 ` Lennart Borgman (gmail)
2007-04-20 1:26 Lennart Borgman (gmail)
2007-04-20 7:24 ` Edward O'Connor
2007-04-20 12:24 ` Lennart Borgman (gmail)
[not found] ` <mailman.2303.1177072165.7795.help-gnu-emacs@gnu.org>
2007-04-20 13:08 ` Robert D. Crawford
2007-04-20 14:17 ` Lennart Borgman (gmail)
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.