all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Differing string delimiters for font-lock
@ 2013-02-14 20:40 Evans Winner
  2013-02-15  0:46 ` Evans Winner
  0 siblings, 1 reply; 3+ messages in thread
From: Evans Winner @ 2013-02-14 20:40 UTC (permalink / raw
  To: help-gnu-emacs

Is there a reasonable way to use two differing delimiters
for strings for font-lock purposes?

Concretely, what I am doing is this: I am trying to define a
`text-mode'-like mode with define-generic-mode that will
fontify strings set off with quotes; but I am also using
typopunct-mode to get "smart" quotes, “like this.”

So in the buffer, strings are not marked off by a single
character, but a pair of matching characters, like
parentheses.

I have tried something along the lines of --

   (modify-syntax-entry ?“ "\"")
   (modify-syntax-entry ?” "\"")

and then later

  '("\\s\"\\|\\s|" . font-lock-string-face)

This almost works, but it doesn’t end fontification at the
close-quote, and instead continues until it finds the next
open quote, where it then ends fontification.

Perhaps the answer is to define them as open and close
delimiters, but then I don’t know how to create a regexp to
fontify everything within those delimiters.  So... that’s as
far as I’ve gotten.



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Differing string delimiters for font-lock
  2013-02-14 20:40 Differing string delimiters for font-lock Evans Winner
@ 2013-02-15  0:46 ` Evans Winner
  2013-02-15 14:44   ` Stefan Monnier
  0 siblings, 1 reply; 3+ messages in thread
From: Evans Winner @ 2013-02-15  0:46 UTC (permalink / raw
  To: help-gnu-emacs

I think I've answered my question -- at least it appears to work.  I've stopped using define-generic-mode.  Anyway, what I was looking for is:

(font-lock-add-keywords nil
  '(("“[^”]*”" 0 font-lock-string-face)))




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Differing string delimiters for font-lock
  2013-02-15  0:46 ` Evans Winner
@ 2013-02-15 14:44   ` Stefan Monnier
  0 siblings, 0 replies; 3+ messages in thread
From: Stefan Monnier @ 2013-02-15 14:44 UTC (permalink / raw
  To: help-gnu-emacs

> I think I've answered my question -- at least it appears to work.  I've
> stopped using define-generic-mode.  Anyway, what I was looking for is:
> (font-lock-add-keywords nil
>   '(("“[^”]*”" 0 font-lock-string-face)))

BTW, please do yourself a favor and use define-derived-mode rather than
define-generic-mode.
If you need help, just post your define-generic-mode and we'll translate
it to define-derived-mode for you.


        Stefan


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-02-15 14:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-02-14 20:40 Differing string delimiters for font-lock Evans Winner
2013-02-15  0:46 ` Evans Winner
2013-02-15 14:44   ` Stefan Monnier

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.