From mboxrd@z Thu Jan 1 00:00:00 1970 From: Kaushal Subject: Reason for org meta line fontification to have the highest priority? Date: Wed, 13 May 2015 21:52:32 +0000 Message-ID: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=001a1136b3b6e4ec3d0515fda078 Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:44006) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YseZw-0006Cu-Qf for emacs-orgmode@gnu.org; Wed, 13 May 2015 17:52:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YseZv-0004xG-2E for emacs-orgmode@gnu.org; Wed, 13 May 2015 17:52:36 -0400 Received: from mail-yh0-x22c.google.com ([2607:f8b0:4002:c01::22c]:34796) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YseZu-0004wI-JT for emacs-orgmode@gnu.org; Wed, 13 May 2015 17:52:35 -0400 Received: by yhom41 with SMTP id m41so16967437yho.1 for ; Wed, 13 May 2015 14:52:33 -0700 (PDT) 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-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: "emacs-orgmode@gnu.org" --001a1136b3b6e4ec3d0515fda078 Content-Type: text/plain; charset=ISO-8859-1 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)) --001a1136b3b6e4ec3d0515fda078 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
Hi,

I came across a situation where I h= ad an org link inside a figure caption.

But the wa= y the org-set-font-lock-defaults is written, the org-link face gets overrid= den by org-meta-line face because the meta line fontification is done AFTER= link fontification.

Is there a specific reason wh= y the meta line fontification has to be done at the very last?
I have edited this function (just moved the meta line fontific= ation above link fontification) and now I can see a link fontification with= in the caption.

I would like to understand if ther= e is a reason why one should not move this order.

= Thanks!

