PavoDive <[email protected]> writes:

> Christian Moe <[email protected]> writes:
>> Turning off activation of links inside Org comments makes those links
>> visible but unclickable. I for one often find it helpful to keep links
>
> With the change I proposed the link is displayed "normally", *and* can
> be opened with C-c C-o (org-open-at-point), though not with the mouse.

Right. I did say 'unclickable', but tbh, I simply forgot to check if
'C-c C-o' might still work.

> For me, that is interactive enough, but I realize other users may want
> to go for the mouse.

Yes, when I see a link, my reflex is still to click on it, even after
nearly two decades of Emacs use, and with a CTRL key that has taken so
much abuse it's literally only held together with Scotch tape. Sure, I
can live with keyboard-only for a corner case like a commented-out link,
but both would be better.

> I liked the idea of having the link syntax
> explicit in the comment, though.

I wouldn't mind that, personally. It would be kind of analogous to how
emphasis markers are shown in comments even when otherwise hidden.

>> I agree with Max; it would be nice to give them a text property so they
>> stand out from other comment text. Maybe you could look into that?
>
> I will have to study about text properties: my level is very basic at
> the moment, but I will read and try to familiarize with the subject.

Same here, unfortunately.

But I went and looked at the logic in org.el, more precisely, the order
in which the function org-set-font-lock-defaults sets the items of
org-font-lock-extra-keywords.

It looks like links are activated early in the sequence, and in comments
their faces are clobbered by the function
org-fontify-meta-lines-and-blocks (line 6200), which is intentionally an
override. Citations in comments follow /after/ that function, for some
reason, which explains why their fontification, uniquely, is not
overridden in comments.

Indeed, if I try simply moving the link handling down to just before
citations, links in comments are fontified normally (blue and
underlined). See the below diff.

That diff is *not* meant as a proposed patch, it's just for
illustration: I haven't tested this extensively, so I don't know what
fontification I might be messing up by changing this no doubt carefully
thought-out order. And I'm not sure normal link fontification in
comments is exactly the result I'd want.

diff --git a/lisp/org.el b/lisp/org.el
index cb36497f4..fbaa94caf 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -6117,13 +6117,6 @@ needs to be inserted at a specific position in the 
font-lock sequence.")
          '(org-fontify-drawers)
          ;; Diary sexps.
          '("^&?%%(.*\\|<%%([^>\n]*?>" (0 'org-sexp-date t))
-         ;; Link related fontification.
-         '(org-activate-links) ; `org-activate-links' prepends faces
-         (when (memq 'tag org-highlight-links) '(org-activate-tags (1 'org-tag 
prepend)))
-         (when (memq 'radio org-highlight-links) '(org-activate-target-links 
(1 'org-link prepend)))
-         (when (memq 'date org-highlight-links) '(org-activate-dates (0 
'org-date prepend)))
-          ;; `org-activate-footnote-links' prepends faces
-         (when (memq 'footnote org-highlight-links) 
'(org-activate-footnote-links))
           ;; Targets.
           (list org-radio-target-regexp '(0 'org-target prepend))
          (list org-target-regexp '(0 'org-target prepend))
@@ -6201,6 +6194,13 @@ needs to be inserted at a specific position in the 
font-lock sequence.")
           ;; `org-fontify-inline-src-blocks' prepends object boundary
           ;; faces and overrides native faces.
           '(org-fontify-inline-src-blocks)
+          ;; Link related fontification.
+         '(org-activate-links) ; `org-activate-links' prepends faces
+         (when (memq 'tag org-highlight-links) '(org-activate-tags (1 'org-tag 
prepend)))
+         (when (memq 'radio org-highlight-links) '(org-activate-target-links 
(1 'org-link prepend)))
+         (when (memq 'date org-highlight-links) '(org-activate-dates (0 
'org-date prepend)))
+          ;; `org-activate-footnote-links' prepends faces
+         (when (memq 'footnote org-highlight-links) 
'(org-activate-footnote-links))
           ;; Citations.  When an activate processor is specified, if
           ;; specified, try loading it beforehand.
           (progn


Regards,
Christian

Reply via email to