Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 86 lines (80 sloc) 3.268 kb
a59470ba »
2012-08-18 Added more link types; removed redundant code
1 ;;; org-link-minor-mode.el -- Enable org-mode links in non-org modes
cee4479d »
2012-08-18 initial commit
2 ;;
3 ;; Copyright (C) 2012
4 ;; Author: Sean O'Halpin <sean dot ohalpin at gmail dot com>
5 ;;
a59470ba »
2012-08-18 Added more link types; removed redundant code
6 ;; Enables org-mode links of the form:
cee4479d »
2012-08-18 initial commit
7 ;;
a59470ba »
2012-08-18 Added more link types; removed redundant code
8 ;; http://www.bbc.co.uk
86a84814 »
2012-08-18 added man: link as example
9 ;; man:emacs
a59470ba »
2012-08-18 Added more link types; removed redundant code
10 ;; <http://www.bbc.co.uk>
cee4479d »
2012-08-18 initial commit
11 ;; [[http://www.bbc.co.uk][BBC]]
12 ;; [[org-link-minor-mode]]
a59470ba »
2012-08-18 Added more link types; removed redundant code
13 ;; [2012-08-18]
14 ;; <2012-08-18>
cee4479d »
2012-08-18 initial commit
15 ;;
16 ;; Note that =org-toggle-link-display= will also work when this mode
17 ;; is enabled.
18 ;;
19
20 (require 'org)
21
e660ed02 »
2012-08-25 On exit from mode, remove more of the fontification added
22 (defun org-link-minor-mode-unfontify-region (beg end &optional maybe_loudly)
23 "Remove fontification and activation overlays from links."
24 (font-lock-default-unfontify-region beg end)
25 (let* ((buffer-undo-list t)
26 (inhibit-read-only t) (inhibit-point-motion-hooks t)
27 (inhibit-modification-hooks t)
28 deactivate-mark buffer-file-name buffer-file-truename)
29 (org-decompose-region beg end)
30 (remove-text-properties beg end
31 '(mouse-face t keymap t org-linked-text t
32 invisible t intangible t
33 help-echo t rear-nonsticky t
34 org-no-flyspell t org-emphasis t))
35 (org-remove-font-lock-display-properties beg end)))
36
f2459a08 »
2012-08-20 autoload org-link-minor-mode
37 ;;;###autoload
cee4479d »
2012-08-18 initial commit
38 (define-minor-mode org-link-minor-mode
39 "Toggle display of org-mode style bracket links in non-org-mode buffers."
40 :lighter " org-link"
41
27aca665 »
2012-08-18 added plain links
42 (let ((org-link-minor-mode-keywords
43 (list
a59470ba »
2012-08-18 Added more link types; removed redundant code
44 '(org-activate-angle-links (0 'org-link t))
27aca665 »
2012-08-18 added plain links
45 '(org-activate-plain-links)
46 '(org-activate-bracket-links (0 'org-link t))
a59470ba »
2012-08-18 Added more link types; removed redundant code
47 '(org-activate-dates (0 'org-date t))
27aca665 »
2012-08-18 added plain links
48 ))
49 )
50 (if org-link-minor-mode
51 (if (derived-mode-p 'org-mode)
cee4479d »
2012-08-18 initial commit
52 (progn
27aca665 »
2012-08-18 added plain links
53 (message "org-mode doesn't need org-link-minor-mode")
54 (org-link-minor-mode -1)
55 )
56 (font-lock-add-keywords nil org-link-minor-mode-keywords t)
9cf93bcc »
2012-08-18 Added key handling (RET to follow link, etc.)
57 (kill-local-variable 'org-mouse-map)
58 (org-set-local 'org-mouse-map
59 (let ((map (make-sparse-keymap)))
60 (define-key map [return] 'org-open-at-point)
61 (define-key map [tab] 'org-next-link)
62 (define-key map [backtab] 'org-previous-link)
63 (define-key map [mouse-2] 'org-open-at-point)
64 (define-key map [follow-link] 'mouse-face)
65 map)
66 )
a59470ba »
2012-08-18 Added more link types; removed redundant code
67 (org-set-local 'org-descriptive-links org-descriptive-links)
27aca665 »
2012-08-18 added plain links
68 (if org-descriptive-links (add-to-invisibility-spec '(org-link)))
69 (org-set-local 'font-lock-unfontify-region-function
e660ed02 »
2012-08-25 On exit from mode, remove more of the fontification added
70 'org-link-minor-mode-unfontify-region)
27aca665 »
2012-08-18 added plain links
71 (org-restart-font-lock)
72 )
73 (unless (derived-mode-p 'org-mode)
a59470ba »
2012-08-18 Added more link types; removed redundant code
74 (font-lock-remove-keywords nil org-link-minor-mode-keywords)
75 (org-restart-font-lock)
e660ed02 »
2012-08-25 On exit from mode, remove more of the fontification added
76 (remove-from-invisibility-spec '(org-link))
c128e592 »
2012-08-19 use 'standard' noweb syntax; kill local variables on mode exit
77 (kill-local-variable 'org-descriptive-links)
78 (kill-local-variable 'org-mouse-map)
79 (kill-local-variable 'font-lock-unfontify-region-function)
cee4479d »
2012-08-18 initial commit
80 )
81 )
82 )
83 )
84
85 (provide 'org-link-minor-mode)
Something went wrong with that request. Please try again.