(defun org-set-font-lock-defaults ()<= /div>
=A0 "Set font lock defaults for the current buffer."
=A0 (let* ((em org-fontify-emphasized-text)
(lk org-activate-lin= ks)
(org-font-lock-extra-keywords
=A0(list
=A0 ;; Call the hook
=A0 = 9;(org-font-lock-hook)
=A0 ;; Headlines
=A0 `(,(if org-fontify-whole-head= ing-line
=A0"^\\(\\**\\)\\(\\* \\)\\(.*\n?\\)"
"^\\(\\**\= \)\\(\\* \\)\\(.*\\)")
=A0 =A0 (1 (org-get-level-face 1))
= =A0 =A0 (= 2 (org-get-level-face 2))
=A0 =A0 (3 (org-get-level-face 3)))
=A0 ;; Tabl= e lines
= =A0 '("^[ \t]*\\(\\(|\\|\\+-[-+]\\).*\\S-\\)"
<= div> =A0 = =A0 (1 'org-table t))
=A0 ;; Table internals
=A0 '("^[ \t]*|= \\(?:.*?|\\)? *\\(:?=3D[^|\n]*\\)" (1 'org-formula t))
<= span class=3D"Apple-tab-span" style=3D"white-space:pre"> =A0 '(= "^[ \t]*| *\\([#*]\\) *|" (1 'org-formula t))
=A0 '(&quo= t;^[ \t]*|\\( *\\([$!_^/]\\) *|.*\\)|" (1 'org-formula t))
=A0 &#= 39;("| *\\(<[lrc]?[0-9]*>\\)" (1 'org-formula t))
=
=A0 = ;; Drawers
=A0 (list org-drawer-regexp '(0 'org-special-keyword t)= )
=A0 (list "^[ \t]*:END:" '(0 'org-special-keyword t))<= /div>
= =A0 ;; Properties
=A0 (list org-property-re
'(1 'org-special-ke= yword t)
'(3 'org-property-value t))
=A0 =A0 =A0 =A0 = =A0 =A0;; Begin edit by KM
=A0 ;; Blocks and meta lines
=A0 = =A0 =A0 =A0 =A0 =A0;; Move meta line fontification BEFORE the link fontific= ation so that
=A0 =A0 =A0 =A0 =A0 =A0;; if meta lines like figure= or table captions have links then the
=A0 =A0 =A0 =A0 =A0 =A0;; = link fontification can override the meta line fontification
=A0 '(org-= fontify-meta-lines-and-blocks)
=A0 =A0 =A0 =A0 =A0 =A0;; End edit= by KM
= =A0 ;; Links
=A0 (if (memq 'tag lk) '(org-activate-tags (1= 'org-tag prepend)))
=A0 (if (memq 'angle lk) '(org-activate-a= ngle-links (0 'org-link t)))
=A0 (if (memq 'plain lk) '(org-ac= tivate-plain-links (0 'org-link t)))
=A0 (if (memq 'bracket lk) &#= 39;(org-activate-bracket-links (0 'org-link t)))
=A0 (if (memq 'r= adio lk) '(org-activate-target-links (0 'org-link t)))
=A0 (if (me= mq 'date lk) '(org-activate-dates (0 'org-date t)))
<= span class=3D"Apple-tab-span" style=3D"white-space:pre"> =A0 (if (m= emq 'footnote lk) '(org-activate-footnote-links))
=A0 =A0= =A0 =A0 =A0 =A0;; Targets.
=A0 =A0 =A0 =A0 =A0 =A0(list org-any-= target-regexp '(0 'org-target t))
=A0 ;; Diary sexps.
=A0 '(&= quot;^&?%%(.*\\|<%%([^>\n]*?>" (0 'org-sexp-date t))<= /div>
= =A0 ;; Macro
=A0 '("{{{.+}}}" (0 'org-macro t))
=A0 &#= 39;(org-hide-wide-columns (0 nil append))
=A0 ;; TODO keyword
=A0 (list (= format org-heading-keyword-regexp-format
org-todo-regexp)
'(2 (org= -get-todo-face 2) t))
=A0 ;; DONE
=A0 (if org-fontify-done-headline
=
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(list (format org-heading-keyword-regex= p-format
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0(concat
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 "\\(?:"
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0 =A0 =A0 =A0 =A0 (mapconcat 'regexp-quote org-done-keywords "\= \|")
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0 "\\)"))
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0'(2 'org-headline-done t))
=A0 =A0 nil)
=A0 ;; Priorities
= =A0 '(org-font-lock-add-priority-faces)
=A0 ;; Tags
=A0 '(org-fon= t-lock-add-tag-faces)
=A0 ;; Tags groups
=A0 (if (and org-group-tags org-= tag-groups-alist)
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(list (concat or= g-outline-regexp-bol ".+\\(:"
=A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(regexp-opt (mapcar 'car org-tag-gro= ups-alist))
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0":\\).*$")
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0'(1 'org-tag-group prepend)))
=A0 ;; Special keywords
=
=A0 = (list (concat "\\<" org-deadline-string) '(0 'org-spec= ial-keyword t))
=A0 (list (concat "\\<" org-scheduled-string)= '(0 'org-special-keyword t))
=A0 (list (concat "\\<"= org-closed-string) '(0 'org-special-keyword t))
=A0 (list (concat= "\\<" org-clock-string) '(0 'org-special-keyword t))<= /div>
= =A0 ;; Emphasis
=A0 (if em
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(if (= featurep 'xemacs)
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0'= ;(org-do-emphasis-faces (0 nil append))
=A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0'(org-do-emphasis-faces)))
=A0 ;; Checkboxes
=A0 '(&qu= ot;^[ \t]*\\(?:[-+*]\\|[0-9]+[.)]\\)[ \t]+\\(?:\\[@\\(?:start:\\)?[0-9]+\\]= [ \t]*\\)?\\(\\[[- X]\\]\\)"
=A0 =A0 1 'org-checkbox prepend)
= =A0 (if (cdr (assq 'checkbox org-list-automatic-rules))
=A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0'("\\[\\([0-9]*%\\)\\]\\|\\[\\([0-9]*\\= )/\\([0-9]*\\)\\]"
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(0 (or= g-get-checkbox-statistics-face) t)))
=A0 ;; Description list items
=A0 &#= 39;("^[ \t]*[-+*][ \t]+\\(.*?[ \t]+::\\)\\([ \t]+\\|$\\)"
=A0 = =A0 1 'org-list-dt prepend)
=A0 ;; ARCHIVEd headings
=A0 (list (conca= t
=A0org-outline-regexp-bol
=A0"\\(.*:" org-archive-tag "= ;:.*\\)")
'(1 'org-archived prepend))
=A0 ;; Specials
=A0= '(org-do-latex-and-related)
=A0 '(org-fontify-entities)
=A0 '= ;(org-raise-scripts)
=A0 ;; Code
=A0 '(org-activate-code (1 'org-= code t))
=A0 ;; COMMENT
=A0 (list (format org-heading-keyword-regexp-form= at
(concat "\\("
org-comment-string "\\|" org-qu= ote-string
"\\)"))
'(2 'org-special-keyword t))
=A0 =A0 =A0 =A0 =A0 =A0;; '(org-fontify-meta-lines-and-blocks) ;= Edited by KM
=A0 =A0 =A0 =A0 =A0 =A0)))
=A0 =A0 (setq = org-font-lock-extra-keywords (delq nil org-font-lock-extra-keywords))
=
=A0 =A0 (run-hooks 'org-font-lock-set-keywords-hook)
=A0= =A0 ;; Now set the full font-lock-keywords
=A0 =A0 (org-set-loca= l 'org-font-lock-keywords org-font-lock-extra-keywords)
=A0 = =A0 (org-set-local 'font-lock-defaults
=A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0'(org-font-lock-keywords t nil nil backward-paragrap= h))
=A0 =A0 (kill-local-variable 'font-lock-keywords) nil))

--001a1136b3b6e4ec3d0515fda078--