protesilaos / denote

Simple notes for Emacs with an efficient file-naming scheme
https://protesilaos.com/emacs/denote
GNU General Public License v3.0
545 stars 55 forks source link

error with denote-files-matching-regexp-prompt #406

Closed birchpoplar closed 3 months ago

birchpoplar commented 3 months ago

I'm getting this error when calling denote-org-extras-dblock-insert-links in an org file:

byte-code: Symbol’s function definition is void: denote-files-matching-regexp-prompt

Usually when I get a void function error I find something got out of sync in package updates, but I've gone through a complete rebuild (deleting all under elpa/, straight/ and transient/) to no avail--this is with emacs 29.4. I have another machine with emacs 29.3 and same dotfiles and the function works fine.

Any suggestions on how to fix or where to look next? The function isn't loaded--I get nothing when using C-h, f.

Apologies if I'm mssing something as a generic mis-configuration in emacs, but have gone through some iterations on this and can't solve. The rest of denote works fine as far as I can tell.

debug on error report below:

Debugger entered--Lisp error: (void-function denote-files-matching-regexp-prompt)
  denote-files-matching-regexp-prompt()
  byte-code("\300 C\207" [denote-files-matching-regexp-prompt] 1)
  command-execute(denote-org-extras-dblock-insert-links record)
  counsel-M-x-action("denote-org-extras-dblock-insert-links")
  ivy-call()
  ivy-read("M-x " [org-super-agenda-date-format magit-section-show-headings mu4e-search-hide-predicate eshell-insert-buffer-name tramp-sudoedit-file-name-handler tramp-completion-handle-file-name-all-completions term-do-line-wrapping lsp-watch-kind? docid access-label mu4e-view-header-field-keymap mastodon-search-types org-fold--spec-org-fold-outline-173388499033826220 c-state-min-scan-pos term-handle-exit vterm-keymap-exceptions hs-hide-comments-when-hiding-all rg-file-message ement-room--format-membership-events text2 tramp-compat-string-equal-ignore-case lsp-perlnavigator eshell-return-exits-minibuffer :EndLineNumber 0 c-make-ml-string-opener-re-function smie-config--guess-value biblio-insert-result :where citeproc-blt--parse-date c-list-found-types byte-condition-case tramp-sudoedit-handle-set-file-acl isqrt rg-header-render-toggle WatchKind Above eshell--sep-terms lsp-json-error? racket-font-lock-keywords-0 racket-font-lock-keywords-1 racket-font-lock-keywords-2 racket-font-lock-keywords-3 projectile-unserialize lsp:set-file-operation-pattern-options? lsp-inlay-hint-face core-accessing-symbol angle-bracket-arglist-escape tramp-handle-make-auto-save-file-name :hugo-blackfriday ...] :predicate #f(compiled-function (sym) #<bytecode -0x961fdbea3b066e1>) :require-match t :history counsel-M-x-history :action counsel-M-x-action :keymap (keymap (67108908 . counsel--info-lookup-symbol) (67108910 . counsel-find-symbol)) :initial-input nil :caller counsel-M-x)
  counsel-M-x()
  funcall-interactively(counsel-M-x)
  command-execute(counsel-M-x)

relevant section below from emacs.org:

#+begin_src emacs-lisp 

    ;; Make Elisp files in that directory available to the user.
    (add-to-list 'load-path "~/Packages/denote")

    (require 'denote)
  (require 'denote-sort)

  ;; Remember to check the doc strings of those variables.
  (setq denote-directory (expand-file-name "~/OrgFiles/Denote/"))
  (setq denote-known-keywords '(
                                "kt" "ke" "km" "kr"
                                "kca" "kcd"
                                "krb" "kra"
                                "ply" "plm" "plw" "pld"
                                "pra" "prb" "prc"
                                ))
  (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)

    ;; Sets format of date in front matter to file-type specific format
    (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)

    ;; Automatically rename Denote buffers using the `denote-rename-buffer-format'.
    (denote-rename-buffer-mode 1)

    (with-eval-after-load 'org-capture
      (setq denote-org-capture-specifiers "%l\n%i\n%?"))

    ;; Denote journal configuration
    (require 'denote-journal-extras)

    ;; Specify dedicated journal directory
    (setq denote-journal-extras-directory (expand-file-name "~/OrgFiles/Denote/journal/"))

    ;; Specify date/time format for title
    (setq denote-journal-extras-title-format 'day-date-month-year-24h)

    ;; define function to prompt for date for non-current journal entry
    (defun jw/denote-journal-entry-with-date ()
      (interactive)
      (let ((date (org-read-date)))
        (denote-journal-extras-new-entry date)))

    (jw/leader-keys
      "dj"  'denote-journal-extras-new-entry
      "dd"  'jw/denote-journal-entry-with-date
      "do"  'denote-open-or-create)
protesilaos commented 3 months ago

From: birchpoplar @.***> Date: Sun, 4 Aug 2024 06:13:24 -0700

I'm getting this error when calling denote-org-extras-dblock-insert-links in an org file:

byte-code: Symbol’s function definition is void: denote-files-matching-regexp-prompt

Usually when I get a void function error I find something got out of sync in package updates, but I've gone through a complete rebuild (deleting all under elpa/, straight/ and transient/) to no avail--this is with emacs 29.4. I have another machine with emacs 29.3 and same dotfiles and the function works fine.

It seems that 'denote' is not loaded at that time, which is surprising because 'denote-org-extras' depends on it. Can you evaluate the following and then repeat the test scenario?

(require 'denote)

-- Protesilaos Stavrou https://protesilaos.com

birchpoplar commented 3 months ago

thanks. I get the same even after evaluating (require 'denote):

byte-code: Symbol’s function definition is void: denote-files-matching-regexp-prompt

What I'm doing here is calling org-dynamic-block-insert-dblock and selecting denote-links.

Also, if I put the cursor in an existing dblock header, such as:

#+BEGIN: denote-links :regexp "--germany" :sort-by-component nil :reverse-sort nil :id-only nil

#+END:

I get the following error:

denote-org-extras-dblock--files: Wrong number of arguments: ((t) nil "Return list of absolute file paths in variable `denote-directory'.

Files only need to have an identifier.  The return value may thus
include file types that are not implied by `denote-file-type'.
To limit the return value to text files, use the function
`denote-directory-text-only-files'.

Remember that the variable `denote-directory' accepts a dir-local
value, as explained in its doc string." (mapcar #'expand-file-name (seq-filter #'denote-file-has-identifier-p (denote--directory-all-files-recursively)))), 2
protesilaos commented 3 months ago

From: birchpoplar @.***> Date: Sun, 4 Aug 2024 12:58:54 -0700

thanks. I get the same even after evaluating (require 'denote):

byte-code: Symbol’s function definition is void: denote-files-matching-regexp-prompt

This is surprising! The only explanation I have is that you have old byte compiled files somewhere. Those with ".elc" at the end.

What I'm doing here is calling org-dynamic-block-insert-dblock and selecting denote-links.

This is an issue with autoloading. I can reproduce it with 'emacs -Q' if I do not load any package.

Though none of the problems occur if I start 'emacs -Q' and then evaluate '(package-initialize)'.

-- Protesilaos Stavrou https://protesilaos.com

birchpoplar commented 3 months ago

Thanks for help here. I figured it out and it was--as could be expected--an issue in my init.el. I had an errant 'load-path entry to local denote copy from late last year. Appreciate the help. Now resolved.

protesilaos commented 3 months ago

From: birchpoplar @.***> Date: Mon, 5 Aug 2024 17:17:53 -0700

Thanks for help here. I figured it out and it was--as could be expected--an issue in my init.el. I had an errant 'load-path entry to local denote copy from late last year. Appreciate the help. Now resolved.

Very well!

-- Protesilaos Stavrou https://protesilaos.com