summaryrefslogtreecommitdiff
path: root/org-gnosis.el
diff options
context:
space:
mode:
authorThanos Apollo <[email protected]>2024-12-05 18:20:20 +0200
committerThanos Apollo <[email protected]>2024-12-05 18:20:20 +0200
commitcf4e914b65965aa99f06d6a04882e1cf8a4ce62a (patch)
treeaa31d7702522ccccd7fcbde0b7f4801838b603f3 /org-gnosis.el
parentc1234ac1ebc4614021c4813eff6e0485faafcd68 (diff)
adjust-title: Link link ids in node titles.
* Add link ids in titles in databse.
Diffstat (limited to 'org-gnosis.el')
-rw-r--r--org-gnosis.el20
1 files changed, 17 insertions, 3 deletions
diff --git a/org-gnosis.el b/org-gnosis.el
index 6d5e5eb..f2e8899 100644
--- a/org-gnosis.el
+++ b/org-gnosis.el
@@ -173,10 +173,24 @@ FILE: File path"
(links (org-gnosis-get-links parsed-data)))
`(:file ,filename :topic ,topic :nodes ,nodes :links ,links)))
-(defun org-gnosis-adjust-title (input)
- "Adjust the INPUT string to replace id link structures with plain text."
+(defun org-gnosis-adjust-title (input &optional node-id)
+ "Adjust the INPUT string to replace id link structures with plain text.
+
+Adjust title INPUT for NODE-ID. If node-id contains an id link, it's
+inserted as link for NODE-ID in the database."
(when (stringp input)
- (replace-regexp-in-string "\\[\\[id:[^]]+\\]\\[\\(.*?\\)\\]\\]" "\\1" input)))
+ (let* ((id-links '())
+ (new-input (replace-regexp-in-string
+ "\\[\\[id:[^]]+\\]\\[\\(.*?\\)\\]\\]"
+ (lambda (match)
+ (push (match-string 1 match) id-links)
+ (match-string 1 match))
+ input)))
+ (when (and node-id id-links)
+ (emacsql-with-transaction org-gnosis-db
+ (cl-loop for link in (reverse id-links)
+ do (org-gnosis--insert-into 'links `([,node-id ,link])))))
+ new-input)))
(defun org-gnosis-get-file-info (filename)
"Something FILENAME."