-
-
Notifications
You must be signed in to change notification settings - Fork 47
/
Copy pathorb-helm.el
98 lines (77 loc) · 3.59 KB
/
orb-helm.el
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
;;; orb-helm.el --- ORB support form Helm -*- lexical-binding: t -*-
;; Copyright © 2020-2022 Mykhailo Shevchuk
;; Author: Mykhailo Shevchuk <[email protected]>
;; URL: https://github.com/org-roam/org-roam-bibtex
;; Soft dependencies: projectile, persp-mode, helm, ivy, hydra
;; This file is NOT part of GNU Emacs.
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 3, or (at your option)
;; any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License along with
;; this program; see the file LICENSE. If not, visit
;; <https://www.gnu.org/licenses/>.
;;; Commentary:
;;; Code:
;; ============================================================================
;;;; Dependencies
;; ============================================================================
(require 'orb-utils)
(require 'helm-bibtex)
(require 'helm-source)
(declare-function orb-insert-edit-note "org-roam-bibtex" (citekey))
(defvar orb-note-actions-default)
(defvar orb-note-actions-extra)
(defvar orb-note-actions-user)
;; ============================================================================
;;;; Note actions
;; ============================================================================
(orb-note-actions-defun helm
(helm :sources
`(((name . ,name)
(candidates . ,candidates)
(action . (lambda (f)
(funcall f (list ,citekey))))))))
;; ============================================================================
;;;; Orb insert
;; ============================================================================
(defvar helm-source-orb-insert
(helm-build-sync-source "BibTeX entries"
:header-name (lambda (name)
(format "%s: " name))
:candidates 'helm-bibtex-candidates
:filtered-candidate-transformer 'helm-bibtex-candidates-formatter
:action (helm-make-actions
"Edit note & insert a link" 'helm-orb-insert-edit-note
"Open PDF, URL or DOI" 'helm-bibtex-open-any
"Open URL or DOI in browser" 'helm-bibtex-open-url-or-doi
"Insert citation" 'helm-bibtex-insert-citation
"Insert reference" 'helm-bibtex-insert-reference
"Insert BibTeX key" 'helm-bibtex-insert-key
"Insert BibTeX entry" 'helm-bibtex-insert-bibtex
"Attach PDF to email" 'helm-bibtex-add-PDF-attachment
"Show entry" 'helm-bibtex-show-entry
"Add PDF to library" 'helm-bibtex-add-pdf-to-library))
"Helm source to use with `orb-insert'.
A copy of `helm-source-bibtex', in which \"Edit notes\" is made
the first (default) action. This action calls `helm-orb-insert-edit-note'.
Only relevant when `orb-insert-interface' is `helm-bibtex'.")
(helm-bibtex-helmify-action orb-insert-edit-note helm-orb-insert-edit-note)
(defun orb-helm-insert (&optional clear-cache)
"Run `helm-bibtex'.
If optional CLEAR-CACHE is non-nil, re-create `bibtex-completion-cache'.
This is a simple wrapper to be run from `orb-insert'."
(let ((helm-source-bibtex helm-source-orb-insert))
(helm-bibtex clear-cache)))
(provide 'orb-helm)
;;; orb-helm.el ends here
;; Local Variables:
;; coding: utf-8
;; fill-column: 79
;; End: