mirror of
https://github.com/org-roam/org-roam
synced 2025-09-12 15:36:48 -05:00
Compare commits
10 Commits
v2.1.0
...
filenotify
Author | SHA1 | Date | |
---|---|---|---|
|
9401fad1b2 | ||
|
1c3d3098c7 | ||
|
15dfb85bd1 | ||
|
0d0ae01684 | ||
|
6135731eed | ||
|
aac41a22e4 | ||
|
c450dbd054 | ||
|
33d8792f19 | ||
|
87b2359d6d | ||
|
210073c7d2 |
32
CHANGELOG.md
32
CHANGELOG.md
@@ -1,36 +1,9 @@
|
||||
# Changelog
|
||||
|
||||
## 2.1.0
|
||||
## 1.2.4 (TBD)
|
||||
|
||||
### 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
|
||||
- [#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
|
||||
@@ -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
|
||||
- [#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
|
||||
- [#1705](https://github.com/org-roam/org-roam/pull/1705) fix for add/remove of file-level tags
|
||||
|
||||
## 1.2.3 (13-11-2020)
|
||||
|
||||
|
174
README.md
174
README.md
@@ -33,170 +33,38 @@ solution for anyone already using Org-mode for their personal wiki.
|
||||
|
||||
## Installation
|
||||
|
||||
Down below you will find basic installation instructions for how to quickly
|
||||
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`:
|
||||
You can install `org-roam` using `package.el`:
|
||||
|
||||
```
|
||||
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
|
||||
(use-package org-roam
|
||||
:ensure t
|
||||
:custom
|
||||
(org-roam-directory (file-truename "/path/to/org-files/"))
|
||||
:bind (("C-c n l" . org-roam-buffer-toggle)
|
||||
("C-c n f" . org-roam-node-find)
|
||||
("C-c n g" . org-roam-graph)
|
||||
("C-c n i" . org-roam-node-insert)
|
||||
("C-c n c" . org-roam-capture)
|
||||
;; Dailies
|
||||
("C-c n j" . org-roam-dailies-capture-today))
|
||||
:config
|
||||
(org-roam-db-autosync-mode)
|
||||
;; If using org-roam-protocol
|
||||
(require 'org-roam-protocol))
|
||||
:ensure t
|
||||
:custom
|
||||
(org-roam-directory (file-truename "/path/to/org-files/"))
|
||||
:bind (("C-c n l" . org-roam-buffer-toggle)
|
||||
("C-c n f" . org-roam-node-find)
|
||||
("C-c n g" . org-roam-graph)
|
||||
("C-c n i" . org-roam-node-insert)
|
||||
("C-c n c" . org-roam-capture)
|
||||
;; Dailies
|
||||
("C-c n j" . org-roam-dailies-capture-today))
|
||||
:config
|
||||
(org-roam-db-autosync-mode)
|
||||
;; If using org-roam-protocol
|
||||
(require 'org-roam-protocol))
|
||||
```
|
||||
|
||||
Note that the `file-truename` function is only necessary when you use symbolic
|
||||
link to `org-roam-directory`. Org-roam won't automatically resolve symbolic link
|
||||
to the directory.
|
||||
</details>
|
||||
The `file-truename` function is only necessary when you use symbolic links
|
||||
inside `org-roam-directory`: Org-roam does not resolve symbolic links.
|
||||
|
||||
### Using `straight.el`
|
||||
<details>
|
||||
<summary>Toggle instuctions</summary>
|
||||
|
||||
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>
|
||||
Org-roam requires sqlite to function. Org-roam optionally uses Graphviz for
|
||||
graph-related functionality. It is recommended to install PCRE-enabled ripgrep
|
||||
for better performance and extended functionality.
|
||||
|
||||
## Getting Started
|
||||
|
||||
|
@@ -116,8 +116,8 @@
|
||||
<div class="row">
|
||||
<a
|
||||
class="content footer-links"
|
||||
href="https://github.com/org-roam/org-roam-ui"
|
||||
>org-roam-ui</a
|
||||
href="https://github.com/org-roam/org-roam-server"
|
||||
>org-roam-server</a
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
|
@@ -8,13 +8,13 @@
|
||||
#+texinfo_dir_category: Emacs
|
||||
#+texinfo_dir_title: Org-roam: (org-roam).
|
||||
#+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
|
||||
#+property: header-args :eval never
|
||||
#+texinfo: @noindent
|
||||
|
||||
This manual is for Org-roam version 2.1.0.
|
||||
This manual is for Org-roam version 2.0.0.
|
||||
|
||||
#+BEGIN_QUOTE
|
||||
Copyright (C) 2020-2021 Jethro Kuan <jethrokuan95@gmail.com>
|
||||
|
@@ -31,7 +31,7 @@ General Public License for more details.
|
||||
@finalout
|
||||
@titlepage
|
||||
@title Org-roam User Manual
|
||||
@subtitle for version 2.1.0
|
||||
@subtitle for version 2.0.0
|
||||
@author Jethro Kuan
|
||||
@page
|
||||
@vskip 0pt plus 1filll
|
||||
@@ -44,7 +44,7 @@ General Public License for more details.
|
||||
|
||||
@noindent
|
||||
|
||||
This manual is for Org-roam version 2.1.0.
|
||||
This manual is for Org-roam version 2.0.0.
|
||||
|
||||
@quotation
|
||||
Copyright (C) 2020-2021 Jethro Kuan <jethrokuan95@@gmail.com>
|
||||
|
@@ -7,8 +7,8 @@
|
||||
;; Leo Vivier <leo.vivier+dev@gmail.com>
|
||||
;; URL: https://github.com/org-roam/org-roam
|
||||
;; Keywords: org-mode, roam, convenience
|
||||
;; Version: 2.1.0
|
||||
;; Package-Requires: ((emacs "26.1") (dash "2.13") (f "0.17.2") (org-roam "2.1"))
|
||||
;; Version: 2.0.0
|
||||
;; Package-Requires: ((emacs "26.1") (dash "2.13") (f "0.17.2") (org-roam "2.0"))
|
||||
|
||||
;; This file is NOT part of GNU Emacs.
|
||||
|
||||
|
@@ -5,8 +5,8 @@
|
||||
;; Author: Jethro Kuan <jethrokuan95@gmail.com>
|
||||
;; URL: https://github.com/org-roam/org-roam
|
||||
;; Keywords: org-mode, roam, convenience
|
||||
;; Version: 2.1.0
|
||||
;; Package-Requires: ((emacs "26.1") (org "9.4") (org-roam "2.1"))
|
||||
;; Version: 2.0.0
|
||||
;; Package-Requires: ((emacs "26.1") (org "9.4") (org-roam "2.0"))
|
||||
|
||||
;; This file is NOT part of GNU Emacs.
|
||||
|
||||
@@ -207,8 +207,7 @@ WITH RECURSIVE
|
||||
connected_component(source) AS
|
||||
(SELECT dest FROM links_of WHERE source = $s1 UNION
|
||||
SELECT dest FROM links_of JOIN connected_component USING(source))
|
||||
SELECT DISTINCT source, dest, type FROM links
|
||||
WHERE source IN connected_component OR dest IN connected_component;"
|
||||
SELECT source, dest, type FROM links WHERE source IN connected_component OR dest IN connected_component;"
|
||||
"
|
||||
WITH RECURSIVE
|
||||
links_of(source, dest) AS
|
||||
@@ -225,7 +224,7 @@ WITH RECURSIVE
|
||||
AND json_array_length(cc.trace) < $s2)),
|
||||
nodes(source) as (SELECT DISTINCT source
|
||||
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)))
|
||||
|
||||
(defun org-roam-graph--dot-option (option &optional wrap-key wrap-val)
|
||||
|
@@ -5,8 +5,8 @@
|
||||
;; Author: Jethro Kuan <jethrokuan95@gmail.com>
|
||||
;; URL: https://github.com/org-roam/org-roam
|
||||
;; Keywords: org-mode, roam, convenience
|
||||
;; Version: 2.1.0
|
||||
;; Package-Requires: ((emacs "26.1") (org "9.4") (org-roam "2.1"))
|
||||
;; Version: 2.0.0
|
||||
;; Package-Requires: ((emacs "26.1") (org "9.4") (org-roam "2.0"))
|
||||
|
||||
;; This file is NOT part of GNU Emacs.
|
||||
|
||||
|
@@ -4,8 +4,8 @@
|
||||
;; Author: Jethro Kuan <jethrokuan95@gmail.com>
|
||||
;; URL: https://github.com/org-roam/org-roam
|
||||
;; Keywords: org-mode, roam, convenience
|
||||
;; Version: 2.1.0
|
||||
;; Package-Requires: ((emacs "26.1") (org "9.4") (org-roam "2.1"))
|
||||
;; Version: 2.0.0
|
||||
;; Package-Requires: ((emacs "26.1") (org "9.4") (org-roam "2.0"))
|
||||
|
||||
;; 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"
|
||||
(when-let ((node (plist-get info :node)))
|
||||
(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)
|
||||
|
||||
(push '("org-roam-ref" :protocol "roam-ref" :function org-roam-protocol-open-ref)
|
||||
|
@@ -5,8 +5,8 @@
|
||||
;; Author: Jethro Kuan <jethrokuan95@gmail.com>
|
||||
;; URL: https://github.com/org-roam/org-roam
|
||||
;; Keywords: org-mode, roam, convenience
|
||||
;; Version: 2.1.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"))
|
||||
;; 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") (filenotify-recursive "0.0.1"))
|
||||
|
||||
;; This file is NOT part of GNU Emacs.
|
||||
|
||||
|
@@ -5,7 +5,7 @@
|
||||
;; Author: Jethro Kuan <jethrokuan95@gmail.com>
|
||||
;; URL: https://github.com/org-roam/org-roam
|
||||
;; Keywords: org-mode, roam, convenience
|
||||
;; Version: 2.1.0
|
||||
;; Version: 2.0.0
|
||||
;; Package-Requires: ((emacs "26.1"))
|
||||
|
||||
;; This file is NOT part of GNU Emacs.
|
||||
@@ -163,6 +163,9 @@ nodes." org-id-locations-file)
|
||||
(define-obsolete-function-alias
|
||||
'org-roam-teardown
|
||||
'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
|
||||
'org-roam-current-node
|
||||
|
194
org-roam-db.el
194
org-roam-db.el
@@ -5,8 +5,8 @@
|
||||
;; Author: Jethro Kuan <jethrokuan95@gmail.com>
|
||||
;; URL: https://github.com/org-roam/org-roam
|
||||
;; Keywords: org-mode, roam, convenience
|
||||
;; Version: 2.1.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"))
|
||||
;; 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") (filenotify-recursive "0.0.1"))
|
||||
|
||||
;; This file is NOT part of GNU Emacs.
|
||||
|
||||
@@ -31,6 +31,9 @@
|
||||
;;
|
||||
;;; Code:
|
||||
(require 'org-roam)
|
||||
(require 'filenotify)
|
||||
(require 'filenotify-recursive)
|
||||
|
||||
(defvar org-outline-path-cache)
|
||||
|
||||
;;; Options
|
||||
@@ -71,26 +74,38 @@ database."
|
||||
:type 'function
|
||||
:group 'org-roam)
|
||||
|
||||
(defcustom org-roam-db-update-on-save t
|
||||
"If t, update the Org-roam database upon saving the file.
|
||||
Disable this if your files are large and updating the database is
|
||||
slow."
|
||||
:type 'boolean
|
||||
(defcustom org-roam-db-autosync-update-method
|
||||
(if file-notify--library 'filenotify 'on-save)
|
||||
"What method to use to keep Org-roam's database updated.
|
||||
|
||||
'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)
|
||||
|
||||
;;; Variables
|
||||
;;; Initialization
|
||||
(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
|
||||
(with-demoted-errors "Org-roam initialization: %S"
|
||||
(emacsql-sqlite-ensure-binary)
|
||||
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 ()
|
||||
"Return the database connection, if any."
|
||||
(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 exists, update the cache with information."
|
||||
(setq file-path (or file-path (buffer-file-name (buffer-base-buffer))))
|
||||
(let ((content-hash (org-roam-db--file-hash file-path))
|
||||
(db-hash (caar (org-roam-db-query [:select hash :from files
|
||||
:where (= file $s1)] file-path))))
|
||||
(unless (string= content-hash db-hash)
|
||||
(org-roam-with-file file-path nil
|
||||
(save-excursion
|
||||
(org-set-regexps-and-options 'tags-only)
|
||||
(org-roam-db-clear-file)
|
||||
(org-roam-db-insert-file)
|
||||
(org-roam-db-insert-file-node)
|
||||
(setq org-outline-path-cache nil)
|
||||
(org-roam-db-map-nodes
|
||||
(list #'org-roam-db-insert-node-data
|
||||
#'org-roam-db-insert-aliases
|
||||
#'org-roam-db-insert-tags
|
||||
#'org-roam-db-insert-refs))
|
||||
(setq org-outline-path-cache nil)
|
||||
(org-roam-db-map-links
|
||||
(list #'org-roam-db-insert-link)))))))
|
||||
(org-roam-db-clear-file file-path)
|
||||
(when (file-exists-p file-path)
|
||||
(let ((content-hash (org-roam-db--file-hash file-path))
|
||||
(db-hash (caar (org-roam-db-query [:select hash :from files
|
||||
:where (= file $s1)] file-path))))
|
||||
(unless (string= content-hash db-hash)
|
||||
(org-roam-with-file file-path nil
|
||||
(save-excursion
|
||||
(org-set-regexps-and-options 'tags-only)
|
||||
(org-roam-db-insert-file)
|
||||
(org-roam-db-insert-file-node)
|
||||
(setq org-outline-path-cache nil)
|
||||
(org-roam-db-map-nodes
|
||||
(list #'org-roam-db-insert-node-data
|
||||
#'org-roam-db-insert-aliases
|
||||
#'org-roam-db-insert-tags
|
||||
#'org-roam-db-insert-refs))
|
||||
(setq org-outline-path-cache nil)
|
||||
(org-roam-db-map-links
|
||||
(list #'org-roam-db-insert-link))))))))
|
||||
|
||||
;;;###autoload
|
||||
(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)
|
||||
(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
|
||||
(define-minor-mode org-roam-db-autosync-mode
|
||||
"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
|
||||
:global t
|
||||
: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
|
||||
(enabled
|
||||
(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)
|
||||
(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))
|
||||
(t
|
||||
(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)
|
||||
(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)
|
||||
;; Disable local hooks for all org-roam buffers
|
||||
(dolist (buf (org-roam-buffer-list))
|
||||
(with-current-buffer buf
|
||||
(remove-hook 'after-save-hook #'org-roam-db-autosync--try-update-on-save-h t)))))))
|
||||
|
||||
;;;###autoload
|
||||
(defun org-roam-db-autosync-enable ()
|
||||
"Activate `org-roam-db-autosync-mode'."
|
||||
(org-roam-db-autosync-mode +1))
|
||||
(defvar org-roam-db-autosync--filenotify-descriptors (list)
|
||||
"An alist mapping watched Org-roam directories to `filenotify-recursive' uuid.")
|
||||
|
||||
(defun org-roam-db-autosync-disable ()
|
||||
"Deactivate `org-roam-db-autosync-mode'."
|
||||
(org-roam-db-autosync-mode -1))
|
||||
(defun org-roam-db-autosync--update-method (state method)
|
||||
"Change the current `org-roam-db-autosync-update-method' to METHOD.
|
||||
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 ()
|
||||
"Toggle `org-roam-db-autosync-mode' enabled/disabled."
|
||||
(org-roam-db-autosync-mode 'toggle))
|
||||
(defun org-roam-db-autosync--filenotify-update (event)
|
||||
"Update Org-roam's database according to EVENT sent by `filenotify'."
|
||||
(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)
|
||||
"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."
|
||||
(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 ()
|
||||
"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))
|
||||
|
||||
(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)))
|
||||
(add-hook 'after-save-hook #'org-roam-db-update-file nil t))
|
||||
|
||||
;;; Diagnostics
|
||||
(defun org-roam-db-diagnose-node ()
|
||||
|
@@ -5,8 +5,8 @@
|
||||
;; Author: Jethro Kuan <jethrokuan95@gmail.com>
|
||||
;; URL: https://github.com/org-roam/org-roam
|
||||
;; Keywords: org-mode, roam, convenience
|
||||
;; Version: 2.1.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"))
|
||||
;; 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") (filenotify-recursive "0.0.1"))
|
||||
|
||||
;; This file is NOT part of GNU Emacs.
|
||||
|
||||
|
@@ -5,8 +5,8 @@
|
||||
;; Author: Jethro Kuan <jethrokuan95@gmail.com>
|
||||
;; URL: https://github.com/org-roam/org-roam
|
||||
;; Keywords: org-mode, roam, convenience
|
||||
;; Version: 2.1.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"))
|
||||
;; 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") (filenotify-recursive "0.0.1"))
|
||||
|
||||
;; 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.")
|
||||
|
||||
(defun org-roam-preview-visit (file point &optional other-window)
|
||||
"Visit FILE at POINT and return the visited buffer.
|
||||
With OTHER-WINDOW non-nil do so in another window.
|
||||
"Visit FILE at POINT. With OTHER-WINDOW non-nil do so in another window.
|
||||
In interactive calls OTHER-WINDOW is set with
|
||||
`universal-argument'."
|
||||
(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
|
||||
#'switch-to-buffer-other-window
|
||||
#'pop-to-buffer-same-window)))
|
||||
(funcall display-buffer-fn buf)
|
||||
(with-current-buffer buf
|
||||
(widen)
|
||||
(goto-char point))
|
||||
(when (org-invisible-p) (org-show-context))
|
||||
buf))
|
||||
(funcall display-buffer-fn buf)
|
||||
(when (org-invisible-p) (org-show-context))))
|
||||
|
||||
(defun org-roam-preview-get-contents (file 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.")
|
||||
|
||||
(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
|
||||
`universal-argument') display the buffer in another window
|
||||
instead."
|
||||
@@ -607,7 +605,6 @@ instead."
|
||||
(display-buffer-fn (if other-window
|
||||
#'switch-to-buffer-other-window
|
||||
#'pop-to-buffer-same-window)))
|
||||
(funcall display-buffer-fn buf)
|
||||
(with-current-buffer buf
|
||||
(widen)
|
||||
(goto-char (point-min))
|
||||
@@ -615,8 +612,8 @@ instead."
|
||||
(forward-line (1- row)))
|
||||
(when col
|
||||
(forward-char (1- col))))
|
||||
(when (org-invisible-p) (org-show-context))
|
||||
buf))
|
||||
(funcall display-buffer-fn buf)
|
||||
(when (org-invisible-p) (org-show-context))))
|
||||
|
||||
;;;; Unlinked references
|
||||
(defvar org-roam-unlinked-references-result-re
|
||||
|
110
org-roam-node.el
110
org-roam-node.el
@@ -5,7 +5,7 @@
|
||||
;; Author: Jethro Kuan <jethrokuan95@gmail.com>
|
||||
;; URL: https://github.com/org-roam/org-roam
|
||||
;; 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"))
|
||||
|
||||
;; 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))
|
||||
: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
|
||||
"This function used to attach annotations for `org-roam-ref-read'.
|
||||
It takes a single argument REF, which is a propertized string.")
|
||||
@@ -369,31 +354,23 @@ GROUP BY id")))
|
||||
all-titles)))))
|
||||
|
||||
;;;; Finders
|
||||
(defun org-roam-node-find-noselect (node &optional force)
|
||||
"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."
|
||||
(defun org-roam-node-find-noselect (node)
|
||||
"Navigate to the point for NODE, and return the buffer."
|
||||
(unless (org-roam-node-file node)
|
||||
(user-error "Node does not have corresponding file"))
|
||||
(let ((buf (find-file-noselect (org-roam-node-file node))))
|
||||
(with-current-buffer buf
|
||||
(when (or force
|
||||
(not (equal (org-roam-node-id node)
|
||||
(org-roam-id-at-point))))
|
||||
(goto-char (org-roam-node-point node))))
|
||||
(goto-char (org-roam-node-point node)))
|
||||
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.
|
||||
|
||||
Display the buffer in the selected window. With a prefix
|
||||
argument OTHER-WINDOW display the buffer in another window
|
||||
instead.
|
||||
|
||||
If NODE is already visited, this won't automatically move the
|
||||
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))
|
||||
instead."
|
||||
(interactive (list (org-roam-node-at-point t) current-prefix-arg))
|
||||
(let ((buf (org-roam-node-find-noselect node))
|
||||
(display-buffer-fn (if other-window
|
||||
#'switch-to-buffer-other-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)))))
|
||||
(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)
|
||||
"Formats NODE for display in the results list.
|
||||
WIDTH is the width of the results list.
|
||||
Uses `org-roam-node-display-template' to format the entry."
|
||||
(pcase-let ((`(,tmpl . ,tmpl-width)
|
||||
(org-roam-node-read--process-display-format org-roam-node-display-template)))
|
||||
(let ((fmt (org-roam-node-read--process-display-format org-roam-node-display-template)))
|
||||
(org-roam-format-template
|
||||
tmpl
|
||||
(car fmt)
|
||||
(lambda (field _default-val)
|
||||
(pcase-let* ((`(,field-name ,field-width) (split-string field ":"))
|
||||
(getter (intern (concat "org-roam-node-" field-name)))
|
||||
(field-value (funcall getter node)))
|
||||
(let* ((field (split-string field ":"))
|
||||
(field-name (car field))
|
||||
(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")
|
||||
field-value)
|
||||
(setq field-value (file-relative-name field-value org-roam-directory)))
|
||||
(when (and (equal field-name "olp")
|
||||
field-value)
|
||||
(setq field-value (string-join field-value " > ")))
|
||||
(when (and field-value (not (listp field-value)))
|
||||
(setq field-value (list field-value)))
|
||||
(setq field-value (mapconcat
|
||||
(lambda (v)
|
||||
(concat (or (cdr (assoc field-name org-roam-node-template-prefixes))
|
||||
"")
|
||||
v))
|
||||
field-value " "))
|
||||
(setq field-width (cond
|
||||
((not field-width)
|
||||
field-width)
|
||||
((string-equal field-width "*")
|
||||
(- width tmpl-width))
|
||||
((>= (string-to-number field-width) 0)
|
||||
(string-to-number field-width))))
|
||||
;; Setting the display (which would be padded out to the field length) for an
|
||||
;; empty string results in an empty string and misalignment for candidates that
|
||||
;; don't have some field. This uses the actual display string, made of spaces
|
||||
;; 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))))))))
|
||||
(if (not field-width)
|
||||
field-value
|
||||
(setq field-width (string-to-number field-width))
|
||||
(let ((display-string (truncate-string-to-width
|
||||
field-value
|
||||
(if (> field-width 0)
|
||||
field-width
|
||||
(- width (cdr fmt)))
|
||||
0 ?\s)))
|
||||
;; Setting the display (which would be padded out to the field length) for an
|
||||
;; empty string results in an empty string and misalignment for candidates that
|
||||
;; don't have some field. This uses the actual display string, made of spaces
|
||||
;; when the field-value is "" so that we actually take up space.
|
||||
(if (not (equal field-value ""))
|
||||
;; 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)
|
||||
display-string))))))))
|
||||
|
||||
(defun org-roam-node-read--process-display-format (format)
|
||||
"Pre-calculate minimal widths needed by the FORMAT string."
|
||||
@@ -621,7 +597,7 @@ Assumes that the cursor was put where the link is."
|
||||
(cond
|
||||
((org-roam-node-file node)
|
||||
(org-mark-ring-push)
|
||||
(org-roam-node-visit node nil 'force)
|
||||
(org-roam-node-visit node)
|
||||
t)
|
||||
(t nil))))))
|
||||
|
||||
@@ -635,7 +611,7 @@ Assumes that the cursor was put where the link is."
|
||||
(when org-roam-link-auto-replace
|
||||
(org-roam-link-replace-at-point))
|
||||
(org-mark-ring-push)
|
||||
(org-roam-node-visit node nil 'force))
|
||||
(org-roam-node-visit node))
|
||||
(org-roam-capture-
|
||||
:node (org-roam-node-create :title title-or-alias)
|
||||
:props '(:finalize find-file))))
|
||||
|
@@ -5,7 +5,7 @@
|
||||
;; Author: Jethro Kuan <jethrokuan95@gmail.com>
|
||||
;; URL: https://github.com/org-roam/org-roam
|
||||
;; Keywords: org-mode, roam, convenience
|
||||
;; Version: 2.1.0
|
||||
;; Version: 2.0.0
|
||||
;; Package-Requires: ((emacs "26.1") (dash "2.13") (org "9.4"))
|
||||
|
||||
;; 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.
|
||||
Interactively, or when MESSAGE is non-nil, show in the echo area."
|
||||
(interactive)
|
||||
(let* ((toplib (or load-file-name buffer-file-name))
|
||||
gitdir topdir version)
|
||||
(unless (and toplib (equal (file-name-nondirectory toplib) "org-roam-utils.el"))
|
||||
(setq toplib (locate-library "org-roam-utils.el")))
|
||||
(setq toplib (and toplib (org-roam--straight-chase-links toplib)))
|
||||
(when toplib
|
||||
(setq topdir (file-name-directory toplib)
|
||||
gitdir (expand-file-name ".git" topdir)))
|
||||
(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")))))
|
||||
(let* ((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))
|
||||
(message "%s" 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
|
||||
(defun org-roam-diagnostics ()
|
||||
"Collect and print info for `org-roam' issues."
|
||||
|
@@ -5,8 +5,8 @@
|
||||
;; Author: Jethro Kuan <jethrokuan95@gmail.com>
|
||||
;; URL: https://github.com/org-roam/org-roam
|
||||
;; Keywords: org-mode, roam, convenience
|
||||
;; Version: 2.1.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"))
|
||||
;; 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") (filenotify-recursive "0.0.1"))
|
||||
|
||||
;; This file is NOT part of GNU Emacs.
|
||||
|
||||
|
Reference in New Issue
Block a user