casouri / xeft

Fast, interactive Emacs note searching
89 stars 9 forks source link

how to use it with org-roam #32

Open Aneeqasif opened 6 months ago

Aneeqasif commented 6 months ago

when a prompt is not matched in the notes xeft allow to make a new note. I want to use it but it should create new note just like org-roam created new note with the default template , i read the org-roam-node-find function and xeft-filename-fn but i am not expert enough in elisp make it work, would you please help me out on this ?

casouri commented 5 months ago

How does org-roam create a note? I don't use it so I don't really know.

fapdash commented 2 weeks ago

This code works

(defun fap/ignore-errors-advice (orig-fun &rest args)
  (ignore-errors (apply orig-fun args)))

(advice-add 'xeft-create-note :around #'fap/ignore-errors-advice)

(setq xeft-filename-fn (lambda (search-phrase)
                           (org-roam-capture- :node (org-roam-node-create :title search-phrase))))

but xeft will throw an error as the function doesn't return the new filename. Don't know if this fixable as we don't know if the capture will get finalized/saved or discarded. But seems to work fine nonetheless, I was able to find the new file via xeft after finalizing the capture.

casouri commented 2 weeks ago

Ok, in that case you might want to redefine xeft-create-note or add an advice around it.

fapdash commented 2 weeks ago

Updated the code in my earlier comment, @Aneeqasif please have a look. :)