branch: externals/org-gnosis
commit cf4e914b65965aa99f06d6a04882e1cf8a4ce62a
Author: Thanos Apollo <[email protected]>
Commit: Thanos Apollo <[email protected]>
adjust-title: Link link ids in node titles.
* Add link ids in titles in databse.
---
org-gnosis.el | 20 +++++++++++++++++---
1 file changed, 17 insertions(+), 3 deletions(-)
diff --git a/org-gnosis.el b/org-gnosis.el
index 6d5e5ebb5b..f2e8899c51 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."