From 6203f490e8747977c0dfdb797cd46327fe7c63dd Mon Sep 17 00:00:00 2001 From: jao Date: Sat, 19 Oct 2024 19:40:21 +0100 Subject: notes: capture org note from eww instead of tmp buffer --- lib/doc/jao-org-notes.el | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'lib') 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." -- cgit v1.2.3