emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Fontify text between quotes?
@ 2018-11-21 17:30 Will Pierce
  2018-11-21 19:38 ` Jeremie Juste
  0 siblings, 1 reply; 4+ messages in thread
From: Will Pierce @ 2018-11-21 17:30 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 325 bytes --]

Hi all,

I'd like to add a function that changes the face of any text in quotation
marks. I looked a bit into adapting the existing org code for emphasis, but
got bogged down. I'd like "text like this" to use the org-block face.

Any help pointing me in the right direction on this would be much
appreciated!

–W

[-- Attachment #2: Type: text/html, Size: 427 bytes --]

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

* Re: Fontify text between quotes?
  2018-11-21 17:30 Fontify text between quotes? Will Pierce
@ 2018-11-21 19:38 ` Jeremie Juste
  2018-11-21 20:50   ` Will Pierce
  0 siblings, 1 reply; 4+ messages in thread
From: Jeremie Juste @ 2018-11-21 19:38 UTC (permalink / raw)
  To: Will Pierce; +Cc: emacs-orgmode

Hello,

You can in principle tap directly into font lock-mode.
For instance something like

 (add-hook 'org-mode-hook
	   (lambda ()
	     (font-lock-add-keywords nil
				     '(("\\<\\(FIXME\\):" 1 'font-lock-warning-face prepend)
				       ("\\<\\(and\\|or\\|not\\)\\>" .
					'font-lock-keyword-face)))))




would fontify [FIXME:], [and] [or] ,and [not], without the [], in org-mode, See the
doc of font-lock-add-keywords (just stole the code above from it)

I could not achieve what you want though. Don't have enough time and energy
to think about it now, and I'm very bad with regex. :-). But in
principle it should do the job,

Hope this helps,

Jeremie



> Hi all,
>
> I'd like to add a function that changes the face of any text in quotation
> marks. I looked a bit into adapting the existing org code for emphasis, but
> got bogged down. I'd like "text like this" to use the org-block face.
>
> Any help pointing me in the right direction on this would be much
> appreciated!
>
> –W

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

* Re: Fontify text between quotes?
  2018-11-21 19:38 ` Jeremie Juste
@ 2018-11-21 20:50   ` Will Pierce
  2018-11-22  6:44     ` Eric S Fraga
  0 siblings, 1 reply; 4+ messages in thread
From: Will Pierce @ 2018-11-21 20:50 UTC (permalink / raw)
  To: jeremiejuste; +Cc: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 1863 bytes --]

Ahah! Thanks for the tip!

Added the following to my init:

;; use org-block face in verse/quote blocks
(setq org-fontify-quote-and-verse-blocks t)

;; use org-block for smart-quoted text
(defun my-org-smart-quote-fontify ()
  "Use org-block face for text between smart quotes."
  (font-lock-add-keywords nil
                          '(("“\\(.*?\\)”" . 'org-block))))
(add-hook 'org-mode-hook 'my-org-smart-quote-fontify)
;; (remove-hook 'org-mode-hook 'my-org-smart-quote-fontify)

It doesn't work across newlines, but that's alright for now.

On Wed, 21 Nov 2018 at 13:38, Jeremie Juste <jeremiejuste@gmail.com> wrote:

> Hello,
>
> You can in principle tap directly into font lock-mode.
> For instance something like
>
>  (add-hook 'org-mode-hook
>            (lambda ()
>              (font-lock-add-keywords nil
>                                      '(("\\<\\(FIXME\\):" 1
> 'font-lock-warning-face prepend)
>                                        ("\\<\\(and\\|or\\|not\\)\\>" .
>                                         'font-lock-keyword-face)))))
>
>
>
>
> would fontify [FIXME:], [and] [or] ,and [not], without the [], in
> org-mode, See the
> doc of font-lock-add-keywords (just stole the code above from it)
>
> I could not achieve what you want though. Don't have enough time and energy
> to think about it now, and I'm very bad with regex. :-). But in
> principle it should do the job,
>
> Hope this helps,
>
> Jeremie
>
>
>
> > Hi all,
> >
> > I'd like to add a function that changes the face of any text in quotation
> > marks. I looked a bit into adapting the existing org code for emphasis,
> but
> > got bogged down. I'd like "text like this" to use the org-block face.
> >
> > Any help pointing me in the right direction on this would be much
> > appreciated!
> >
> > –W
>

[-- Attachment #2: Type: text/html, Size: 2665 bytes --]

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

* Re: Fontify text between quotes?
  2018-11-21 20:50   ` Will Pierce
@ 2018-11-22  6:44     ` Eric S Fraga
  0 siblings, 0 replies; 4+ messages in thread
From: Eric S Fraga @ 2018-11-22  6:44 UTC (permalink / raw)
  To: Will Pierce; +Cc: emacs-orgmode

On Wednesday, 21 Nov 2018 at 14:50, Will Pierce wrote:
> Ahah! Thanks for the tip!
>
> Added the following to my init:
>
> ;; use org-block face in verse/quote blocks
> (setq org-fontify-quote-and-verse-blocks t)
>
> ;; use org-block for smart-quoted text
> (defun my-org-smart-quote-fontify ()
>   "Use org-block face for text between smart quotes."
>   (font-lock-add-keywords nil
>                           '(("“\\(.*?\\)”" . 'org-block))))

You might want to replace the .* with [^"]* to avoid cases where you
have two or more quoted bits of text in a single line leading to
fontification of all the text between the first " and the last ".

(untested)
-- 
Eric S Fraga via Emacs 27.0.50, Org release_9.1.14-1035-gfeb442

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

end of thread, other threads:[~2018-11-22  6:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-11-21 17:30 Fontify text between quotes? Will Pierce
2018-11-21 19:38 ` Jeremie Juste
2018-11-21 20:50   ` Will Pierce
2018-11-22  6:44     ` Eric S Fraga

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

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).