summaryrefslogtreecommitdiff
path: root/hsys-org-roam.el
blob: a509f7f6dd5608b32da4a1b8184641e0aa0a0a78 (plain)
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
;;; hsys-org.el --- GNU Hyperbole support functions for Org Roam  -*- lexical-binding: t; -*-
;;
;; Author:       Bob Weiner
;;
;; Orig-Date:    26-Feb-23 at 11:20:15 by Bob Weiner
;; Last-Mod:     23-Apr-23 at 22:05:38 by Mats Lidell
;;
;; SPDX-License-Identifier: GPL-3.0-or-later
;;
;; Copyright (C) 2023  Free Software Foundation, Inc.
;; See the "HY-COPY" file for license information.
;;
;; This file is part of GNU Hyperbole.

;;; Commentary:
;;
;;   The autoloaded function, `hsys-org-roam-consult-grep', uses
;;   consult-grep to do a full-text search over notes included
;;   into the user's Org Roam database.
;;
;;   Use `org-roam-migrate-wizard' to import any Org note files and
;;   assign them UUIDs required for indexing by Org Roam.

;;; Code:

;;; ************************************************************************
;;; Public declarations
;;; ************************************************************************

(defvar consult-org-roam-grep-func)
(defvar org-roam-directory)
(declare-function org-roam-db-autosync-mode "ext:org-roam")

;;; ************************************************************************
;;; Public functions
;;; ************************************************************************

;;;###autoload
(defun hsys-org-roam-consult-grep ()
  "Search with the consult org-roam grep command.
Interactively show all matches from `hyrolo-file-list'.
Prompt for the search pattern."
  (interactive)
  (unless (package-installed-p 'consult-org-roam)
    (package-install 'consult-org-roam))
  (require 'consult-org-roam)
  (let ((grep-func (when (and (boundp 'consult-org-roam-grep-func)
			      (fboundp consult-org-roam-grep-func))
		     consult-org-roam-grep-func)))
    (if grep-func
	(funcall grep-func org-roam-directory)
      (error "(hyrolo-consult-org-roam-grep): `%s' is an invalid function"
	     consult-org-roam-grep-func))))

(provide 'hsys-org-roam)

;;  Don't byte-compile since may not have org-roam package and then
;;  will get an 'org-roam-directory' undefined error.

;;  Local Variables:
;;  no-byte-compile: t
;;  End:

;;; hsys-org-roam.el ends here