Skip to content

Commit

Permalink
Add zk--no-gc
Browse files Browse the repository at this point in the history
Improves performance of relevant functions

Also include title by default in zk-luhmann-completion-at-point
  • Loading branch information
localauthor committed Aug 12, 2024
1 parent 836943c commit ed0bd2a
Showing 1 changed file with 20 additions and 12 deletions.
32 changes: 20 additions & 12 deletions zk-luhmann.el
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ and `zk-luhmann-id-delimiter'."
(file (zk--parse-id 'file-path id)))
(delete-char (- -1 (length str)))
(insert (car
(zk-luhmann--formatter file))))
(zk-luhmann--formatter file t))))
(when zk-enable-link-buttons
(zk-make-button-before-point)))))))))

Expand Down Expand Up @@ -305,15 +305,18 @@ Optional INCL-TITLE. When NO-PROC is non-nil, bypass `zk--processor'."

;;; Luhmann Index

(defvar zk--no-gc)

(defun zk-luhmann--index (&rest args)
"Wrapper around `zk-index' to implement `zk-luhmann-indent-index'.
Passes ARGS to `zk-index'."
(if zk-luhmann-indent-index
(let ((zk-index-prefix ""))
(advice-add 'zk-index--insert :override #'zk-luhmann-index--insert)
(apply #'zk-index args)
(advice-remove 'zk-index--insert #'zk-luhmann-index--insert))
(apply #'zk-index args)))
(let ((zk--no-gc t))
(if zk-luhmann-indent-index
(let ((zk-index-prefix ""))
(advice-add 'zk-index--insert :override #'zk-luhmann-index--insert)
(apply #'zk-index args)
(advice-remove 'zk-index--insert #'zk-luhmann-index--insert))
(apply #'zk-index args))))

(defun zk-luhmann-index--insert (candidates)
"Insert CANDIDATES into ZK-Index."
Expand Down Expand Up @@ -350,7 +353,8 @@ Passes ARGS to `zk-index'."
(defun zk-luhmann-index ()
"Open index for Luhmann-ID notes."
(interactive)
(let ((zk-luhmann-count-format nil)) ; for efficiency
(let ((zk--no-gc t)
(zk-luhmann-count-format nil)) ; for efficiency
(when (eq major-mode 'zk-index-mode)
(zk-index--reset-mode-line)
(zk-index--reset-mode-name)
Expand All @@ -360,7 +364,8 @@ Passes ARGS to `zk-index'."
"Sort index according to Luhmann-IDs."
(interactive)
(when (eq major-mode 'zk-index-mode)
(let ((file-list (zk-index--current-file-list)))
(let* ((zk--no-gc t)
(file-list (zk-index--current-file-list)))
(when (listp file-list)
(zk-index-refresh file-list
zk-index-last-format-function
Expand All @@ -373,7 +378,8 @@ Passes ARGS to `zk-index'."
(when (eq major-mode 'zk-index-mode)
(zk-index--reset-mode-line)
(zk-index--reset-mode-name)
(let ((buffer-string (buffer-string)))
(let ((zk--no-gc t)
(buffer-string (buffer-string)))
(zk-luhmann--index (zk--directory-files
t
(concat zk-luhmann-id-prefix
Expand All @@ -393,7 +399,8 @@ Passes ARGS to `zk-index'."
(when (eq major-mode 'zk-index-mode)
(zk-index--reset-mode-line)
(zk-index--reset-mode-name)
(let* ((buffer-string (buffer-string))
(let* ((zk--no-gc t)
(buffer-string (buffer-string))
(regexp (concat zk-luhmann-id-prefix
".[^"
zk-luhmann-id-postfix
Expand Down Expand Up @@ -444,7 +451,8 @@ Passes ARGS to `zk-index'."
(unless (eq zk-index-last-sort-function
'zk-luhmann-sort)
(zk-luhmann-index-sort))
(let* ((buffer-string (buffer-string))
(let* ((zk--no-gc t)
(buffer-string (buffer-string))
(backward-rx (concat zk-luhmann-id-prefix
".*"
zk-luhmann-id-postfix))
Expand Down

0 comments on commit ed0bd2a

Please sign in to comment.