summaryrefslogtreecommitdiffstatshomepage
path: root/nroam.el
diff options
context:
space:
mode:
authorGravatar Nicolas Petton2021-02-23 15:00:17 +0100
committerGravatar GitHub2021-02-23 15:00:17 +0100
commit8ce18feb8ee7ea0da12cf90aff2e85b0fecb592a (patch)
tree9b451e0e3bcc02fb7d1c772bf3113865ef1241c9 /nroam.el
parent40ba80de1a79b435f396adbe7d9045dfb99c6385 (diff)
parent3a0d7a3696f3bebc4fe117e18d94068443aaca83 (diff)
downloadnroam-8ce18feb8ee7ea0da12cf90aff2e85b0fecb592a.tar.gz
nroam-8ce18feb8ee7ea0da12cf90aff2e85b0fecb592a.zip
Merge pull request #1 from Whil-/master
Make crawler not crawl and as a consequence ... speed up things a lot!
Diffstat (limited to 'nroam.el')
-rw-r--r--nroam.el26
1 files changed, 18 insertions, 8 deletions
diff --git a/nroam.el b/nroam.el
index bbadffb..5120905 100644
--- a/nroam.el
+++ b/nroam.el
@@ -44,6 +44,8 @@
(defvar-local nroam-start-marker nil)
(defvar-local nroam-end-marker nil)
+(defvar nroam-work-buffer " nroam-work")
+
(defmacro with-nroam-markers (&rest body)
"Evaluate BODY.
Make the region inserted by BODY read-only, and marked with
@@ -68,6 +70,7 @@ Make the region inserted by BODY read-only, and marked with
:keymap nroam-mode-map
(if nroam-mode
(progn
+ (nroam--init-work-buffer)
(add-hook 'before-save-hook #'nroam--prune-backlinks nil t)
(add-hook 'after-save-hook #'nroam--update-backlinks-maybe nil t)
(nroam-update-backlinks))
@@ -75,6 +78,13 @@ Make the region inserted by BODY read-only, and marked with
(remove-hook 'after-save-hook #'nroam--update-backlinks-maybe t)
(nroam--prune-backlinks)))
+(defun nroam--init-work-buffer ()
+ "Initiate nroam hidden buffer."
+ (get-buffer-create nroam-work-buffer t)
+ (with-current-buffer nroam-work-buffer
+ (delay-mode-hooks
+ (org-mode))))
+
(defun nroam-ctrl-c-ctrl-c ()
"Update the backlinks for the current buffer, or fallback to `org-ctrl-c-ctrl-c'."
(interactive)
@@ -198,14 +208,14 @@ Make the region inserted by BODY read-only, and marked with
(defun nroam--crawl-source (file point)
"Return the source element in FILE at POINT."
- (with-current-buffer (find-file-noselect file)
- (save-excursion
- (goto-char point)
- (let ((elt (org-element-at-point)))
- (let ((begin (org-element-property :begin elt))
- (end (org-element-property :end elt))
- (type (org-element-type elt)))
- `(,type . ,(buffer-substring begin end)))))))
+ (with-current-buffer nroam-work-buffer
+ (insert-file-contents file nil nil nil 'replace)
+ (goto-char point)
+ (let ((elt (org-element-at-point)))
+ (let ((begin (org-element-property :begin elt))
+ (end (org-element-property :end elt))
+ (type (org-element-type elt)))
+ `(,type . ,(buffer-substring begin end))))))
(defun nroam--fix-links (content origin)
"Correct all relative links in CONTENT from ORIGIN.