mclear-tools / consult-notes

Use consult to search notes
GNU General Public License v3.0
163 stars 15 forks source link

`apply: Opening input file: No such file or directory, ` after deleting note #33

Closed JonatanSahar closed 1 year ago

JonatanSahar commented 1 year ago

after deleting a note (possibly it was the last note opened through constult-notes) I get apply: Opening input file: No such file or directory, c:/Users/Jonathan/notes/20230409T130534--presentations-prep__bib_finance.org

and no completion pops up.

JonatanSahar commented 1 year ago

this is the backtrace:

Debugger entered--Lisp error: (file-missing "Opening input file" "No such file or directory" "c:/Users/Jonathan/notes/20230402T113618--בדיקה-1.o...")

("c:/Users/Jonathan/notes/20230402T113618--בדיקה-1.o...")

apply(# "c:/Users/Jonathan/notes/20230402T113618--בדיקה-1.o..." nil) editorconfig--advice-insert-file-contents(# "c:/Users/Jonathan/notes/20230402T113618--בדיקה-1.o...") apply(editorconfig--advice-insert-file-contents # "c:/Users/Jonathan/notes/20230402T113618--בדיקה-1.o...") insert-file-contents("c:/Users/Jonathan/notes/20230402T113618--בדיקה-1.o...") denote-retrieve-title-value("c:/Users/Jonathan/notes/20230402T113618--בדיקה-1.o..." org)

f(compiled-function (f) #<bytecode -0x6f653e75574f16d>)("c:/Users/Jonathan/notes/20230402T113618--בדיקה-1.o...")

mapcar(#f(compiled-function (f) #<bytecode -0x6f653e75574f16d>) ("c:/Users/Jonathan/notes/20230323T111555--paper-sum..." "c:/Users/Jonathan/notes/20230323T113003--knowledge..." "c:/Users/Jonathan/notes/20230323T113249--action-mo..." "c:/Users/Jonathan/notes/20230323T113609--action-mo..." "c:/Users/Jonathan/notes/20230323T113638--action-se..." "c:/Users/Jonathan/notes/20230329T113432--stronger-..." "c:/Users/Jonathan/notes/20230329T121953--enhanced-..." "c:/Users/Jonathan/notes/20230329T135029--advantage..." "c:/Users/Jonathan/notes/20230329T155402--literatur..." "c:/Users/Jonathan/notes/20230331T070538--איך-לבחור..." "c:/Users/Jonathan/notes/20230331T070738--volumef..." "c:/Users/Jonathan/notes/20230331T070907--דוח-רווח-..." "c:/Users/Jonathan/notes/20230331T070938--מאזןfin..." "c:/Users/Jonathan/notes/20230331T071217--אופציות-ו..." "c:/Users/Jonathan/notes/20230331T160233--מחירן-של-..." "c:/Users/Jonathan/notes/20230331T160545--זה-קריטי-..." "c:/Users/Jonathan/notes/20230331T161033--איך-להשקי..." "c:/Users/Jonathan/notes/20230331T161601--שאלות-לאמ..." "c:/Users/Jonathan/notes/20230402T104912--lateraliz..." "c:/Users/Jonathan/notes/20230402T112858--efference..." "c:/Users/Jonathan/notes/20230402T113618--בדיקה-1.o..." "c:/Users/Jonathan/notes/20230402T113631--בדיקה-2.o..." "c:/Users/Jonathan/notes/20230402T133604--interesti..." "c:/Users/Jonathan/notes/20230402T133604--interesti..." "c:/Users/Jonathan/notes/20230403T121950--a-preacti..." "c:/Users/Jonathan/notes/20230403T122319--voluntary..." "c:/Users/Jonathan/notes/20230404T122908--עמלות__fi..." "c:/Users/Jonathan/notes/20230404T225329--conversat..." "c:/Users/Jonathan/notes/20230406T101834--straddle-..." "c:/Users/Jonathan/notes/20230406T180738--butterfly..." "c:/Users/Jonathan/notes/20230406T180738--butterfly..." "c:/Users/Jonathan/notes/20230406T220331--מחיר-האופ..." "c:/Users/Jonathan/notes/20230406T223625--intrinsic..." "c:/Users/Jonathan/notes/20230406T224959--time-deca..." "c:/Users/Jonathan/notes/20230406T224959--time-deca..." "c:/Users/Jonathan/notes/20230409T093744--thesis-ex..." "c:/Users/Jonathan/notes/20230409T102750--how-to-re..." "c:/Users/Jonathan/notes/20230409T102947--thesis-id..." "c:/Users/Jonathan/notes/20230409T130534--presentat..."))

f(compiled-function () #<bytecode -0x1bc4dd8e4a018571>)()

f(compiled-function (src) #<bytecode 0x178745b86fc74c51>)((:name #("Denote notes" 0 12 (face consult-notes-sep)) :narrow 100 :category consult-notes-category :annotate consult-notes-denote--annotate :items #f(compiled-function () #<bytecode -0x1bc4dd8e4a018571>) :state consult-notes-denote--state :new consult-notes-denote--new-note))

mapc(#f(compiled-function (src) #<bytecode 0x178745b86fc74c51>) [(:name #("Denote notes" 0 12 (face consult-notes-sep)) :narrow 100 :category consult-notes-category :annotate consult-notes-denote--annotate :items #f(compiled-function () #<bytecode -0x1bc4dd8e4a018571>) :state consult-notes-denote--state :new consult-notes-denote--new-note)]) seq-do(#f(compiled-function (src) #<bytecode 0x178745b86fc74c51>) [(:name #("Denote notes" 0 12 (face consult-notes-sep)) :narrow 100 :category consult-notes-category :annotate consult-notes-denote--annotate :items #f(compiled-function () #<bytecode -0x1bc4dd8e4a018571>) :state consult-notes-denote--state :new consult-notes-denote--new-note)]) consult--multi-candidates([(:name #("Denote notes" 0 12 (face consult-notes-sep)) :narrow 100 :category consult-notes-category :annotate consult-notes-denote--annotate :items #f(compiled-function () #<bytecode -0x1bc4dd8e4a018571>) :state consult-notes-denote--state :new consult-notes-denote--new-note)]) consult--multi((consult-notes-denote--source) :require-match nil :prompt "Notes: " :history consult-notes-history) consult-notes() funcall-interactively(consult-notes) command-execute(consult-notes record)

(nil "consult-notes" #("cons note" 0 9 (ws-butler-chg chg)))

ad-Advice-execute-extended-command(# nil "consult-notes" #("cons note" 0 9 (ws-butler-chg chg))) apply(ad-Advice-execute-extended-command # (nil "consult-notes" #("cons note" 0 9 (ws-butler-chg chg)))) execute-extended-command(nil "consult-notes" #("cons note" 0 9 (ws-butler-chg chg))) funcall-interactively(execute-extended-command nil "consult-notes" #("cons note" 0 9 (ws-butler-chg chg))) command-execute(execute-extended-command)

JonatanSahar commented 1 year ago

this happens even on a brand new install, after deleting a file from the denote dir, without ever calling consult-notes

mclearc commented 1 year ago

If you're not calling consult-notes, then perhaps this is a problem with your setup of denote? The error message suggests it is calling an error because it doesn't think the directory exists. But it also looks like you're using windows, and that may bring with it its own set of problems (unfortunately I can't help there as I don't use windows).

JonatanSahar commented 1 year ago

I am using windows, unfortunately.. I have denote set up like in the manual suggests, and I don't have any problems of this particular kind with it. Why do you think it's a problem with directory? it's complaining about a specific file. Why is consult-notes even looking for a deleted file? Does it use any caching mechanisms? Is it looking at the history of any other function's output or anything?

On Mon, Apr 17, 2023, 15:18 Colin McLear @.***> wrote:

If you're not calling consult-notes, then perhaps this is a problem with your setup of denote? The error message suggests it is calling an error because it doesn't think the directory exists. But it also looks like you're using windows, and that may bring with it its own set of problems (unfortunately I can't help there as I don't use windows).

— Reply to this email directly, view it on GitHub https://github.com/mclear-tools/consult-notes/issues/33#issuecomment-1511233765, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEL3S3FW7P5C6VCGOEC5A5TXBUYITANCNFSM6AAAAAAWYBFLJA . You are receiving this because you authored the thread.Message ID: @.***>

mclearc commented 1 year ago

There’s no caching. The generic consult-notes function is just (directory-files) so I’m not sure what is going on. __Colin McLearcolinmclear.netOn Apr 17, 2023, at 9:24 AM, Jonathan Sahar @.***> wrote: I am using windows, unfortunately.. I have denote set up like in the manual suggests, and I don't have any problems of this particular kind with it. Why is consult-notes even looking for a deleted file? Does it use any caching mechanisms? Is it looking at the history of any other function's output or anything?

On Mon, Apr 17, 2023, 15:18 Colin McLear @.***> wrote:

If you're not calling consult-notes, then perhaps this is a problem with your setup of denote? The error message suggests it is calling an error because it doesn't think the directory exists. But it also looks like you're using windows, and that may bring with it its own set of problems (unfortunately I can't help there as I don't use windows).

— Reply to this email directly, view it on GitHub https://github.com/mclear-tools/consult-notes/issues/33#issuecomment-1511233765, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEL3S3FW7P5C6VCGOEC5A5TXBUYITANCNFSM6AAAAAAWYBFLJA . You are receiving this because you authored the thread.Message ID: @.***>

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: @.***>

JonatanSahar commented 1 year ago

ok, I just found something strange: the value of consult-notes-denote-files-function is set to a list of files names from the note directory:

consult-notes-denote-files-function is a variable defined in consult-notes-denote.el.

Value ("c:/Users/Jonathan/notes/images/20230406T180738--butterfly-spread-optionsfinance.org_20230406_191527_dCpXJh.png" "c:/Users/Jonathan/notes/images/20230406T224959--time-decay-options__finance.org_20230406_232034_kGSAPz.png" "c:/Users/Jonathan/notes/images/20230409T130534--presentations-prepthesis.org_20230412_104736_eItKLw.png" "c:/Users/Jonathan/notes/images/20230409T130534--presentations-prepthesis.org_20230412_104815_wJRqB8.png" "c:/Users/Jonathan/notes/images/20230409T130534--presentations-prep__thesis.org_20230412_104904_jmaYjO.png" "c:/Users/Jonathan/notes/20230323T111555--paper-summaries-from-guythesis.org" "c:/Users/Jonathan/notes/20230323T113003--knowledge-basethesis.org" "c:/Users/Jonathan/notes/20230323T113249--action-modulates-perceptionthesis.org" "c:/Users/Jonathan/notes/20230323T113609--action-modulates-preparatory-sensory-neural-activitythesis.org" "c:/Users/Jonathan/notes/20230323T113638--action-sensory-modulation-is-learning-basedthesis.org" "c:/Users/Jonathan/notes/20230329T113432--stronger-modulation-in-ipsilateral-configurationthesis.org" "c:/Users/Jonathan/notes/20230329T121953--enhanced-auditory-evoked-activity-to-self-generated-sounds-reznik-et-albib_thesis.org" "c:/Users/Jonathan/notes/20230329T135029--advantage-in-contralateral-configurationthesis.org" "c:/Users/Jonathan/notes/20230329T155402--literature-review-draftthesis.org" "c:/Users/Jonathan/notes/20230331T070538--איך-לבחור-מניותfinance.org" "c:/Users/Jonathan/notes/20230331T070738--volumefinance.org" "c:/Users/Jonathan/notes/20230331T070907--דוח-רווח-והפסדfinance.org" "c:/Users/Jonathan/notes/20230331T070938--מאזןfinance.org" "c:/Users/Jonathan/notes/20230331T071217--אופציות-ונילהfinance.org" "c:/Users/Jonathan/notes/20230331T160233--מחירן-של-אופציות-הוא-תנודתי-יותר-ממחיר-נכס-הבסיסfinance.org" "c:/Users/Jonathan/notes/20230331T160545--זה-קריטי-לא-להיות-חמדנים-בהשקעותfinance.org" "c:/Users/Jonathan/notes/20230331T161033--איך-להשקיע-באופציות-בלי-להוציא-כסףfinance.org" "c:/Users/Jonathan/notes/20230331T161601--שאלות-לאמירfinance.org" "c:/Users/Jonathan/notes/20230402T104912--lateralized-enhancement-of-auditory-cortex-activity-rezink-mukamel-et-albib_thesis.org" "c:/Users/Jonathan/notes/20230402T112858--efference-copythesis.org" "c:/Users/Jonathan/notes/20230402T133604--interesting-papersthesis.org" "c:/Users/Jonathan/notes/20230403T121950--a-preactivation-account-of-sensory-attenuation-roussel-et-albib_thesis.org" "c:/Users/Jonathan/notes/20230403T122319--voluntary-actions-modulate-perception-buaron-et-al__bib_thesis.org" "c:/Users/Jonathan/notes/20230404T122908--עמלותfinance.org" "c:/Users/Jonathan/notes/20230404T225329--conversations-with-chatgpt.org" "c:/Users/Jonathan/notes/20230406T101834--straddle-optionsfinance.org" "c:/Users/Jonathan/notes/20230406T180738--butterfly-spread-optionsfinance.org" "c:/Users/Jonathan/notes/20230406T220331--מחיר-האופציה-בכל-נק-זמן-מגלם-את-הרווח-שבמימושהfinance.org" "c:/Users/Jonathan/notes/20230406T223625--intrinsic-vs-extrinsic-value-optionsfinance.org" "c:/Users/Jonathan/notes/20230406T224959--time-decay-optionsfinance.org" "c:/Users/Jonathan/notes/20230409T093744--thesis-experiment-planningthesis.org" "c:/Users/Jonathan/notes/20230409T102750--how-to-read-papersthesis.org" "c:/Users/Jonathan/notes/20230409T102947--thesis-ideas-and-thoughtsthesis.org" "c:/Users/Jonathan/notes/20230409T130534--presentations-prepthesis.org" "c:/Users/Jonathan/notes/20230410T144059--forward-modelthesis.org" "c:/Users/Jonathan/notes/20230411T171156--david-schneiderthesis.org" "c:/Users/Jonathan/notes/20230414T182859--analaysis-logthesis.org" "c:/Users/Jonathan/notes/20230414T183424--analysis-logthesis.org" "c:/Users/Jonathan/notes/20230416T101541--action-sharpens-sensory-representations-of-expected-outcomes-yon-press-et-albib_thesis.org")

Original Value ("c:/Users/Jonathan/notes/images/20230406T180738--butterfly-spread-optionsfinance.org_20230406_191527_dCpXJh.png" "c:/Users/Jonathan/notes/images/20230406T224959--time-decay-options__finance.org_20230406_232034_kGSAPz.png" "c:/Users/Jonathan/notes/images/20230409T130534--presentations-prepthesis.org_20230412_104736_eItKLw.png" "c:/Users/Jonathan/notes/images/20230409T130534--presentations-prepthesis.org_20230412_104815_wJRqB8.png" "c:/Users/Jonathan/notes/images/20230409T130534--presentations-prep__thesis.org_20230412_104904_jmaYjO.png" "c:/Users/Jonathan/notes/20230323T111555--paper-summaries-from-guythesis.org" "c:/Users/Jonathan/notes/20230323T113003--knowledge-basethesis.org" "c:/Users/Jonathan/notes/20230323T113249--action-modulates-perceptionthesis.org" "c:/Users/Jonathan/notes/20230323T113609--action-modulates-preparatory-sensory-neural-activitythesis.org" "c:/Users/Jonathan/notes/20230323T113638--action-sensory-modulation-is-learning-basedthesis.org" "c:/Users/Jonathan/notes/20230329T113432--stronger-modulation-in-ipsilateral-configurationthesis.org" "c:/Users/Jonathan/notes/20230329T121953--enhanced-auditory-evoked-activity-to-self-generated-sounds-reznik-et-albib_thesis.org" "c:/Users/Jonathan/notes/20230329T135029--advantage-in-contralateral-configurationthesis.org" "c:/Users/Jonathan/notes/20230329T155402--literature-review-draftthesis.org" "c:/Users/Jonathan/notes/20230331T070538--איך-לבחור-מניותfinance.org" "c:/Users/Jonathan/notes/20230331T070738--volumefinance.org" "c:/Users/Jonathan/notes/20230331T070907--דוח-רווח-והפסדfinance.org" "c:/Users/Jonathan/notes/20230331T070938--מאזןfinance.org" "c:/Users/Jonathan/notes/20230331T071217--אופציות-ונילהfinance.org" "c:/Users/Jonathan/notes/20230331T160233--מחירן-של-אופציות-הוא-תנודתי-יותר-ממחיר-נכס-הבסיסfinance.org" "c:/Users/Jonathan/notes/20230331T160545--זה-קריטי-לא-להיות-חמדנים-בהשקעותfinance.org" "c:/Users/Jonathan/notes/20230331T161033--איך-להשקיע-באופציות-בלי-להוציא-כסףfinance.org" "c:/Users/Jonathan/notes/20230331T161601--שאלות-לאמירfinance.org" "c:/Users/Jonathan/notes/20230402T104912--lateralized-enhancement-of-auditory-cortex-activity-rezink-mukamel-et-albib_thesis.org" "c:/Users/Jonathan/notes/20230402T112858--efference-copythesis.org" "c:/Users/Jonathan/notes/20230402T133604--interesting-papersthesis.org" "c:/Users/Jonathan/notes/20230403T122319--voluntary-actions-modulate-perception-buaron-et-albib_thesis.org" "c:/Users/Jonathan/notes/20230404T122908--עמלותfinance.org" "c:/Users/Jonathan/notes/20230404T225329--conversations-with-chatgpt.org" "c:/Users/Jonathan/notes/20230406T101834--straddle-optionsfinance.org" "c:/Users/Jonathan/notes/20230406T180738--butterfly-spread-optionsfinance.org" "c:/Users/Jonathan/notes/20230406T220331--מחיר-האופציה-בכל-נק-זמן-מגלם-את-הרווח-שבמימושהfinance.org" "c:/Users/Jonathan/notes/20230406T223625--intrinsic-vs-extrinsic-value-optionsfinance.org" "c:/Users/Jonathan/notes/20230406T224959--time-decay-optionsfinance.org" "c:/Users/Jonathan/notes/20230409T093744--thesis-experiment-planningthesis.org" "c:/Users/Jonathan/notes/20230409T102750--how-to-read-papersthesis.org" "c:/Users/Jonathan/notes/20230409T102947--thesis-ideas-and-thoughtsthesis.org" "c:/Users/Jonathan/notes/20230409T130534--presentations-prepthesis.org" "c:/Users/Jonathan/notes/20230410T144059--forward-modelthesis.org" "c:/Users/Jonathan/notes/20230411T171156--david-schneiderthesis.org" "c:/Users/Jonathan/notes/20230414T183424--analysis-logthesis.org" "c:/Users/Jonathan/notes/20230416T101541--action-sharpens-sensory-representations-of-expected-outcomes-yon-press-et-albib_thesis.org" "c:/Users/Jonathan/notes/20230416T164124--a-preactivation-account-of-sensory-attenuation-roussel-2013bib_thesis.org" "c:/Users/Jonathan/notes/20230416T213823--the-auditory-brain-in-action-intention-determines-predictive-processing-in-the-auditory-system-korka-2022bib_review_thesis.org" "c:/Users/Jonathan/notes/20230417T154407--misc-knowledge-basethesis.org")

I have no idea how it gets set to this value, but the "original value" is also the same. What is it supposed to be?

JonatanSahar commented 1 year ago

hmm, it looks it's set up this way on purpose?

(defcustom consult-notes-denote-files-function (denote-directory-files)
  "Fuction for listing denote files. If only text files are wanted use `denote-directory-text-only-files' instead."
  :group 'consult-notes
  :type 'function)

denote-directory-files returns a list of files

mclearc commented 1 year ago

Yes this is just how denote works. __Colin McLearcolinmclear.netOn Apr 17, 2023, at 9:39 AM, Jonathan Sahar @.***> wrote: hmm, it looks it's set up this way on purpose? (defcustom consult-notes-denote-files-function (denote-directory-files) "Fuction for listing denote files. If only text files are wanted use `denote-directory-text-only-files' instead." :group 'consult-notes :type 'function)

denote-directory-files returns a list of files

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: @.***>

JonatanSahar commented 1 year ago

I see, and it re-populats the list, calling denote-directory-files every time the function is called? if it doesn't refresh for some reason, then it makes sense it will fail looking for a file that's in the list but not on disk anymore, or something like that..

I just noticed that on my setup it doesn't recognize new note files, so I suspect it's not refreshing for some reason. Do you any idea how that could be?

JonatanSahar commented 1 year ago

(I neglected to say that denot-open-or-create works well in all respects)

mclearc commented 1 year ago

Could you provide your setup for both denote and consult-notes?

JonatanSahar commented 1 year ago

sure :)

(use-package! denote
  :config
  ;; Remember to check the doc strings of those variables.
  (setq denote-directory (expand-file-name "~/notes/"))
  (setq denote-known-keywords '("emacs" "philosophy" "politics" "economics"))
  (setq denote-infer-keywords t)
  (setq denote-sort-keywords t)
  (setq denote-file-type nil) ; Org is the default, set others here
  (setq denote-prompts '(title keywords))
  (setq denote-excluded-directories-regexp nil)
  (setq denote-excluded-keywords-regexp nil)

  ;; Pick dates, where relevant, with Org's advanced interface:
  (setq denote-date-prompt-use-org-read-date t)

  ;; Read this manual for how to specify `denote-templates'.  We do not
  ;; include an example here to avoid potential confusion.

  ;; We allow multi-word keywords by default.  The author's personal
  ;; preference is for single-word keywords for a more rigid workflow.
  (setq denote-allow-multi-word-keywords t)

  (setq denote-date-format nil) ; read doc string

  ;; By default, we do not show the context of links.  We just display
  ;; file names.  This provides a more informative view.
  (setq denote-backlinks-show-context t)

  ;; Also see `denote-link-backlinks-display-buffer-action' which is a bit
  ;; advanced.

  ;; If you use Markdown or plain text files (Org renders links as buttons
  ;; right away)
  (add-hook 'find-file-hook #'denote-link-buttonize-buffer)

  ;; We use different ways to specify a path for demo purposes.
  (setq denote-dired-directories
        (list denote-directory
              (thread-last denote-directory (expand-file-name "attachments"))
              (expand-file-name "~/Documents/books")))

  ;; Generic (great if you rename files Denote-style in lots of places):
  ;; (add-hook 'dired-mode-hook #'denote-dired-mode)
  ;;
  ;; OR if only want it in `denote-dired-directories':
  (add-hook 'dired-mode-hook #'denote-dired-mode-in-directories)

  ;; Here is a custom, user-level command from one of the examples we
  ;; showed in this manual.  We define it here and add it to a key binding
  ;; below.
  (defun my-denote-journal ()
    "Create an entry tagged 'journal', while prompting for a title."
    (interactive)
    (denote
     (denote--title-prompt)
     '("journal")))

  ;; Denote DOES NOT define any key bindings.  This is for the user to
  ;; decide.  For example:

  (with-eval-after-load 'org-capture
    (setq denote-org-capture-specifiers "%l\n%i\n%?")
    (add-to-list 'org-capture-templates
                 '("n" "New note (with denote.el)" plain
                   (file denote-last-path)
                   #'denote-org-capture
                   :no-save t
                   :immediate-finish nil
                   :kill-buffer t
                   :jump-to-captured t)))

  ;; Also check the commands `denote-link-after-creating',
  ;; `denote-link-or-create'.  You may want to bind them to keys as well
  )

(use-package! consult-notes
  :commands (consult-notes
             consult-notes-search-in-all-notes
             ;; if using org-roam
             consult-notes-org-roam-find-node
             consult-notes-org-roam-find-node-relation)
  :init
  (when (locate-library "denote")
    (consult-notes-denote-mode))
  (setq consult-notes-denote-display-id nil)
  (consult-customize consult-notes
                   :preview-key "C-.")
                   ;; '("M-."
                   ;;   :debounce 0.5 "<up>" "<down>"
                   ;;   :debounce 0.5 any))
  )
mclearc commented 1 year ago

Those look fine -- do you have anything non-standard in your consult settings?

JonatanSahar commented 1 year ago

I don't think so..

(after! consult
  (consult-customize
   consult-buffer consult-buffer-other-window consult-ripgrep consult-git-grep consult-grep
   consult-bookmark consult-recent-file consult-xref consult-theme
   ;; consult--source-file consult--source-project-file consult--source-bookmark
   :preview-key "C-.")
  ;; The :init configuration is always executed (Not lazy)
  :init

  ;; Optionally configure the register formatting. This improves the register
  ;; preview for `consult-register', `consult-register-load',
  ;; `consult-register-store' and the Emacs built-ins.
  (setq register-preview-delay 0
        register-preview-function #'consult-register-format)
  ;; Optionally tweak the register preview window.
  ;; This adds thin lines, sorting and hides the mode line of the window.
  (advice-add #'register-preview :override #'consult-register-window)
  (advice-add #'consult-line :around #'jnf/consult-line '((name . "wrapper")))
  (advice-add #'consult-ripgrep :around #'jnf/consult-ripgrep '((name . "wrapper")))

  ;; Use Consult to select xref locations with preview
  (setq xref-show-xrefs-function #'consult-xref
        xref-show-definitions-function #'consult-xref)

  ;; Updating the default to include "--ignore-case"
  (setq consult-ripgrep-command "rg --null --line-buffered --color=ansi --max-columns=1000 --ignore-case --no-heading --line-number . -e ARG OPTS")

  ;; Configure other variables and modes in the :config section,
  ;; after lazily loading the package.

  :config

  ;; Optionally configure the narrowing key.
  ;; Both < and C-+ work reasonably well.
  (setq consult-narrow-key "<") ;; (kbd "C-+")

  (autoload 'projectile-project-root "projectile")
  (setq consult-project-root-function #'projectile-project-root)

  ;; Optionally add the `consult-flycheck' command.
  (use-package! consult-flycheck
    :bind (:map flycheck-command-map
                ("!" . consult-flycheck)))

  (setq consult-project-function (lambda (_) (projectile-project-root)))
  )
JonatanSahar commented 1 year ago

for the moment, I've added

  (setq consult-notes-denote-files-function (denote-directory-text-only-files))

in:

(defun consult-notes (&optional sources)
  "Find a file in a notes directory with consult-multi, or from SOURCES."
  (interactive)
  (setq consult-notes-denote-files-function (denote-directory-text-only-files))
  (consult-notes--make-file-dir-sources)
  (consult--multi (or sources consult-notes-all-sources)
                  :require-match
                  (confirm-nonexistent-file-or-buffer)
                  :prompt "Notes: "
                  :history 'consult-notes-history))

and it seems to work alright, but I gather this is hacky, and is not in fact how it's supposed to work?

michzappa commented 1 year ago

I came here after seeing exactly the same two behaviors:

  1. error for file not found when note gets deleted
  2. new notes not shown

My denote/consult-notes config

(use-package-dependency denote
    :hook (dired-mode-hook . denote-dired-mode)
    :bind (("C-c N n" . denote)
           ("C-c N f" . consult-notes))
    :custom
    (denote-allow-multi-word-keywords t)
    (denote-date-prompt-denote-date-prompt-use-org-read-date t)
    (denote-directory (expand-file-name "denote" org-directory))
    (denote-file-type 'org)
    (denote-prompts '(title keywords))
    :config
    (use-package-dependency consult-notes
      :commands (consult-notes-denote-mode)
      :config
      (consult-notes-denote-mode +1)))

use-package-dependency is just use-package with :demand t.

relict007 commented 1 year ago

I am also facing this issue. My elisp is really bad but I got it working in my fork with this change. Not sure if it breaks something else.

fork/custom 567ce347203c94e518f6a55f99c4210d52d4d660
Author:     relict007 <1025329+relict007@users.noreply.github.com>
AuthorDate: Wed Apr 19 09:03:55 2023 +0530
Commit:     relict007 <1025329+relict007@users.noreply.github.com>
CommitDate: Wed Apr 19 09:03:55 2023 +0530

Parent:     ecebec9 remove directory name
Merged:     custom main
Contained:  custom

make sure that denote-directory-files is called everytime

1 file changed, 2 insertions(+), 2 deletions(-)
consult-notes-denote.el | 4 ++--

modified   consult-notes-denote.el
@@ -49,7 +49,7 @@
   :group 'consult-notes
   :type 'boolean)

-(defcustom consult-notes-denote-files-function (denote-directory-files)
+(defcustom consult-notes-denote-files-function (function denote-directory-files)
   "Fuction for listing denote files. If only text files are wanted use `denote-directory-text-only-files' instead."
   :group 'consult-notes
   :type 'function)
@@ -93,7 +93,7 @@
                                                 (when (> current-width max-width)
                                                   (setq max-width (+ 24 current-width))))
                                               (propertize title 'denote-path f 'denote-keywords keywords)))
-                                          consult-notes-denote-files-function)))
+                                          (funcall consult-notes-denote-files-function))))
                       (mapcar (lambda (c)
                                 (let* ((keywords (get-text-property 0 'denote-keywords c))
                                        (path (get-text-property 0 'denote-path c))
mclearc commented 1 year ago

looks good to me