Compare commits

..

10 Commits

Author SHA1 Message Date
Wetlize
9401fad1b2 (experimental): react to directory related events in the database
With filenotify events related to subdirectories, automatically
invalidate no longer valid entries and add the new ones as they appear.
2021-08-23 01:22:49 +03:00
Wetlize
1c3d3098c7 allow hot swapping of org-roam-db-autosync-update-method 2021-08-22 15:39:03 +03:00
Jethro Kuan
15dfb85bd1 ignore hidden directories 2021-08-20 15:25:36 +08:00
Jethro Kuan
0d0ae01684 use filenotify-recursive 2021-08-19 03:14:49 +08:00
Wetlize
6135731eed revert "move (require 'filenotify) under the "update method" function"
Revert c450dbd054.

We sniff for file-notify--library at the top level, so it's required
there. Otherwise it will error during the loading.
2021-08-17 21:00:04 +03:00
Wetlize
aac41a22e4 update org-roam-compat.el 2021-08-17 20:53:40 +03:00
Wetlize
c450dbd054 move (require 'filenotify) under the "update method" function 2021-08-17 20:53:38 +03:00
Wetlize
33d8792f19 fix and refactor things
- restructure the file a bit
- move setup logic for update method to its own function
- namespace autosync and filenotify related things
- rewrite org-roam-db-fn-callback (now org-roam-db-autosync--filenotify-update)
  to actually react to changes. Previously it wouldn't do anything.
2021-08-17 20:25:00 +03:00
Jethro Kuan
87b2359d6d fix lints 2021-08-17 19:11:47 +08:00
Jethro Kuan
210073c7d2 (feat)db: use file-notify to keep track trigger db updates 2021-08-17 18:55:22 +08:00
17 changed files with 252 additions and 374 deletions

View File

@@ -1,36 +1,9 @@
# Changelog # Changelog
## 2.1.0 ## 1.2.4 (TBD)
### Added ### Added
- [#1709](https://github.com/org-roam/org-roam/pull/1709) added ability to specify default value in org-roam capture templates
- [#1710](https://github.com/org-roam/org-roam/pull/1710) added `org-roam-extract-subtree`
- [#1720](https://github.com/org-roam/org-roam/pull/1720) added `org-roam-db-update-on-save`
- [#1758](https://github.com/org-roam/org-roam/pull/1758) added `org-roam-db-autosync-mode`, replacing `org-roam-setup` and `org-roam-teardown`
### Removed
- [#1716](https://github.com/org-roam/org-roam/pull/1716) helper function `org-roam-get-keyword` is now obsolete: prefer `org-collect-keywords`
### Changed
- [#1595](https://github.com/org-roam/org-roam/pull/1595), [#1724](https://github.com/org-roam/org-roam/pull/1724) Major refactoring and restructuring of the codebase
- [#1655](https://github.com/org-roam/org-roam/pull/1655) improved org-roam contents preview
- [#1741](https://github.com/org-roam/org-roam/pull/1741) expose `org-roam-capture-` keys in interactive commands
- [#1786](https://github.com/org-roam/org-roam/pull/1786) org-roam-version now outputs commit hash if found
- [#1788](https://github.com/org-roam/org-roam/pull/1788) the point is not moved if the node is already visited
### Fixed
- [#1608](https://github.com/org-roam/org-roam/pull/1608) migration: empty ROAM_REFS are now removed
- [#1609](https://github.com/org-roam/org-roam/pull/1609) migration: fixed file-link replacement
- [#1653](https://github.com/org-roam/org-roam/pull/1653) migration: fixed tags migration
- [#1694](https://github.com/org-roam/org-roam/pull/1694) core: nodes with no title are now skipped
- [#1637](https://github.com/org-roam/org-roam/pull/1637) core: fix org-ref multi-cite links not being split
- [#1651](https://github.com/org-roam/org-roam/pull/1651) core: fix org-roam-file-p crashing when there is no corresponding file
- [#1705](https://github.com/org-roam/org-roam/pull/1705) core: fix for add/remove of file-level tags
- [#1769](https://github.com/org-roam/org-roam/pull/1769) core: gracefully handle absence of `org-id-locations-file`
- [#1713](https://github.com/org-roam/org-roam/pull/1713) capture: check for file-existence before template insertion
- [#1725](https://github.com/org-roam/org-roam/pull/1725) db: always compute hash of encrypted file to prevent re-processing of encrypted files
## 2.0.0
### Added
- [#1396](https://github.com/org-roam/org-roam/pull/1396) add option to choose between prepending, appending, and omitting `roam_tags` in file completion - [#1396](https://github.com/org-roam/org-roam/pull/1396) add option to choose between prepending, appending, and omitting `roam_tags` in file completion
- [#1270](https://github.com/org-roam/org-roam/pull/1270) capture: create OLP if it does not exist. Removes need for OLP setup in `:head`. - [#1270](https://github.com/org-roam/org-roam/pull/1270) capture: create OLP if it does not exist. Removes need for OLP setup in `:head`.
- [#1353](https://github.com/org-roam/org-roam/pull/1353) support file-level property drawers - [#1353](https://github.com/org-roam/org-roam/pull/1353) support file-level property drawers
@@ -55,6 +28,7 @@
- [#1403](https://github.com/org-roam/org-roam/issues/1403) fixed inconsistency between how we write and read props like alias and tags - [#1403](https://github.com/org-roam/org-roam/issues/1403) fixed inconsistency between how we write and read props like alias and tags
- [#1409](https://github.com/org-roam/org-roam/issues/1398) prevent inclusion of non-org-roam files in `org-roam-dailies--list-files` - [#1409](https://github.com/org-roam/org-roam/issues/1398) prevent inclusion of non-org-roam files in `org-roam-dailies--list-files`
- [#1542](https://github.com/org-roam/org-roam/issues/1542) fix files not excluded when `org-roam-list-files-commands` is nil - [#1542](https://github.com/org-roam/org-roam/issues/1542) fix files not excluded when `org-roam-list-files-commands` is nil
- [#1705](https://github.com/org-roam/org-roam/pull/1705) fix for add/remove of file-level tags
## 1.2.3 (13-11-2020) ## 1.2.3 (13-11-2020)

174
README.md
View File

@@ -33,170 +33,38 @@ solution for anyone already using Org-mode for their personal wiki.
## Installation ## Installation
Down below you will find basic installation instructions for how to quickly You can install `org-roam` using `package.el`:
install `org-roam` using various environments for various purposes. For more
detailed information, please read the [manual][docs].
### Using `package.el`
<details>
<summary>Toggle instuctions</summary>
You can install `org-roam` from [MELPA](https://melpa.org/) or [MELPA
Stable](https://stable.melpa.org/) using `package.el`:
``` ```
M-x package-install RET org-roam RET M-x package-install RET org-roam RET
``` ```
Here's a very basic sample for configuration of `org-roam` using `use-package`: Here's a sample configuration with `use-package`:
```emacs-lisp ```emacs-lisp
(use-package org-roam (use-package org-roam
:ensure t :ensure t
:custom :custom
(org-roam-directory (file-truename "/path/to/org-files/")) (org-roam-directory (file-truename "/path/to/org-files/"))
:bind (("C-c n l" . org-roam-buffer-toggle) :bind (("C-c n l" . org-roam-buffer-toggle)
("C-c n f" . org-roam-node-find) ("C-c n f" . org-roam-node-find)
("C-c n g" . org-roam-graph) ("C-c n g" . org-roam-graph)
("C-c n i" . org-roam-node-insert) ("C-c n i" . org-roam-node-insert)
("C-c n c" . org-roam-capture) ("C-c n c" . org-roam-capture)
;; Dailies ;; Dailies
("C-c n j" . org-roam-dailies-capture-today)) ("C-c n j" . org-roam-dailies-capture-today))
:config :config
(org-roam-db-autosync-mode) (org-roam-db-autosync-mode)
;; If using org-roam-protocol ;; If using org-roam-protocol
(require 'org-roam-protocol)) (require 'org-roam-protocol))
``` ```
Note that the `file-truename` function is only necessary when you use symbolic The `file-truename` function is only necessary when you use symbolic links
link to `org-roam-directory`. Org-roam won't automatically resolve symbolic link inside `org-roam-directory`: Org-roam does not resolve symbolic links.
to the directory.
</details>
### Using `straight.el` Org-roam requires sqlite to function. Org-roam optionally uses Graphviz for
<details> graph-related functionality. It is recommended to install PCRE-enabled ripgrep
<summary>Toggle instuctions</summary> for better performance and extended functionality.
Installation from MELPA or MELPA Stable using `straight.el`:
```emacs-lisp
(straight-use-package 'org-roam)
```
Or with `use-package`:
```emacs-lisp
(use-package org-roam
:straight t
...)
```
If you need to install the package directly from the source repository, instead
of from MELPA, the next sample shows how to do so:
```emacs-lisp
(use-package org-roam
:straight (:host github :repo "org-roam/org-roam"
:files (:defaults "extensions/*"))
...)
```
If you plan to use your own local fork for the development and contribution, the
next sample will get you there:
```emacs-lisp
(use-package org-roam
:straight (:local-repo "/path/to/org-roam-fork"
:files (:defaults "extensions/*")
:build (:not compile))
...)
```
</details>
### Using Doom Emacs
<details>
<summary>Toggle instuctions</summary>
Doom's `:lang org` module comes with support for `org-roam`, but it's not
enabled by default. To activate it pass `+roam2` flag to `org` module in your
`$DOOMDIR/init.el` (e.g. `(org +roam2)`), save the file and run `doom sync -u`
in your shell.
To provide better stability, Doom pins the package to a specific commit. If you
need to unpin it *(not recommended doing that, request Doom to bump the package
instead)* use the next in your `packages.el`:
```emacs-lisp
(unpin! org-roam)
```
If for some reasons you want to use a different recipe for `org-roam`, you can
use the next form in your `packages.el` to install the package from a recipe
repository (e.g. MELPA):
```emacs-lisp
(package! org-roam)
```
You can pass `:pin "commit hash"` to pin the package to a specific commit.
With the next sample you can install the package directly from the source
repository:
```emacs-lisp
(package! org-roam
:recipe (:host github :repo "org-roam/org-roam"
:files (:defaults "extensions/*")))
```
And if you plan to use your own local fork for the development or contribution,
the next sample will get you there:
```emacs-lisp
(package! org-roam
:recipe (:local-repo "/path/to/org-roam-fork"
:files (:defaults "extensions/*")
:build (:not compile)))
```
</details>
### Without a package manager
<details>
<summary>Toggle instructions</summary>
To install the package without using a package manager you have the next two
options:
1. Install the package by cloning it with `git` from the source repository.
2. Or install the package by downloading the latest [release
version](https://github.com/org-roam/org-roam/releases).
In both of the cases you will need to ensure that you have all the required
dependencies. These include:
- dash
- f
- s
- org (9.4 is the minimal required version!)
- emacsql
- emacsql-sqlite
- magit-section
- filenotify-recursive
After installing the package, you will need to properly setup `load-path` to the
package:
``` emacs-lisp
(add-to-list 'load-path "/path/to/org-roam/")
(add-to-list 'load-path "/path/to-org-roam/extensions/")
```
After which you should be able to resolve `(require 'org-roam)` call without any
problems.
Org-roam also comes with `.texi` files to integrate with Emacs' built-in Info
system. Read the manual to find more details for how to install them manually.
</details>
## Getting Started ## Getting Started

View File

@@ -116,8 +116,8 @@
<div class="row"> <div class="row">
<a <a
class="content footer-links" class="content footer-links"
href="https://github.com/org-roam/org-roam-ui" href="https://github.com/org-roam/org-roam-server"
>org-roam-ui</a >org-roam-server</a
> >
</div> </div>
</div> </div>

View File

@@ -8,13 +8,13 @@
#+texinfo_dir_category: Emacs #+texinfo_dir_category: Emacs
#+texinfo_dir_title: Org-roam: (org-roam). #+texinfo_dir_title: Org-roam: (org-roam).
#+texinfo_dir_desc: Roam Research for Emacs. #+texinfo_dir_desc: Roam Research for Emacs.
#+subtitle: for version 2.1.0 #+subtitle: for version 2.0.0
#+options: H:4 num:3 toc:nil creator:t ':t #+options: H:4 num:3 toc:nil creator:t ':t
#+property: header-args :eval never #+property: header-args :eval never
#+texinfo: @noindent #+texinfo: @noindent
This manual is for Org-roam version 2.1.0. This manual is for Org-roam version 2.0.0.
#+BEGIN_QUOTE #+BEGIN_QUOTE
Copyright (C) 2020-2021 Jethro Kuan <jethrokuan95@gmail.com> Copyright (C) 2020-2021 Jethro Kuan <jethrokuan95@gmail.com>

View File

@@ -31,7 +31,7 @@ General Public License for more details.
@finalout @finalout
@titlepage @titlepage
@title Org-roam User Manual @title Org-roam User Manual
@subtitle for version 2.1.0 @subtitle for version 2.0.0
@author Jethro Kuan @author Jethro Kuan
@page @page
@vskip 0pt plus 1filll @vskip 0pt plus 1filll
@@ -44,7 +44,7 @@ General Public License for more details.
@noindent @noindent
This manual is for Org-roam version 2.1.0. This manual is for Org-roam version 2.0.0.
@quotation @quotation
Copyright (C) 2020-2021 Jethro Kuan <jethrokuan95@@gmail.com> Copyright (C) 2020-2021 Jethro Kuan <jethrokuan95@@gmail.com>

View File

@@ -7,8 +7,8 @@
;; Leo Vivier <leo.vivier+dev@gmail.com> ;; Leo Vivier <leo.vivier+dev@gmail.com>
;; URL: https://github.com/org-roam/org-roam ;; URL: https://github.com/org-roam/org-roam
;; Keywords: org-mode, roam, convenience ;; Keywords: org-mode, roam, convenience
;; Version: 2.1.0 ;; Version: 2.0.0
;; Package-Requires: ((emacs "26.1") (dash "2.13") (f "0.17.2") (org-roam "2.1")) ;; Package-Requires: ((emacs "26.1") (dash "2.13") (f "0.17.2") (org-roam "2.0"))
;; This file is NOT part of GNU Emacs. ;; This file is NOT part of GNU Emacs.

View File

@@ -5,8 +5,8 @@
;; Author: Jethro Kuan <jethrokuan95@gmail.com> ;; Author: Jethro Kuan <jethrokuan95@gmail.com>
;; URL: https://github.com/org-roam/org-roam ;; URL: https://github.com/org-roam/org-roam
;; Keywords: org-mode, roam, convenience ;; Keywords: org-mode, roam, convenience
;; Version: 2.1.0 ;; Version: 2.0.0
;; Package-Requires: ((emacs "26.1") (org "9.4") (org-roam "2.1")) ;; Package-Requires: ((emacs "26.1") (org "9.4") (org-roam "2.0"))
;; This file is NOT part of GNU Emacs. ;; This file is NOT part of GNU Emacs.
@@ -207,8 +207,7 @@ WITH RECURSIVE
connected_component(source) AS connected_component(source) AS
(SELECT dest FROM links_of WHERE source = $s1 UNION (SELECT dest FROM links_of WHERE source = $s1 UNION
SELECT dest FROM links_of JOIN connected_component USING(source)) SELECT dest FROM links_of JOIN connected_component USING(source))
SELECT DISTINCT source, dest, type FROM links SELECT source, dest, type FROM links WHERE source IN connected_component OR dest IN connected_component;"
WHERE source IN connected_component OR dest IN connected_component;"
" "
WITH RECURSIVE WITH RECURSIVE
links_of(source, dest) AS links_of(source, dest) AS
@@ -225,7 +224,7 @@ WITH RECURSIVE
AND json_array_length(cc.trace) < $s2)), AND json_array_length(cc.trace) < $s2)),
nodes(source) as (SELECT DISTINCT source nodes(source) as (SELECT DISTINCT source
FROM connected_component GROUP BY source ORDER BY min(json_array_length(trace))) FROM connected_component GROUP BY source ORDER BY min(json_array_length(trace)))
SELECT DISTINCT source, dest, type FROM links WHERE source IN nodes OR dest IN nodes;"))) SELECT source, dest, type FROM links WHERE source IN nodes OR dest IN nodes;")))
(org-roam-db-query query id distance))) (org-roam-db-query query id distance)))
(defun org-roam-graph--dot-option (option &optional wrap-key wrap-val) (defun org-roam-graph--dot-option (option &optional wrap-key wrap-val)

View File

@@ -5,8 +5,8 @@
;; Author: Jethro Kuan <jethrokuan95@gmail.com> ;; Author: Jethro Kuan <jethrokuan95@gmail.com>
;; URL: https://github.com/org-roam/org-roam ;; URL: https://github.com/org-roam/org-roam
;; Keywords: org-mode, roam, convenience ;; Keywords: org-mode, roam, convenience
;; Version: 2.1.0 ;; Version: 2.0.0
;; Package-Requires: ((emacs "26.1") (org "9.4") (org-roam "2.1")) ;; Package-Requires: ((emacs "26.1") (org "9.4") (org-roam "2.0"))
;; This file is NOT part of GNU Emacs. ;; This file is NOT part of GNU Emacs.

View File

@@ -4,8 +4,8 @@
;; Author: Jethro Kuan <jethrokuan95@gmail.com> ;; Author: Jethro Kuan <jethrokuan95@gmail.com>
;; URL: https://github.com/org-roam/org-roam ;; URL: https://github.com/org-roam/org-roam
;; Keywords: org-mode, roam, convenience ;; Keywords: org-mode, roam, convenience
;; Version: 2.1.0 ;; Version: 2.0.0
;; Package-Requires: ((emacs "26.1") (org "9.4") (org-roam "2.1")) ;; Package-Requires: ((emacs "26.1") (org "9.4") (org-roam "2.0"))
;; This file is NOT part of GNU Emacs. ;; This file is NOT part of GNU Emacs.
@@ -160,7 +160,7 @@ It should contain the FILE key, pointing to the path of the file to open.
org-protocol://roam-node?node=uuid" org-protocol://roam-node?node=uuid"
(when-let ((node (plist-get info :node))) (when-let ((node (plist-get info :node)))
(raise-frame) (raise-frame)
(org-roam-node-visit (org-roam-populate (org-roam-node-create :id node)) nil 'force)) (org-roam-node-visit (org-roam-populate (org-roam-node-create :id node))))
nil) nil)
(push '("org-roam-ref" :protocol "roam-ref" :function org-roam-protocol-open-ref) (push '("org-roam-ref" :protocol "roam-ref" :function org-roam-protocol-open-ref)

View File

@@ -5,8 +5,8 @@
;; Author: Jethro Kuan <jethrokuan95@gmail.com> ;; Author: Jethro Kuan <jethrokuan95@gmail.com>
;; URL: https://github.com/org-roam/org-roam ;; URL: https://github.com/org-roam/org-roam
;; Keywords: org-mode, roam, convenience ;; Keywords: org-mode, roam, convenience
;; Version: 2.1.0 ;; Version: 2.0.0
;; Package-Requires: ((emacs "26.1") (dash "2.13") (f "0.17.2") (org "9.4") (emacsql "3.0.0") (emacsql-sqlite "1.0.0") (magit-section "2.90.1")) ;; Package-Requires: ((emacs "26.1") (dash "2.13") (f "0.17.2") (org "9.4") (emacsql "3.0.0") (emacsql-sqlite "1.0.0") (magit-section "2.90.1") (filenotify-recursive "0.0.1"))
;; This file is NOT part of GNU Emacs. ;; This file is NOT part of GNU Emacs.

View File

@@ -5,7 +5,7 @@
;; Author: Jethro Kuan <jethrokuan95@gmail.com> ;; Author: Jethro Kuan <jethrokuan95@gmail.com>
;; URL: https://github.com/org-roam/org-roam ;; URL: https://github.com/org-roam/org-roam
;; Keywords: org-mode, roam, convenience ;; Keywords: org-mode, roam, convenience
;; Version: 2.1.0 ;; Version: 2.0.0
;; Package-Requires: ((emacs "26.1")) ;; Package-Requires: ((emacs "26.1"))
;; This file is NOT part of GNU Emacs. ;; This file is NOT part of GNU Emacs.
@@ -163,6 +163,9 @@ nodes." org-id-locations-file)
(define-obsolete-function-alias (define-obsolete-function-alias
'org-roam-teardown 'org-roam-teardown
'org-roam-db-autosync-disable "org-roam 2.0") 'org-roam-db-autosync-disable "org-roam 2.0")
(define-obsolete-variable-alias
'org-roam-db-update-on-save
'org-roam-db-autosync-update-method "org-roam 2.0")
(define-obsolete-variable-alias (define-obsolete-variable-alias
'org-roam-current-node 'org-roam-current-node

View File

@@ -5,8 +5,8 @@
;; Author: Jethro Kuan <jethrokuan95@gmail.com> ;; Author: Jethro Kuan <jethrokuan95@gmail.com>
;; URL: https://github.com/org-roam/org-roam ;; URL: https://github.com/org-roam/org-roam
;; Keywords: org-mode, roam, convenience ;; Keywords: org-mode, roam, convenience
;; Version: 2.1.0 ;; Version: 2.0.0
;; Package-Requires: ((emacs "26.1") (dash "2.13") (f "0.17.2") (org "9.4") (emacsql "3.0.0") (emacsql-sqlite "1.0.0") (magit-section "2.90.1")) ;; Package-Requires: ((emacs "26.1") (dash "2.13") (f "0.17.2") (org "9.4") (emacsql "3.0.0") (emacsql-sqlite "1.0.0") (magit-section "2.90.1") (filenotify-recursive "0.0.1"))
;; This file is NOT part of GNU Emacs. ;; This file is NOT part of GNU Emacs.
@@ -31,6 +31,9 @@
;; ;;
;;; Code: ;;; Code:
(require 'org-roam) (require 'org-roam)
(require 'filenotify)
(require 'filenotify-recursive)
(defvar org-outline-path-cache) (defvar org-outline-path-cache)
;;; Options ;;; Options
@@ -71,26 +74,38 @@ database."
:type 'function :type 'function
:group 'org-roam) :group 'org-roam)
(defcustom org-roam-db-update-on-save t (defcustom org-roam-db-autosync-update-method
"If t, update the Org-roam database upon saving the file. (if file-notify--library 'filenotify 'on-save)
Disable this if your files are large and updating the database is "What method to use to keep Org-roam's database updated.
slow."
:type 'boolean 'filenotify
Update Org-roam upon detecting changes from the filesystem using
file watchers. Requires Emacs that's compiled with support for
file notifications.
'on-save
Update the database whenever Emacs buffer that visits an Org-roam
file is saved. Unlike `filenotify' this won't be able to react to
external changes in the filesystem.
nil
Do not automatically update the Org-roam database."
:type '(choice (const :tag "Filenotify" filenotify)
(const :tag "On save" onsave)
(const :tag "Do not autoupdate" nil))
:group 'org-roam) :group 'org-roam)
;;; Variables ;;; Initialization
(defconst org-roam-db-version 16) (defconst org-roam-db-version 16)
;; TODO Rename this (defvar org-roam-db--connection (make-hash-table :test #'equal)
"Database connection to Org-roam database.")
(defconst org-roam--sqlite-available-p (defconst org-roam--sqlite-available-p
(with-demoted-errors "Org-roam initialization: %S" (with-demoted-errors "Org-roam initialization: %S"
(emacsql-sqlite-ensure-binary) (emacsql-sqlite-ensure-binary)
t)) t))
(defvar org-roam-db--connection (make-hash-table :test #'equal)
"Database connection to Org-roam database.")
;;; Core Functions
(defun org-roam-db--get-connection () (defun org-roam-db--get-connection ()
"Return the database connection, if any." "Return the database connection, if any."
(gethash (expand-file-name org-roam-directory) (gethash (expand-file-name org-roam-directory)
@@ -474,25 +489,26 @@ If UPDATE-P is non-nil, first remove the file in the database."
If the file does not exist anymore, remove it from the cache. If the file does not exist anymore, remove it from the cache.
If the file exists, update the cache with information." If the file exists, update the cache with information."
(setq file-path (or file-path (buffer-file-name (buffer-base-buffer)))) (setq file-path (or file-path (buffer-file-name (buffer-base-buffer))))
(let ((content-hash (org-roam-db--file-hash file-path)) (org-roam-db-clear-file file-path)
(db-hash (caar (org-roam-db-query [:select hash :from files (when (file-exists-p file-path)
:where (= file $s1)] file-path)))) (let ((content-hash (org-roam-db--file-hash file-path))
(unless (string= content-hash db-hash) (db-hash (caar (org-roam-db-query [:select hash :from files
(org-roam-with-file file-path nil :where (= file $s1)] file-path))))
(save-excursion (unless (string= content-hash db-hash)
(org-set-regexps-and-options 'tags-only) (org-roam-with-file file-path nil
(org-roam-db-clear-file) (save-excursion
(org-roam-db-insert-file) (org-set-regexps-and-options 'tags-only)
(org-roam-db-insert-file-node) (org-roam-db-insert-file)
(setq org-outline-path-cache nil) (org-roam-db-insert-file-node)
(org-roam-db-map-nodes (setq org-outline-path-cache nil)
(list #'org-roam-db-insert-node-data (org-roam-db-map-nodes
#'org-roam-db-insert-aliases (list #'org-roam-db-insert-node-data
#'org-roam-db-insert-tags #'org-roam-db-insert-aliases
#'org-roam-db-insert-refs)) #'org-roam-db-insert-tags
(setq org-outline-path-cache nil) #'org-roam-db-insert-refs))
(org-roam-db-map-links (setq org-outline-path-cache nil)
(list #'org-roam-db-insert-link))))))) (org-roam-db-map-links
(list #'org-roam-db-insert-link))))))))
;;;###autoload ;;;###autoload
(defun org-roam-db-sync (&optional force) (defun org-roam-db-sync (&optional force)
@@ -527,6 +543,19 @@ If FORCE, force a rebuild of the cache from scratch."
(dolist (file modified-files) (dolist (file modified-files)
(org-roam-db-update-file file)))))) (org-roam-db-update-file file))))))
;;;###autoload
(defun org-roam-db-autosync-enable ()
"Activate `org-roam-db-autosync-mode'."
(org-roam-db-autosync-mode +1))
(defun org-roam-db-autosync-disable ()
"Deactivate `org-roam-db-autosync-mode'."
(org-roam-db-autosync-mode -1))
(defun org-roam-db-autosync-toggle ()
"Toggle `org-roam-db-autosync-mode' enabled/disabled."
(org-roam-db-autosync-mode 'toggle))
;;;###autoload ;;;###autoload
(define-minor-mode org-roam-db-autosync-mode (define-minor-mode org-roam-db-autosync-mode
"Global minor mode to keep your Org-roam session automatically synchronized. "Global minor mode to keep your Org-roam session automatically synchronized.
@@ -540,37 +569,101 @@ database, see `org-roam-db-sync' command."
:group 'org-roam :group 'org-roam
:global t :global t
:init-value nil :init-value nil
(let ((enabled org-roam-db-autosync-mode)) (let ((enabled org-roam-db-autosync-mode)
(update-method org-roam-db-autosync-update-method))
(cond (cond
(enabled (enabled
(add-hook 'find-file-hook #'org-roam-db-autosync--setup-file-h) (add-hook 'find-file-hook #'org-roam-db-autosync--setup-file-h)
(org-roam-db-autosync--update-method :enable update-method)
(add-hook 'kill-emacs-hook #'org-roam-db--close-all) (add-hook 'kill-emacs-hook #'org-roam-db--close-all)
(advice-add #'rename-file :after #'org-roam-db-autosync--rename-file-a)
(advice-add #'delete-file :before #'org-roam-db-autosync--delete-file-a)
(org-roam-db-sync)) (org-roam-db-sync))
(t (t
(remove-hook 'find-file-hook #'org-roam-db-autosync--setup-file-h) (remove-hook 'find-file-hook #'org-roam-db-autosync--setup-file-h)
(org-roam-db-autosync--update-method :disable update-method)
(remove-hook 'kill-emacs-hook #'org-roam-db--close-all) (remove-hook 'kill-emacs-hook #'org-roam-db--close-all)
(advice-remove #'rename-file #'org-roam-db-autosync--rename-file-a)
(advice-remove #'delete-file #'org-roam-db-autosync--delete-file-a)
(org-roam-db--close-all) (org-roam-db--close-all)
;; Disable local hooks for all org-roam buffers ;; Disable local hooks for all org-roam buffers
(dolist (buf (org-roam-buffer-list)) (dolist (buf (org-roam-buffer-list))
(with-current-buffer buf (with-current-buffer buf
(remove-hook 'after-save-hook #'org-roam-db-autosync--try-update-on-save-h t))))))) (remove-hook 'after-save-hook #'org-roam-db-autosync--try-update-on-save-h t)))))))
;;;###autoload (defvar org-roam-db-autosync--filenotify-descriptors (list)
(defun org-roam-db-autosync-enable () "An alist mapping watched Org-roam directories to `filenotify-recursive' uuid.")
"Activate `org-roam-db-autosync-mode'."
(org-roam-db-autosync-mode +1))
(defun org-roam-db-autosync-disable () (defun org-roam-db-autosync--update-method (state method)
"Deactivate `org-roam-db-autosync-mode'." "Change the current `org-roam-db-autosync-update-method' to METHOD.
(org-roam-db-autosync-mode -1)) STATE should be either :enable or :disable, while METHOD should
be on of the values from `org-roam-db-autosync-update-method'."
(unless (memq method '(filenotify on-save nil))
(user-error "Unknown `org-roam-db-autosync-update-method': %s" method))
(cl-ecase state
(:enable
(unless (eq method org-roam-db-autosync-update-method)
;; Clean up the old method in case of hot swap.
(org-roam-db-autosync--update-method :disable org-roam-db-autosync-update-method))
(setq org-roam-db-autosync-update-method method)
(pcase method
('filenotify
(cl-pushnew
(cons org-roam-directory
(fnr-add-watch org-roam-directory
'(change)
#'org-roam-db-autosync--filenotify-update
"\\`\\.")) ; Ignore directories that start with "."
org-roam-db-autosync--filenotify-descriptors))
('on-save
(add-hook 'org-roam-find-file-hook #'org-roam-db-autosync--setup-update-on-save-h)
(advice-add #'rename-file :after #'org-roam-db-autosync--rename-file-a)
(advice-add #'delete-file :before #'org-roam-db-autosync--delete-file-a))
((pred nilp)
t)))
(:disable
(pcase org-roam-db-autosync-update-method
('filenotify
(cl-loop for entry in org-roam-db-autosync--filenotify-descriptors
for _dir = (car entry)
for uuid = (cdr entry)
do (fnr-rm-watch uuid))
(setq org-roam-db-autosync--filenotify-descriptors nil))
('on-save
(remove-hook 'org-roam-find-file-hook #'org-roam-db-autosync--setup-update-on-save-h)
(advice-remove #'rename-file #'org-roam-db-autosync--rename-file-a)
(advice-remove #'delete-file #'org-roam-db-autosync--delete-file-a))
((pred nilp)
t)))))
(defun org-roam-db-autosync-toggle () (defun org-roam-db-autosync--filenotify-update (event)
"Toggle `org-roam-db-autosync-mode' enabled/disabled." "Update Org-roam's database according to EVENT sent by `filenotify'."
(org-roam-db-autosync-mode 'toggle)) (cl-destructuring-bind (_descriptor action &rest files) event
(cond
((cl-find-if #'org-roam-file-p files)
(mapc #'org-roam-db-update-file files))
((memq action '(created deleted renamed))
(apply (intern (format "org-roam-db-autosync--update-%s-dir" action)) files)))))
(defun org-roam-db-autosync--update-created-dir (dir)
"Add entries from Org-roam files under DIR to the database."
(when (file-directory-p dir)
(let ((files (let ((org-roam-directory dir))
(org-roam-list-files))))
(emacsql-with-transaction (org-roam-db)
(mapc #'org-roam-db-update-file files)))))
(defun org-roam-db-autosync--update-deleted-dir (dir)
"Invalidate entries related to Org-roam files under DIR from the database."
(let ((dir (thread-first dir
;; Ensure that separator is present in the name
(directory-file-name)
(concat (f-path-separator))
;; Follow the same format as the rest of the files in the database
(expand-file-name))))
(org-roam-db-query [:delete :from files :where (like file $s1)]
(concat dir "%"))))
(defun org-roam-db-autosync--update-renamed-dir (old-name new-name)
"Invalidate and then add files renamed from OLD-NAME directory to NEW-NAME."
(org-roam-db-autosync--update-deleted-dir old-name)
(org-roam-db-autosync--update-created-dir new-name))
(defun org-roam-db-autosync--delete-file-a (file &optional _trash) (defun org-roam-db-autosync--delete-file-a (file &optional _trash)
"Maintain cache consistency when file deletes. "Maintain cache consistency when file deletes.
@@ -601,14 +694,9 @@ OLD-FILE is cleared from the database, and NEW-FILE-OR-DIR is added."
"Setup the current buffer if it visits an Org-roam file." "Setup the current buffer if it visits an Org-roam file."
(when (org-roam-file-p) (run-hooks 'org-roam-find-file-hook))) (when (org-roam-file-p) (run-hooks 'org-roam-find-file-hook)))
(add-hook 'org-roam-find-file-hook #'org-roam-db-autosync--setup-update-on-save-h)
(defun org-roam-db-autosync--setup-update-on-save-h () (defun org-roam-db-autosync--setup-update-on-save-h ()
"Setup the current buffer to update the DB after saving the current file." "Setup the current buffer to update the DB after saving the current file."
(add-hook 'after-save-hook #'org-roam-db-autosync--try-update-on-save-h nil t)) (add-hook 'after-save-hook #'org-roam-db-update-file nil t))
(defun org-roam-db-autosync--try-update-on-save-h ()
"If appropriate, update the database for the current file after saving buffer."
(when org-roam-db-update-on-save (org-roam-db-update-file)))
;;; Diagnostics ;;; Diagnostics
(defun org-roam-db-diagnose-node () (defun org-roam-db-diagnose-node ()

View File

@@ -5,8 +5,8 @@
;; Author: Jethro Kuan <jethrokuan95@gmail.com> ;; Author: Jethro Kuan <jethrokuan95@gmail.com>
;; URL: https://github.com/org-roam/org-roam ;; URL: https://github.com/org-roam/org-roam
;; Keywords: org-mode, roam, convenience ;; Keywords: org-mode, roam, convenience
;; Version: 2.1.0 ;; Version: 2.0.0
;; Package-Requires: ((emacs "26.1") (dash "2.13") (f "0.17.2") (org "9.4") (emacsql "3.0.0") (emacsql-sqlite "1.0.0") (magit-section "2.90.1")) ;; Package-Requires: ((emacs "26.1") (dash "2.13") (f "0.17.2") (org "9.4") (emacsql "3.0.0") (emacsql-sqlite "1.0.0") (magit-section "2.90.1") (filenotify-recursive "0.0.1"))
;; This file is NOT part of GNU Emacs. ;; This file is NOT part of GNU Emacs.

View File

@@ -5,8 +5,8 @@
;; Author: Jethro Kuan <jethrokuan95@gmail.com> ;; Author: Jethro Kuan <jethrokuan95@gmail.com>
;; URL: https://github.com/org-roam/org-roam ;; URL: https://github.com/org-roam/org-roam
;; Keywords: org-mode, roam, convenience ;; Keywords: org-mode, roam, convenience
;; Version: 2.1.0 ;; Version: 2.0.0
;; Package-Requires: ((emacs "26.1") (dash "2.13") (f "0.17.2") (org "9.4") (emacsql "3.0.0") (emacsql-sqlite "1.0.0") (magit-section "2.90.1")) ;; Package-Requires: ((emacs "26.1") (dash "2.13") (f "0.17.2") (org "9.4") (emacsql "3.0.0") (emacsql-sqlite "1.0.0") (magit-section "2.90.1") (filenotify-recursive "0.0.1"))
;; This file is NOT part of GNU Emacs. ;; This file is NOT part of GNU Emacs.
@@ -379,8 +379,7 @@ the same time:
The preview content comes from FILE, and the link as at POINT.") The preview content comes from FILE, and the link as at POINT.")
(defun org-roam-preview-visit (file point &optional other-window) (defun org-roam-preview-visit (file point &optional other-window)
"Visit FILE at POINT and return the visited buffer. "Visit FILE at POINT. With OTHER-WINDOW non-nil do so in another window.
With OTHER-WINDOW non-nil do so in another window.
In interactive calls OTHER-WINDOW is set with In interactive calls OTHER-WINDOW is set with
`universal-argument'." `universal-argument'."
(interactive (list (org-roam-buffer-file-at-point 'assert) (interactive (list (org-roam-buffer-file-at-point 'assert)
@@ -390,12 +389,11 @@ In interactive calls OTHER-WINDOW is set with
(display-buffer-fn (if other-window (display-buffer-fn (if other-window
#'switch-to-buffer-other-window #'switch-to-buffer-other-window
#'pop-to-buffer-same-window))) #'pop-to-buffer-same-window)))
(funcall display-buffer-fn buf)
(with-current-buffer buf (with-current-buffer buf
(widen) (widen)
(goto-char point)) (goto-char point))
(when (org-invisible-p) (org-show-context)) (funcall display-buffer-fn buf)
buf)) (when (org-invisible-p) (org-show-context))))
(defun org-roam-preview-get-contents (file point) (defun org-roam-preview-get-contents (file point)
"Get preview content for FILE at POINT." "Get preview content for FILE at POINT."
@@ -595,7 +593,7 @@ Sorts by title."
"A `magit-section' used by `org-roam-mode' to contain grep output.") "A `magit-section' used by `org-roam-mode' to contain grep output.")
(defun org-roam-grep-visit (file &optional other-window row col) (defun org-roam-grep-visit (file &optional other-window row col)
"Visit FILE at row ROW (if any) and column COL (if any). Return the buffer. "Visits FILE. If ROW, move to the row, and if COL move to the COL.
With OTHER-WINDOW non-nil (in interactive calls set with With OTHER-WINDOW non-nil (in interactive calls set with
`universal-argument') display the buffer in another window `universal-argument') display the buffer in another window
instead." instead."
@@ -607,7 +605,6 @@ instead."
(display-buffer-fn (if other-window (display-buffer-fn (if other-window
#'switch-to-buffer-other-window #'switch-to-buffer-other-window
#'pop-to-buffer-same-window))) #'pop-to-buffer-same-window)))
(funcall display-buffer-fn buf)
(with-current-buffer buf (with-current-buffer buf
(widen) (widen)
(goto-char (point-min)) (goto-char (point-min))
@@ -615,8 +612,8 @@ instead."
(forward-line (1- row))) (forward-line (1- row)))
(when col (when col
(forward-char (1- col)))) (forward-char (1- col))))
(when (org-invisible-p) (org-show-context)) (funcall display-buffer-fn buf)
buf)) (when (org-invisible-p) (org-show-context))))
;;;; Unlinked references ;;;; Unlinked references
(defvar org-roam-unlinked-references-result-re (defvar org-roam-unlinked-references-result-re

View File

@@ -5,7 +5,7 @@
;; Author: Jethro Kuan <jethrokuan95@gmail.com> ;; Author: Jethro Kuan <jethrokuan95@gmail.com>
;; URL: https://github.com/org-roam/org-roam ;; URL: https://github.com/org-roam/org-roam
;; Keywords: org-mode, roam, convenience ;; Keywords: org-mode, roam, convenience
;; Version: 2.1.0 ;; Version: 2.0.0
;; Package-Requires: ((emacs "26.1") (dash "2.13") (org "9.4") (magit-section "2.90.1")) ;; Package-Requires: ((emacs "26.1") (dash "2.13") (org "9.4") (magit-section "2.90.1"))
;; This file is NOT part of GNU Emacs. ;; This file is NOT part of GNU Emacs.
@@ -76,21 +76,6 @@ It takes a single argument NODE, which is an `org-roam-node' construct."
(const :tag "file-atime" file-atime)) (const :tag "file-atime" file-atime))
:group 'org-roam) :group 'org-roam)
(defcustom org-roam-node-template-prefixes
'(("tags" . "#")
("todo" . "t:"))
"Prefixes for each of the node's properties.
This is used in conjunction with
`org-roam-node-display-template': in minibuffer completions the
node properties will be prefixed with strings in this variable,
acting as a query language of sorts.
For example, if a node has tags (\"foo\" \"bar\") and the alist
has the entry (\"tags\" . \"#\"), these will appear as
\"#foo #bar\"."
:group 'org-roam
:type '(alist))
(defcustom org-roam-ref-annotation-function #'org-roam-ref-read--annotation (defcustom org-roam-ref-annotation-function #'org-roam-ref-read--annotation
"This function used to attach annotations for `org-roam-ref-read'. "This function used to attach annotations for `org-roam-ref-read'.
It takes a single argument REF, which is a propertized string.") It takes a single argument REF, which is a propertized string.")
@@ -369,31 +354,23 @@ GROUP BY id")))
all-titles))))) all-titles)))))
;;;; Finders ;;;; Finders
(defun org-roam-node-find-noselect (node &optional force) (defun org-roam-node-find-noselect (node)
"Navigate to the point for NODE, and return the buffer. "Navigate to the point for NODE, and return the buffer."
If NODE is already visited, this won't automatically move the
point to the beginning of the NODE, unless FORCE is non-nil."
(unless (org-roam-node-file node) (unless (org-roam-node-file node)
(user-error "Node does not have corresponding file")) (user-error "Node does not have corresponding file"))
(let ((buf (find-file-noselect (org-roam-node-file node)))) (let ((buf (find-file-noselect (org-roam-node-file node))))
(with-current-buffer buf (with-current-buffer buf
(when (or force (goto-char (org-roam-node-point node)))
(not (equal (org-roam-node-id node)
(org-roam-id-at-point))))
(goto-char (org-roam-node-point node))))
buf)) buf))
(defun org-roam-node-visit (node &optional other-window force) (defun org-roam-node-visit (node &optional other-window)
"From the current buffer, visit NODE. Return the visited buffer. "From the current buffer, visit NODE. Return the visited buffer.
Display the buffer in the selected window. With a prefix Display the buffer in the selected window. With a prefix
argument OTHER-WINDOW display the buffer in another window argument OTHER-WINDOW display the buffer in another window
instead. instead."
(interactive (list (org-roam-node-at-point t) current-prefix-arg))
If NODE is already visited, this won't automatically move the (let ((buf (org-roam-node-find-noselect node))
point to the beginning of the NODE, unless FORCE is non-nil. In
interactive calls FORCE always set to t."
(interactive (list (org-roam-node-at-point t) current-prefix-arg t))
(let ((buf (org-roam-node-find-noselect node 'force))
(display-buffer-fn (if other-window (display-buffer-fn (if other-window
#'switch-to-buffer-other-window #'switch-to-buffer-other-window
#'pop-to-buffer-same-window))) #'pop-to-buffer-same-window)))
@@ -478,51 +455,50 @@ The displayed title is formatted according to `org-roam-node-display-template'."
(let ((candidate-main (org-roam-node-read--format-entry node (1- (frame-width))))) (let ((candidate-main (org-roam-node-read--format-entry node (1- (frame-width)))))
(cons (propertize candidate-main 'node node) node))) (cons (propertize candidate-main 'node node) node)))
(defun org-roam-node-read--tags-to-str (tags)
"Convert list of TAGS into a string."
(mapconcat (lambda (s) (concat "#" s)) tags " "))
(defun org-roam-node-read--format-entry (node width) (defun org-roam-node-read--format-entry (node width)
"Formats NODE for display in the results list. "Formats NODE for display in the results list.
WIDTH is the width of the results list. WIDTH is the width of the results list.
Uses `org-roam-node-display-template' to format the entry." Uses `org-roam-node-display-template' to format the entry."
(pcase-let ((`(,tmpl . ,tmpl-width) (let ((fmt (org-roam-node-read--process-display-format org-roam-node-display-template)))
(org-roam-node-read--process-display-format org-roam-node-display-template)))
(org-roam-format-template (org-roam-format-template
tmpl (car fmt)
(lambda (field _default-val) (lambda (field _default-val)
(pcase-let* ((`(,field-name ,field-width) (split-string field ":")) (let* ((field (split-string field ":"))
(getter (intern (concat "org-roam-node-" field-name))) (field-name (car field))
(field-value (funcall getter node))) (field-width (cadr field))
(getter (intern (concat "org-roam-node-" field-name)))
(field-value (or (funcall getter node) "")))
(when (and (equal field-name "tags")
field-value)
(setq field-value (org-roam-node-read--tags-to-str field-value)))
(when (and (equal field-name "file") (when (and (equal field-name "file")
field-value) field-value)
(setq field-value (file-relative-name field-value org-roam-directory))) (setq field-value (file-relative-name field-value org-roam-directory)))
(when (and (equal field-name "olp") (when (and (equal field-name "olp")
field-value) field-value)
(setq field-value (string-join field-value " > "))) (setq field-value (string-join field-value " > ")))
(when (and field-value (not (listp field-value))) (if (not field-width)
(setq field-value (list field-value))) field-value
(setq field-value (mapconcat (setq field-width (string-to-number field-width))
(lambda (v) (let ((display-string (truncate-string-to-width
(concat (or (cdr (assoc field-name org-roam-node-template-prefixes)) field-value
"") (if (> field-width 0)
v)) field-width
field-value " ")) (- width (cdr fmt)))
(setq field-width (cond 0 ?\s)))
((not field-width) ;; Setting the display (which would be padded out to the field length) for an
field-width) ;; empty string results in an empty string and misalignment for candidates that
((string-equal field-width "*") ;; don't have some field. This uses the actual display string, made of spaces
(- width tmpl-width)) ;; when the field-value is "" so that we actually take up space.
((>= (string-to-number field-width) 0) (if (not (equal field-value ""))
(string-to-number field-width)))) ;; Remove properties from the full candidate string, otherwise the display
;; Setting the display (which would be padded out to the field length) for an ;; formatting with pre-prioritized field-values gets messed up.
;; empty string results in an empty string and misalignment for candidates that (propertize (substring-no-properties field-value) 'display display-string)
;; don't have some field. This uses the actual display string, made of spaces display-string))))))))
;; when the field-value is "" so that we actually take up space.
(let ((display-string (if field-width
(truncate-string-to-width field-value field-width 0 ?\s)
field-value)))
(if (equal field-value "")
display-string
;; Remove properties from the full candidate string, otherwise the display
;; formatting with pre-prioritized field-values gets messed up.
(propertize (substring-no-properties field-value) 'display display-string))))))))
(defun org-roam-node-read--process-display-format (format) (defun org-roam-node-read--process-display-format (format)
"Pre-calculate minimal widths needed by the FORMAT string." "Pre-calculate minimal widths needed by the FORMAT string."
@@ -621,7 +597,7 @@ Assumes that the cursor was put where the link is."
(cond (cond
((org-roam-node-file node) ((org-roam-node-file node)
(org-mark-ring-push) (org-mark-ring-push)
(org-roam-node-visit node nil 'force) (org-roam-node-visit node)
t) t)
(t nil)))))) (t nil))))))
@@ -635,7 +611,7 @@ Assumes that the cursor was put where the link is."
(when org-roam-link-auto-replace (when org-roam-link-auto-replace
(org-roam-link-replace-at-point)) (org-roam-link-replace-at-point))
(org-mark-ring-push) (org-mark-ring-push)
(org-roam-node-visit node nil 'force)) (org-roam-node-visit node))
(org-roam-capture- (org-roam-capture-
:node (org-roam-node-create :title title-or-alias) :node (org-roam-node-create :title title-or-alias)
:props '(:finalize find-file)))) :props '(:finalize find-file))))

View File

@@ -5,7 +5,7 @@
;; Author: Jethro Kuan <jethrokuan95@gmail.com> ;; Author: Jethro Kuan <jethrokuan95@gmail.com>
;; URL: https://github.com/org-roam/org-roam ;; URL: https://github.com/org-roam/org-roam
;; Keywords: org-mode, roam, convenience ;; Keywords: org-mode, roam, convenience
;; Version: 2.1.0 ;; Version: 2.0.0
;; Package-Requires: ((emacs "26.1") (dash "2.13") (org "9.4")) ;; Package-Requires: ((emacs "26.1") (dash "2.13") (org "9.4"))
;; This file is NOT part of GNU Emacs. ;; This file is NOT part of GNU Emacs.
@@ -288,45 +288,18 @@ If VAL is not specified, user is prompted to select a value."
"Return `org-roam' version. "Return `org-roam' version.
Interactively, or when MESSAGE is non-nil, show in the echo area." Interactively, or when MESSAGE is non-nil, show in the echo area."
(interactive) (interactive)
(let* ((toplib (or load-file-name buffer-file-name)) (let* ((version
gitdir topdir version) (with-temp-buffer
(unless (and toplib (equal (file-name-nondirectory toplib) "org-roam-utils.el")) (insert-file-contents-literally (locate-library "org-roam.el"))
(setq toplib (locate-library "org-roam-utils.el"))) (goto-char (point-min))
(setq toplib (and toplib (org-roam--straight-chase-links toplib))) (save-match-data
(when toplib (if (re-search-forward "\\(?:;; Version: \\([^z-a]*?$\\)\\)" nil nil)
(setq topdir (file-name-directory toplib) (substring-no-properties (match-string 1))
gitdir (expand-file-name ".git" topdir))) "N/A")))))
(when (file-exists-p gitdir)
(setq version
(let ((default-directory topdir))
(shell-command-to-string "git describe --tags --dirty --always"))))
(unless version
(setq version (with-temp-buffer
(insert-file-contents-literally (locate-library "org-roam.el"))
(goto-char (point-min))
(save-match-data
(if (re-search-forward "\\(?:;; Version: \\([^z-a]*?$\\)\\)" nil nil)
(substring-no-properties (match-string 1))
"N/A")))))
(if (or message (called-interactively-p 'interactive)) (if (or message (called-interactively-p 'interactive))
(message "%s" version) (message "%s" version)
version))) version)))
(defun org-roam--straight-chase-links (filename)
"Chase links in FILENAME until a name that is not a link.
This is the same as `file-chase-links', except that it also
handles fake symlinks that are created by the package manager
straight.el on Windows.
See <https://github.com/raxod502/straight.el/issues/520>."
(when (and (bound-and-true-p straight-symlink-emulation-mode)
(fboundp 'straight-chase-emulated-symlink))
(when-let ((target (straight-chase-emulated-symlink filename)))
(unless (eq target 'broken)
(setq filename target))))
(file-chase-links filename))
;;;###autoload ;;;###autoload
(defun org-roam-diagnostics () (defun org-roam-diagnostics ()
"Collect and print info for `org-roam' issues." "Collect and print info for `org-roam' issues."

View File

@@ -5,8 +5,8 @@
;; Author: Jethro Kuan <jethrokuan95@gmail.com> ;; Author: Jethro Kuan <jethrokuan95@gmail.com>
;; URL: https://github.com/org-roam/org-roam ;; URL: https://github.com/org-roam/org-roam
;; Keywords: org-mode, roam, convenience ;; Keywords: org-mode, roam, convenience
;; Version: 2.1.0 ;; Version: 2.0.0
;; Package-Requires: ((emacs "26.1") (dash "2.13") (f "0.17.2") (org "9.4") (emacsql "3.0.0") (emacsql-sqlite "1.0.0") (magit-section "2.90.1")) ;; Package-Requires: ((emacs "26.1") (dash "2.13") (f "0.17.2") (org "9.4") (emacsql "3.0.0") (emacsql-sqlite "1.0.0") (magit-section "2.90.1") (filenotify-recursive "0.0.1"))
;; This file is NOT part of GNU Emacs. ;; This file is NOT part of GNU Emacs.