branch: elpa/gnosis
commit d89fb6ba8ec908c3a31815407ffce350fc664578
Author: Thanos Apollo <[email protected]>
Commit: Thanos Apollo <[email protected]>
[New] bulk-link-themata: Accept list of IDs for scoped bulk linking.
---
gnosis.el | 29 +++++++++++++++++------------
1 file changed, 17 insertions(+), 12 deletions(-)
diff --git a/gnosis.el b/gnosis.el
index e59771d9a7..6aef1fa53b 100644
--- a/gnosis.el
+++ b/gnosis.el
@@ -1794,29 +1794,34 @@ Reopens the gnosis database after successful pull."
(when (and gnosis-vc-auto-push (not gnosis-testing))
(gnosis-vc-push))))
-;;;###autoload
-(defun gnosis-bulk-link-string (string node-id)
- "Replace all instances of STRING in themata keimenon with org-link to
NODE-ID."
- (interactive
- (let* ((string (read-string "String to replace: "))
- (nodes (org-gnosis-select '[id title] 'nodes))
- (node-title (gnosis-completing-read "Select node: " (mapcar #'cadr
nodes)))
- (node-id (car (cl-find node-title nodes :key #'cadr :test
#'string=))))
- (list string node-id)))
+(defun gnosis-bulk-link-themata (ids string node-id)
+ "Replace STRING with org-link to NODE-ID in themata with IDS.
+Return list of updated thema IDs."
(when (string-empty-p string)
(user-error "String cannot be empty"))
(unless node-id
(user-error "Node not found"))
- (let* ((themata (gnosis-select '[id keimenon] 'themata nil))
+ (let* ((themata (gnosis-select '[id keimenon] 'themata
+ `(in id ,(vconcat ids))))
(count (gnosis--count-themata-with-string themata string)))
(if (zerop count)
- (message "No themata contain '%s'" string)
+ (progn (message "No themata contain '%s'" string) nil)
(when (y-or-n-p (format "Replace '%s' in %d themata? " string count))
(let ((updates (gnosis--themata-to-update themata string node-id)))
(gnosis--update-themata-keimenon updates)
(gnosis--commit-bulk-link (length updates) string)
(message "Updated %d themata with links to '%s'" (length updates)
string)
- (length updates))))))
+ (mapcar #'car updates))))))
+
+(defun gnosis-bulk-link-string (string node-id)
+ "Replace all instances of STRING in themata keimenon with org-link to
NODE-ID."
+ (interactive
+ (let* ((string (read-string "String to replace: "))
+ (nodes (org-gnosis-select '[id title] 'nodes))
+ (node-title (gnosis-completing-read "Select node: " (mapcar #'cadr
nodes)))
+ (node-id (car (cl-find node-title nodes :key #'cadr :test
#'string=))))
+ (list string node-id)))
+ (gnosis-bulk-link-themata (gnosis-select 'id 'themata nil t) string node-id))
;;; Link integrity