* Active, fontified org hyperlinks in any major mode
@ 2010-03-12 0:27 Paul Sexton
0 siblings, 0 replies; only message in thread
From: Paul Sexton @ 2010-03-12 0:27 UTC (permalink / raw)
To: emacs-orgmode
To activate and correctly fontify org [[hyperlinks]] in any
major mode, add the following to your .emacs:
(defun orgl-do-font-lock (add-or-remove)
"Add or remove font-lock rules for org hyperlinks."
(funcall add-or-remove nil '((org-activate-bracket-links (0 'org-link t)))))
(defun orgl-enable ()
"Enable fontification of org-style hyperlinks in the current buffer."
(interactive)
;; The following variable has to be bound to a string, or opening links
;; will not work.
;; There is probably a more elegant solution.
(unless org-todo-line-tags-regexp
(set (make-local-variable 'org-todo-line-tags-regexp)
"DSFSFSFSF_UTTER_NONSENSE_TAG_SDSDFSFDF"))
(orgl-do-font-lock 'font-lock-add-keywords)
(font-lock-fontify-buffer))
(defun orgl-disable ()
"Disable fontification of org-style hyperlinks in the current buffer."
(interactive)
(remove-text-properties
(point-min) (point-max)
'(mouse-face t keymap t org-linked-text t
invisible t intangible t
org-no-flyspell t))
(orgl-do-font-lock 'font-lock-remove-keywords)
(font-lock-fontify-buffer))
;; Change lisp-mode-hook to whatever you want
(add-hook 'lisp-mode-hook 'orgl-enable)
I was amazed at how easy this was. The most obvious use for me is to put
[[hyperlinks]] in source code comments. The link behaves the same as in org
mode, i.e. by default it looks for a matching <<target>>, then searches for
the text of the link starting from the top of the buffer.
Useful extensions would be:
- Figure out how to force hiding of the [[ ... ]] brackets. They disappear
only if the text is in the 'default' face.
- Fontification of <<targets>> to make them stand out would be useful
- Figure out how to define special link types outside org mode proper.
eg in an emacs lisp file it would be good if the link [[defun:my-function]]
would jump to a "(defun my-function ...." toplevel form.
Paul
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2010-03-12 0:28 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-12 0:27 Active, fontified org hyperlinks in any major mode Paul Sexton
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).