org links are useful for making your org-mode documents more terse.

1
2
3
4
$EMACSD/config/org/org-google.el
$EMACSD/config/org/org-man.el
$EMACSD/config/org/org-rifle.el
$EMACSD/config/org/org-youtube.el

org-google.el, for instance will allow you to write google searches into your org mode.

org-google

Example

You can then type C-c C-o on the link to run the google search.

1
[[google:emacs plugins]]

This is how it appears in org-mode.

[google:emacs plugins](emacs plugins)

org-google.el source

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
;;; org-man.el - Support for links to google queries in Org

(require 'org)

;; org-add-link-type removes the google: from the start, I think

(org-add-link-type "google" 'org-g-open)
(org-add-link-type "goo" 'org-g-open)
(org-add-link-type "gl" 'org-g-open)
(org-add-link-type "gr" 'org-g-open)
(org-add-link-type "gg" 'org-g-open)
(add-hook 'org-store-link-functions 'org-g-store-link)

;; create a function, gr to open googler in a tmux split given search terms

;; vim +/"(defun my-google (&optional terms)" "$EMACSD/config/my-utils.2.el"
(defcustom org-g-command 'my-google
  "The Emacs command to be used to run a google search."
  :group 'org-link
  :type '(choice (const my-google) (const w3m)))

(defun org-g-open (terms)
  "Google search for something
TERMS should be a set of query terms that is passed to googler."
  (funcall org-g-command terms))

(defun org-g-store-link ()
  "Store a link to a google search."
  (when (memq major-mode '(eww-mode))
    ;; This is a google search page, we do make this link
    (let* ((terms (org-g-get-page-terms))
           (link (concat "google:" terms))
           (description (format "Google for %s" terms)))
      (org-store-link-props
       :type "google"
       :link link
       :description description))))

;; This is not necessary. It would get the google search title, but we
;; only need the terms for the desription

(defun org-g-get-page-terms ()
  "Extract the query from the buffer name. Not sure how to do this"
  (if (not nil)
      "google-search"
    (error "Cannot create link to this google search")))

(provide 'org-google)

;;; org-google.el ends here

org-rifle

My immediate use-case for this was when I wanted to embed images into my org-mode document but have them open with an external utility.

Example

1
[[rifle:supervised-learning-algorithms.png][Supervised Learning Algorithms - screenshot of Google]]

org-rifle.el source

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
;;; org-rifle.el - Support for opening a path with rifle

(require 'org)


(org-add-link-type "rifle" 'org-rifle-open)
(add-hook 'org-store-link-functions 'org-rifle-store-link)


(defcustom org-rifle-command 'spv-rifle
  "The Emacs command to be used to display a rifle page."
  :group 'org-link
  :type '(choice (const spv-rifle)))

(setq org-rifle-command 'spv-rifle)

(defun org-rifle-open (path)
  "Visit the manpage on PATH.
PATH should be a topic that can be thrown at the rifle command."
  (funcall org-rifle-command path))

(defun org-rifle-store-link ()
  "Store a link to a manpage."
  (when (memq major-mode '(Rifle-mode woman-mode))
    ;; This is a rifle page, we do make this link
    (let* ((page (org-rifle-get-page-name))
           (link (concat "rifle:" page))
           (description (format "rifle %s" page)))
      (org-store-link-props
       :type "rifle"
       :link link
       :description description))))


(defun org-rifle-get-page-name ()
  "Extract the page name from the buffer name."
  ;; This works for both `Rifle-mode' and `woman-mode'.
  (if (string-match " \\(\\S-+\\)\\*" (buffer-name))
      (match-string 1 (buffer-name))
    (error "Cannot create link to this rifle page")))

(provide 'org-rifle)

;;; org-rifle.el ends here