* Re: Separating // and /**/ comment fontification
[not found] <mailman.3751.1118182395.25862.help-gnu-emacs@gnu.org>
@ 2005-06-07 23:00 ` Stefan Monnier
2005-06-14 19:13 ` Ryan Bowman
0 siblings, 1 reply; 5+ messages in thread
From: Stefan Monnier @ 2005-06-07 23:00 UTC (permalink / raw)
> How can I change the fontification of one (or the
> other) to use a different face?
Try C-h v font-lock-syntactic-face-function.
Stefan
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Separating // and /**/ comment fontification
2005-06-07 23:00 ` Separating // and /**/ comment fontification Stefan Monnier
@ 2005-06-14 19:13 ` Ryan Bowman
2005-06-14 20:10 ` Ryan Bowman
0 siblings, 1 reply; 5+ messages in thread
From: Ryan Bowman @ 2005-06-14 19:13 UTC (permalink / raw)
--- Stefan Monnier <monnier@iro.umontreal.ca> wrote:
> > How can I change the fontification of one (or the
> > other) to use a different face?
>
> Try C-h v font-lock-syntactic-face-function.
>
>
> Stefan
;; from font-lock.el
(defvar font-lock-syntactic-face-function
(lambda (state)
(if (nth 3 state) font-lock-string-face
font-lock-comment-face))
"Function to determine which face to use when
fontifying syntactically.
The function is called with a single parameter (the
state as returned by
`parse-partial-sexp' at the beginning of the region to
highlight) and
should return a face.")
So as I understand it
font-lock-syntactic-face-function will return the face
with which to highlight something: -string-face if
it's a string, -comment-face otherwise.
Following the link to parse-partial-sexp item #7 of
the return value looks somewhat helpful:
7. t if in a comment of style b; symbol
`syntax-table' if the comment
should be terminated by a generic comment
delimiter.
but I don't quite understand it. What is a comment of
style b? I assume that if the symbol `syntax-table'
is returned it means that the comment must be
terminated by the comment delimiter defined in the
syntax table for the current mode, is that correct?
In Java would the latter then be '*/' and a comment of
style b be a comment started with '//'?
----
Ryan Bowman
There is no vi there is only Emacs
----
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Separating // and /**/ comment fontification
2005-06-14 19:13 ` Ryan Bowman
@ 2005-06-14 20:10 ` Ryan Bowman
0 siblings, 0 replies; 5+ messages in thread
From: Ryan Bowman @ 2005-06-14 20:10 UTC (permalink / raw)
--- Ryan Bowman <ryanlbowman@yahoo.com> wrote:
>
> --- Stefan Monnier <monnier@iro.umontreal.ca> wrote:
>
> > > How can I change the fontification of one (or the
> > > other) to use a different face?
> >
> > Try C-h v font-lock-syntactic-face-function.
> >
> >
> > Stefan
>
> ;; from font-lock.el
> (defvar font-lock-syntactic-face-function
> (lambda (state)
> (if (nth 3 state) font-lock-string-face
> font-lock-comment-face))
> "Function to determine which face to use when
> fontifying syntactically.
> The function is called with a single parameter (the
> state as returned by
> `parse-partial-sexp' at the beginning of the region to
> highlight) and
> should return a face.")
>
> So as I understand it
> font-lock-syntactic-face-function will return the face
> with which to highlight something: -string-face if
> it's a string, -comment-face otherwise.
>
> Following the link to parse-partial-sexp item #7 of
> the return value looks somewhat helpful:
>
> 7. t if in a comment of style b; symbol
> `syntax-table' if the comment
> should be terminated by a generic comment
> delimiter.
>
> but I don't quite understand it. What is a comment of
> style b? I assume that if the symbol `syntax-table'
> is returned it means that the comment must be
> terminated by the comment delimiter defined in the
> syntax table for the current mode, is that correct?
> In Java would the latter then be '*/' and a comment of
> style b be a comment started with '//'?
>
Apparently, I didn't follow my train of ignorance far enough. I dug up the
syntax table chapter in the emacs lisp manual and found out what a 'b' style
comment is - in c++ (and I assume by extension, java) a b-style comment is the
line comment '//' that I was looking for. So, I could redefine
font-lock-syntactic-face-function
(setq font-lock-syntactic-face-function
(lambda (state)
(if (nth 3 state) font-lock-string-face
(if (nth 7 state) font-lock-other-comment-face
font-lock-comment-face))))
and that should do what I want. Though on first attempt it doesn't seem to.
----
Ryan Bowman
There is no vi there is only Emacs
----
__________________________________
Discover Yahoo!
Find restaurants, movies, travel and more fun for the weekend. Check it out!
http://discover.yahoo.com/weekend.html
^ permalink raw reply [flat|nested] 5+ messages in thread
[parent not found: <mailman.1.1118779995.2857.help-gnu-emacs@gnu.org>]
* Re: Separating // and /**/ comment fontification
[not found] <mailman.1.1118779995.2857.help-gnu-emacs@gnu.org>
@ 2005-06-15 5:30 ` Stefan Monnier
0 siblings, 0 replies; 5+ messages in thread
From: Stefan Monnier @ 2005-06-15 5:30 UTC (permalink / raw)
> (setq font-lock-syntactic-face-function
> (lambda (state)
> (if (nth 3 state) font-lock-string-face
> (if (nth 7 state) font-lock-other-comment-face
> font-lock-comment-face))))
> and that should do what I want. Though on first attempt it doesn't seem to.
Make sure you have a variable `font-lock-other-comment-face' whose value is
a symbol (a face). Or otherwise try
(setq font-lock-syntactic-face-function
(lambda (state)
(if (nth 3 state) font-lock-string-face
(if (nth 7 state) 'font-lock-other-comment-face
font-lock-comment-face))))
-- Stefan
^ permalink raw reply [flat|nested] 5+ messages in thread
* Separating // and /**/ comment fontification
@ 2005-06-07 22:09 Ryan Bowman
0 siblings, 0 replies; 5+ messages in thread
From: Ryan Bowman @ 2005-06-07 22:09 UTC (permalink / raw)
I would like /* */ comments to fontify differently
from // comments (in jde-mode).
I added the following to my .emacs but // line
comments are still fontified using
font-lock-comment-face.
(defface new-font-lock-comment-face
'((t (:foreground "Red"))))
(add-hook 'font-lock-mode-hook
(function
(lambda ()
(setq font-lock-keywords
(append font-lock-keywords
'(("//.*$" (0
'new-font-lock-comment-face))))))))
How can I change the fontification of one (or the
other) to use a different face?
----
Ryan Bowman
There is no vi there is only Emacs
----
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2005-06-15 5:30 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <mailman.3751.1118182395.25862.help-gnu-emacs@gnu.org>
2005-06-07 23:00 ` Separating // and /**/ comment fontification Stefan Monnier
2005-06-14 19:13 ` Ryan Bowman
2005-06-14 20:10 ` Ryan Bowman
[not found] <mailman.1.1118779995.2857.help-gnu-emacs@gnu.org>
2005-06-15 5:30 ` Stefan Monnier
2005-06-07 22:09 Ryan Bowman
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).