summaryrefslogtreecommitdiffhomepage
path: root/lib
diff options
context:
space:
mode:
authorjao <jao@gnu.org>2024-10-19 19:40:21 +0100
committerjao <jao@gnu.org>2024-10-19 19:40:21 +0100
commit6203f490e8747977c0dfdb797cd46327fe7c63dd (patch)
tree9e8309ea8ce8a15dce96087554237f4fd276d583 /lib
parent22b6c1dd68436d18f16e0e65dc53f85db89e4c0c (diff)
downloadelibs-6203f490e8747977c0dfdb797cd46327fe7c63dd.tar.gz
elibs-6203f490e8747977c0dfdb797cd46327fe7c63dd.tar.bz2
notes: capture org note from eww instead of tmp buffer
Diffstat (limited to 'lib')
-rw-r--r--lib/doc/jao-org-notes.el15
1 files changed, 8 insertions, 7 deletions
diff --git a/lib/doc/jao-org-notes.el b/lib/doc/jao-org-notes.el
index bd82543..43b8c09 100644
--- a/lib/doc/jao-org-notes.el
+++ b/lib/doc/jao-org-notes.el
@@ -71,13 +71,13 @@
(and (string-match-p "^[^:]+ + :" m) "tags")
"titles"))
-(defun jao-org-notes--consult-rg (prompt &optional cat no-req cmd)
+(defun jao-org-notes--consult-rg (prompt &optional cat no-req cmd initial)
(let ((default-directory (expand-file-name (or cat "") jao-org-notes-dir)))
(consult--read
(consult--async-command #'jao-org-notes--rg-title-or-tags
(consult--async-transform jao-org-notes--matches))
:prompt prompt
- :initial (consult--async-split-initial "")
+ :initial (consult--async-split-initial (or initial ""))
:add-history (concat (consult--async-split-initial (thing-at-point 'symbol)))
:require-match (not no-req)
:category 'jao-org-notes-lookup
@@ -94,9 +94,10 @@
(cond ((file-exists-p (expand-file-name cat jao-org-notes-dir)) cat)
((yes-or-no-p "New category, create?") cat))))
-(defun jao-org-notes--insert-title ()
+(defun jao-org-notes--insert-title (&optional title)
(let* ((cat (jao-org-notes--cat))
- (title (file-name-base (jao-org-notes--consult-rg "Title: " cat t)))
+ (note (jao-org-notes--consult-rg "Title: " cat t nil title))
+ (title (file-name-base note))
(title (replace-regexp-in-string "^#" "" title)))
(when (not (string-empty-p title))
(let* ((base (replace-regexp-in-string " +" "-" (downcase title)))
@@ -160,16 +161,16 @@
(interactive)
(consult-ripgrep (expand-file-name (or cat "") jao-org-notes-dir) initial))
-(defun jao-org-notes-create ()
+(defun jao-org-notes-create (&optional title)
"Create a new note file, matching tags and titles with completion."
(interactive)
- (when (jao-org-notes--insert-title)
+ (when (jao-org-notes--insert-title title)
(org-insert-time-stamp (current-time) t t "#+date: " "\n")
(insert "#+tags: :"
(mapconcat #'identity (jao-org-notes--read-tags) ":")
":\n"))
(save-buffer)
- (buffer-file-name))
+ (current-buffer))
(defun jao-org-notes-backlinks ()
"Show a list of note files linking to the current one."