From: Kaushal <kaushal.modi@gmail.com>
To: "emacs-orgmode@gnu.org" <emacs-orgmode@gnu.org>
Subject: Reason for org meta line fontification to have the highest priority?
Date: Wed, 13 May 2015 21:52:32 +0000 [thread overview]
Message-ID: <CAFyQvY2D6DBc7=93-SoL_Z=t88knaV1f0D_4WrU9R-e1X1JxHw@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 5458 bytes --]
Hi,
I came across a situation where I had an org link inside a figure caption.
But the way the org-set-font-lock-defaults is written, the org-link face
gets overridden by org-meta-line face because the meta line fontification
is done AFTER link fontification.
Is there a specific reason why the meta line fontification has to be done
at the very last?
I have edited this function (just moved the meta line fontification above
link fontification) and now I can see a link fontification within the
caption.
I would like to understand if there is a reason why one should not move
this order.
Thanks!
(defun org-set-font-lock-defaults ()
"Set font lock defaults for the current buffer."
(let* ((em org-fontify-emphasized-text)
(lk org-activate-links)
(org-font-lock-extra-keywords
(list
;; Call the hook
'(org-font-lock-hook)
;; Headlines
`(,(if org-fontify-whole-heading-line
"^\\(\\**\\)\\(\\* \\)\\(.*\n?\\)"
"^\\(\\**\\)\\(\\* \\)\\(.*\\)")
(1 (org-get-level-face 1))
(2 (org-get-level-face 2))
(3 (org-get-level-face 3)))
;; Table lines
'("^[ \t]*\\(\\(|\\|\\+-[-+]\\).*\\S-\\)"
(1 'org-table t))
;; Table internals
'("^[ \t]*|\\(?:.*?|\\)? *\\(:?=[^|\n]*\\)" (1 'org-formula t))
'("^[ \t]*| *\\([#*]\\) *|" (1 'org-formula t))
'("^[ \t]*|\\( *\\([$!_^/]\\) *|.*\\)|" (1 'org-formula t))
'("| *\\(<[lrc]?[0-9]*>\\)" (1 'org-formula t))
;; Drawers
(list org-drawer-regexp '(0 'org-special-keyword t))
(list "^[ \t]*:END:" '(0 'org-special-keyword t))
;; Properties
(list org-property-re
'(1 'org-special-keyword t)
'(3 'org-property-value t))
;; Begin edit by KM
;; Blocks and meta lines
;; Move meta line fontification BEFORE the link fontification so
that
;; if meta lines like figure or table captions have links then
the
;; link fontification can override the meta line fontification
'(org-fontify-meta-lines-and-blocks)
;; End edit by KM
;; Links
(if (memq 'tag lk) '(org-activate-tags (1 'org-tag prepend)))
(if (memq 'angle lk) '(org-activate-angle-links (0 'org-link t)))
(if (memq 'plain lk) '(org-activate-plain-links (0 'org-link t)))
(if (memq 'bracket lk) '(org-activate-bracket-links (0 'org-link t)))
(if (memq 'radio lk) '(org-activate-target-links (0 'org-link t)))
(if (memq 'date lk) '(org-activate-dates (0 'org-date t)))
(if (memq 'footnote lk) '(org-activate-footnote-links))
;; Targets.
(list org-any-target-regexp '(0 'org-target t))
;; Diary sexps.
'("^&?%%(.*\\|<%%([^>\n]*?>" (0 'org-sexp-date t))
;; Macro
'("{{{.+}}}" (0 'org-macro t))
'(org-hide-wide-columns (0 nil append))
;; TODO keyword
(list (format org-heading-keyword-regexp-format
org-todo-regexp)
'(2 (org-get-todo-face 2) t))
;; DONE
(if org-fontify-done-headline
(list (format org-heading-keyword-regexp-format
(concat
"\\(?:"
(mapconcat 'regexp-quote org-done-keywords
"\\|")
"\\)"))
'(2 'org-headline-done t))
nil)
;; Priorities
'(org-font-lock-add-priority-faces)
;; Tags
'(org-font-lock-add-tag-faces)
;; Tags groups
(if (and org-group-tags org-tag-groups-alist)
(list (concat org-outline-regexp-bol ".+\\(:"
(regexp-opt (mapcar 'car org-tag-groups-alist))
":\\).*$")
'(1 'org-tag-group prepend)))
;; Special keywords
(list (concat "\\<" org-deadline-string) '(0 'org-special-keyword t))
(list (concat "\\<" org-scheduled-string) '(0 'org-special-keyword t))
(list (concat "\\<" org-closed-string) '(0 'org-special-keyword t))
(list (concat "\\<" org-clock-string) '(0 'org-special-keyword t))
;; Emphasis
(if em
(if (featurep 'xemacs)
'(org-do-emphasis-faces (0 nil append))
'(org-do-emphasis-faces)))
;; Checkboxes
'("^[ \t]*\\(?:[-+*]\\|[0-9]+[.)]\\)[
\t]+\\(?:\\[@\\(?:start:\\)?[0-9]+\\][ \t]*\\)?\\(\\[[- X]\\]\\)"
1 'org-checkbox prepend)
(if (cdr (assq 'checkbox org-list-automatic-rules))
'("\\[\\([0-9]*%\\)\\]\\|\\[\\([0-9]*\\)/\\([0-9]*\\)\\]"
(0 (org-get-checkbox-statistics-face) t)))
;; Description list items
'("^[ \t]*[-+*][ \t]+\\(.*?[ \t]+::\\)\\([ \t]+\\|$\\)"
1 'org-list-dt prepend)
;; ARCHIVEd headings
(list (concat
org-outline-regexp-bol
"\\(.*:" org-archive-tag ":.*\\)")
'(1 'org-archived prepend))
;; Specials
'(org-do-latex-and-related)
'(org-fontify-entities)
'(org-raise-scripts)
;; Code
'(org-activate-code (1 'org-code t))
;; COMMENT
(list (format org-heading-keyword-regexp-format
(concat "\\("
org-comment-string "\\|" org-quote-string
"\\)"))
'(2 'org-special-keyword t))
;; '(org-fontify-meta-lines-and-blocks) ; Edited by KM
)))
(setq org-font-lock-extra-keywords (delq nil
org-font-lock-extra-keywords))
(run-hooks 'org-font-lock-set-keywords-hook)
;; Now set the full font-lock-keywords
(org-set-local 'org-font-lock-keywords org-font-lock-extra-keywords)
(org-set-local 'font-lock-defaults
'(org-font-lock-keywords t nil nil backward-paragraph))
(kill-local-variable 'font-lock-keywords) nil))
[-- Attachment #2: Type: text/html, Size: 12792 bytes --]
next reply other threads:[~2015-05-13 21:52 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-13 21:52 Kaushal [this message]
2015-05-13 21:56 ` Reason for org meta line fontification to have the highest priority? Kaushal
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAFyQvY2D6DBc7=93-SoL_Z=t88knaV1f0D_4WrU9R-e1X1JxHw@mail.gmail.com' \
--to=kaushal.modi@gmail.com \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).