mirror of
https://github.com/org-roam/org-roam
synced 2025-08-03 12:27:23 -05:00
Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
57fadf54a6 | |||
54a6eeaf1d | |||
89dfaef38b | |||
fc8638759b | |||
1958e035fc | |||
1ea7e3077c |
29
.github/workflows/tidy-issues.yml
vendored
29
.github/workflows/tidy-issues.yml
vendored
@ -71,12 +71,6 @@ jobs:
|
||||
|
||||
This pull request was automatically closed due to **6 months of inactivity** followed by 2 weeks notice.
|
||||
|
||||
**To reopen:**
|
||||
- If still relevant, comment below or push new commits
|
||||
- Or create a new PR with updated changes
|
||||
|
||||
If this PR is not reopened in 2 weeks, it will be locked.
|
||||
|
||||
# Timing (6 months + 2 weeks)
|
||||
days-before-stale: 182 # ~6 months
|
||||
days-before-close: 14 # 2 weeks notice
|
||||
@ -97,26 +91,3 @@ jobs:
|
||||
echo "2. Click 'Run workflow'"
|
||||
echo "3. Leave 'Dry run mode' unchecked"
|
||||
echo "4. Click 'Run workflow'"
|
||||
|
||||
lock:
|
||||
runs-on: ubuntu-latest
|
||||
needs: stale
|
||||
# Only run lock job if NOT in dry run mode
|
||||
if: github.event.inputs.dry_run != 'true'
|
||||
steps:
|
||||
# Lock issues/PRs that have been closed for 2 weeks or more
|
||||
- name: Lock closed issues
|
||||
uses: dessant/lock-threads@v5
|
||||
with:
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
issue-inactive-days: 14
|
||||
issue-lock-reason: 'resolved'
|
||||
process-only: 'issues'
|
||||
|
||||
- name: Lock closed PRs
|
||||
uses: dessant/lock-threads@v5
|
||||
with:
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
pr-inactive-days: 14
|
||||
pr-lock-reason: 'resolved'
|
||||
process-only: 'prs'
|
||||
|
@ -655,12 +655,14 @@ database, see `org-roam-db-sync' command."
|
||||
(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)
|
||||
(advice-add #'vc-delete-file :around #'org-roam-db-autosync--vc-delete-file-a)
|
||||
(org-roam-db-sync))
|
||||
(t
|
||||
(remove-hook 'find-file-hook #'org-roam-db-autosync--setup-file-h)
|
||||
(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)
|
||||
(advice-remove #'vc-delete-file #'org-roam-db-autosync--vc-delete-file-a)
|
||||
(org-roam-db--close-all)
|
||||
;; Disable local hooks for all org-roam buffers
|
||||
(dolist (buf (org-roam-buffer-list))
|
||||
@ -688,6 +690,17 @@ FILE is removed from the database."
|
||||
(org-roam-file-p file))
|
||||
(org-roam-db-clear-file (expand-file-name file))))
|
||||
|
||||
(defun org-roam-db-autosync--vc-delete-file-a (fun file)
|
||||
"Maintain cache consistency on file deletion by FUN.
|
||||
FILE is removed from the database."
|
||||
(let ((org-roam-file-p (and (not (auto-save-file-name-p file))
|
||||
(not (backup-file-name-p file))
|
||||
(org-roam-file-p file))))
|
||||
(apply fun `(,file))
|
||||
(when (and org-roam-file-p
|
||||
(not (file-exists-p file)))
|
||||
(org-roam-db-clear-file (expand-file-name file)))))
|
||||
|
||||
(defun org-roam-db-autosync--rename-file-a (old-file new-file-or-dir &rest _args)
|
||||
"Maintain cache consistency of file rename.
|
||||
OLD-FILE is cleared from the database, and NEW-FILE-OR-DIR is added."
|
||||
|
@ -167,6 +167,10 @@ This path is relative to `org-roam-directory'."
|
||||
:group 'org-roam
|
||||
:type 'string)
|
||||
|
||||
(defvar org-roam-link-type "roam"
|
||||
"Link type for org-roam nodes.
|
||||
Replaced by `id' automatically when `org-roam-link-auto-replace' is non-nil.")
|
||||
|
||||
(defvar org-roam-node-history nil
|
||||
"Minibuffer history of nodes.")
|
||||
|
||||
@ -768,7 +772,7 @@ The INFO, if provided, is passed to the underlying `org-roam-capture-'."
|
||||
(deactivate-mark)))
|
||||
|
||||
;;;;; [roam:] link
|
||||
(org-link-set-parameters "roam" :follow #'org-roam-link-follow-link)
|
||||
(org-link-set-parameters org-roam-link-type :follow #'org-roam-link-follow-link)
|
||||
(defun org-roam-link-follow-link (title-or-alias)
|
||||
"Navigate \"roam:\" link to find and open the node with TITLE-OR-ALIAS.
|
||||
Assumes that the cursor was put where the link is."
|
||||
@ -797,7 +801,7 @@ Assumes that the cursor was put where the link is."
|
||||
node)
|
||||
(goto-char (org-element-property :begin link))
|
||||
(when (and (org-in-regexp org-link-any-re 1)
|
||||
(string-equal type "roam")
|
||||
(string-equal type org-roam-link-type)
|
||||
(setq node (save-match-data (org-roam-node-from-title-or-alias path))))
|
||||
(replace-match (org-link-make-string
|
||||
(concat "id:" (org-roam-node-id node))
|
||||
@ -807,7 +811,7 @@ Assumes that the cursor was put where the link is."
|
||||
"Replace all \"roam:\" links in buffer with \"id:\" links."
|
||||
(interactive)
|
||||
(org-with-point-at 1
|
||||
(while (re-search-forward org-link-bracket-re nil t)
|
||||
(while (search-forward (concat "[[" org-roam-link-type ":") nil t)
|
||||
(org-roam-link-replace-at-point))))
|
||||
|
||||
(add-hook 'org-roam-find-file-hook #'org-roam--replace-roam-links-on-save-h)
|
||||
|
56
tests/test-org-roam-link-replace.el
Normal file
56
tests/test-org-roam-link-replace.el
Normal file
@ -0,0 +1,56 @@
|
||||
;;; test-org-roam-link-replace.el --- Tests for Org-roam link replacement -*- lexical-binding: t; -*-
|
||||
|
||||
;; Copyright (C) 2025
|
||||
|
||||
;; Package-Requires: ((buttercup))
|
||||
|
||||
;; This program is free software; you can redistribute it and/or modify
|
||||
;; it under the terms of the GNU General Public License as published by
|
||||
;; the Free Software Foundation, either version 3 of the License, or
|
||||
;; (at your option) any later version.
|
||||
|
||||
;; This program is distributed in the hope that it will be useful,
|
||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;; GNU General Public License for more details.
|
||||
|
||||
;; You should have received a copy of the GNU General Public License
|
||||
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
;; Tests for commits fc86387 and 89dfaef - link replacement optimization
|
||||
;;; Code:
|
||||
|
||||
(require 'buttercup)
|
||||
(require 'org-roam)
|
||||
(require 'org-roam-node)
|
||||
|
||||
(describe "org-roam-link-replace-all optimization"
|
||||
(before-all
|
||||
(setq org-roam-directory (expand-file-name "tests/roam-files")
|
||||
org-roam-db-location (expand-file-name "org-roam.db" temporary-file-directory))
|
||||
(org-roam-db-sync))
|
||||
|
||||
(after-all
|
||||
(org-roam-db--close)
|
||||
(delete-file org-roam-db-location))
|
||||
|
||||
(it "only processes roam: links, not other bracket links"
|
||||
(with-temp-buffer
|
||||
(org-mode)
|
||||
(insert "[[file:test.org][File]]\n[[roam:Foo]]\n[[https://example.com][Web]]")
|
||||
(let ((replace-count 0)
|
||||
(original-fn (symbol-function 'org-roam-link-replace-at-point)))
|
||||
;; Wrap the original function to count calls
|
||||
(cl-letf (((symbol-function 'org-roam-link-replace-at-point)
|
||||
(lambda ()
|
||||
(cl-incf replace-count)
|
||||
(funcall original-fn))))
|
||||
(org-roam-link-replace-all)
|
||||
;; Should only be called once, for the roam: link
|
||||
(expect replace-count :to-equal 1)
|
||||
(expect (buffer-string) :to-match "\\[\\[id:.*\\]\\[Foo\\]\\]"))))))
|
||||
|
||||
(provide 'test-org-roam-link-replace)
|
||||
|
||||
;;; test-org-roam-link-replace.el ends here
|
@ -73,14 +73,16 @@
|
||||
(expect (org-roam-node-title node) :to-equal "Bruce Wayne"))))
|
||||
|
||||
(describe "org-roam-demote-entire-buffer"
|
||||
(after-each
|
||||
(cd root-directory))
|
||||
|
||||
(it "demotes an entire org buffer"
|
||||
(find-file "tests/roam-files/demoteable.org" nil)
|
||||
(org-roam-demote-entire-buffer)
|
||||
(expect (buffer-substring-no-properties (point) (point-max))
|
||||
:to-equal "* Demoteable\n:PROPERTIES:\n:ID: 97bf31cf-dfee-45d8-87a5-2ae0dabc4734\n:END:\n\n** Demoteable h1\n\n*** Demoteable child\n")))
|
||||
;; Use a temporary copy to avoid interfering with other tests
|
||||
(let ((temp-file (make-temp-file "test-demoteable-" nil ".org")))
|
||||
(copy-file "tests/roam-files/demoteable.org" temp-file t)
|
||||
(find-file temp-file)
|
||||
(org-roam-demote-entire-buffer)
|
||||
(expect (buffer-substring-no-properties (point) (point-max))
|
||||
:to-equal "* Demoteable\n:PROPERTIES:\n:ID: 97bf31cf-dfee-45d8-87a5-2ae0dabc4734\n:END:\n\n** Demoteable h1\n\n*** Demoteable child\n")
|
||||
(kill-buffer)
|
||||
(delete-file temp-file))))
|
||||
|
||||
(describe "org-roam--h1-count"
|
||||
(after-each
|
||||
|
Reference in New Issue
Block a user