emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] Inline code block syntax highlighting absence


From: Nicolas Goaziou
Subject: Re: [O] Inline code block syntax highlighting absence
Date: Fri, 26 Oct 2018 17:49:36 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux)

Hello,

stardiviner <address@hidden> writes:

> I did a search of "font-lock-add-keywords", "begin_src", "src_" etc in
> Org Mode source code, but have not found exact place where fontify
> function are. So I don't know where to modify the source code. Now I put
> my current config here:

[...]

> (font-lock-add-keywords
>  'org-mode
>  '(("\\(src_\\)\\([^[{]+\\)\\(\\[:.*\\]\\)\\({\\)\\([^}]*\\)\\(}\\)"
>     (1 '(:foreground "black" :weight 'normal :height 0.1)) ; src_ part
>     (2 '(:foreground "cyan" :weight 'bold :height 0.8 :box '(:color "light 
> gray"))) ; "lang" part.
>     (3 '(:foreground "#555555" :height 0.7)) ; [:header arguments] part.
>     (4 '(:foreground "#333333")) ; {
>     (5 'org-code) ; "code..." part.
>     (6 '(:foreground "#333333")) ; }
>     ))
>  'append)

The first thing is to define new faces, or re-use existing one, instead
of creating them ad-hoc.

Then you need to create a function like `org-fontify-entities'.

For example:

--8<---------------cut here---------------start------------->8---
(defun org-fontify-inline-code (limit)
  (when (re-search-forward "src_..." limit t)
    ;; here you need to make as sure as possible that you are really
    ;; at some inline code.  You cannot really parse inline source code
    ;; or inline Babel calls with a regexp only.
    (org-remove-flyspell-overlays-in beg end)
    (add-text-properties beg end (list 'font-lock-fontified t 'face ...))
    t))
--8<---------------cut here---------------end--------------->8---

You then register the function above in `org-set-font-lock-defaults.

Do you want to implement this?

Regards,

-- 
Nicolas Goaziou



reply via email to

[Prev in Thread] Current Thread [Next in Thread]