From mboxrd@z Thu Jan 1 00:00:00 1970 From: Will Pierce Subject: Re: Fontify text between quotes? Date: Wed, 21 Nov 2018 14:50:37 -0600 Message-ID: References: <87r2fenrv3.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="0000000000008c08c1057b32e8c1" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:58346) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gPZSo-0001gJ-0V for emacs-orgmode@gnu.org; Wed, 21 Nov 2018 15:51:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gPZSl-0003n4-SD for emacs-orgmode@gnu.org; Wed, 21 Nov 2018 15:51:09 -0500 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]:38160) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gPZSj-0003hV-NC for emacs-orgmode@gnu.org; Wed, 21 Nov 2018 15:51:05 -0500 Received: by mail-pl1-x62a.google.com with SMTP id e5so7129794plb.5 for ; Wed, 21 Nov 2018 12:51:05 -0800 (PST) In-Reply-To: <87r2fenrv3.fsf@gmail.com> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: jeremiejuste@gmail.com Cc: emacs-orgmode@gnu.org --0000000000008c08c1057b32e8c1 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 '(("=E2=80=9C\\(.*?\\)=E2=80=9D" . '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 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 ener= gy > 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 quotati= on > > 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! > > > > =E2=80=93W > --0000000000008c08c1057b32e8c1 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Ahah! Thanks for the tip= !

Added the following to my init:

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

;; use org-block fo= r smart-quoted text
(defun my-org-smart-quote-fontify ()
=C2=A0 "Use org-block face for text between smart quotes."
=C2=A0 (font-lock-add-keywords nil
=C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 '((&= quot;=E2=80=9C\\(.*?\\)=E2=80=9D" . 'org-block))))
(add-= hook 'org-mode-hook 'my-org-smart-quote-fontify)
;; (remo= ve-hook 'org-mode-hook 'my-org-smart-quote-fontify)

It doesn't work across newlines, but that's al= right 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

=C2=A0(add-hook 'org-mode-hook
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(lambda ()
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(font-lock-add-keywords nil=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0'(("\\&= lt;\\(FIXME\\):" 1 'font-lock-warning-face prepend)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0("\\= <\\(and\\|or\\|not\\)\\>" .
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 'fon= t-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 en= ergy
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 qu= otation
> 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 or= g-block face.
>
> Any help pointing me in the right direction on this would be much
> appreciated!
>
> =E2=80=93W
--0000000000008c08c1057b32e8c1--