Skip to content
Newer
Older
100644 66 lines (61 sloc) 2.18 KB
a59470b @seanohalpin Added more link types; removed redundant code
authored Aug 18, 2012
1 ;;; org-link-minor-mode.el -- Enable org-mode links in non-org modes
cee4479 @seanohalpin initial commit
authored Aug 18, 2012
2 ;;
3 ;; Copyright (C) 2012
4 ;; Author: Sean O'Halpin <sean dot ohalpin at gmail dot com>
5 ;;
a59470b @seanohalpin Added more link types; removed redundant code
authored Aug 18, 2012
6 ;; Enables org-mode links of the form:
cee4479 @seanohalpin initial commit
authored Aug 17, 2012
7 ;;
a59470b @seanohalpin Added more link types; removed redundant code
authored Aug 18, 2012
8 ;; http://www.bbc.co.uk
86a8481 @seanohalpin added man: link as example
authored Aug 18, 2012
9 ;; man:emacs
a59470b @seanohalpin Added more link types; removed redundant code
authored Aug 18, 2012
10 ;; <http://www.bbc.co.uk>
cee4479 @seanohalpin initial commit
authored Aug 17, 2012
11 ;; [[http://www.bbc.co.uk][BBC]]
12 ;; [[org-link-minor-mode]]
a59470b @seanohalpin Added more link types; removed redundant code
authored Aug 18, 2012
13 ;; [2012-08-18]
14 ;; <2012-08-18>
cee4479 @seanohalpin initial commit
authored Aug 17, 2012
15 ;;
16 ;; Note that =org-toggle-link-display= will also work when this mode
17 ;; is enabled.
18 ;;
19
20 (require 'org)
21
22 (define-minor-mode org-link-minor-mode
23 "Toggle display of org-mode style bracket links in non-org-mode buffers."
24 :lighter " org-link"
25
27aca66 @seanohalpin added plain links
authored Aug 18, 2012
26 (let ((org-link-minor-mode-keywords
27 (list
a59470b @seanohalpin Added more link types; removed redundant code
authored Aug 18, 2012
28 '(org-activate-angle-links (0 'org-link t))
27aca66 @seanohalpin added plain links
authored Aug 18, 2012
29 '(org-activate-plain-links)
30 '(org-activate-bracket-links (0 'org-link t))
a59470b @seanohalpin Added more link types; removed redundant code
authored Aug 18, 2012
31 '(org-activate-dates (0 'org-date t))
27aca66 @seanohalpin added plain links
authored Aug 18, 2012
32 ))
33 )
34 (if org-link-minor-mode
35 (if (derived-mode-p 'org-mode)
cee4479 @seanohalpin initial commit
authored Aug 17, 2012
36 (progn
27aca66 @seanohalpin added plain links
authored Aug 18, 2012
37 (message "org-mode doesn't need org-link-minor-mode")
38 (org-link-minor-mode -1)
39 )
40 (font-lock-add-keywords nil org-link-minor-mode-keywords t)
9cf93bc @seanohalpin Added key handling (RET to follow link, etc.)
authored Aug 18, 2012
41 (kill-local-variable 'org-mouse-map)
42 (org-set-local 'org-mouse-map
43 (let ((map (make-sparse-keymap)))
44 (define-key map [return] 'org-open-at-point)
45 (define-key map [tab] 'org-next-link)
46 (define-key map [backtab] 'org-previous-link)
47 (define-key map [mouse-2] 'org-open-at-point)
48 (define-key map [follow-link] 'mouse-face)
49 map)
50 )
a59470b @seanohalpin Added more link types; removed redundant code
authored Aug 18, 2012
51 (org-set-local 'org-descriptive-links org-descriptive-links)
27aca66 @seanohalpin added plain links
authored Aug 18, 2012
52 (if org-descriptive-links (add-to-invisibility-spec '(org-link)))
53 (org-set-local 'font-lock-unfontify-region-function
54 'org-unfontify-region)
55 (org-restart-font-lock)
56 )
57 (unless (derived-mode-p 'org-mode)
a59470b @seanohalpin Added more link types; removed redundant code
authored Aug 18, 2012
58 (font-lock-remove-keywords nil org-link-minor-mode-keywords)
59 (org-restart-font-lock)
cee4479 @seanohalpin initial commit
authored Aug 17, 2012
60 )
61 )
62 )
63 )
64
65 (provide 'org-link-minor-mode)
Something went wrong with that request. Please try again.