Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Support]: Upgrading built-in Eldoc #236

Open
2 of 3 tasks
ashlineldridge opened this issue Jan 5, 2024 · 10 comments
Open
2 of 3 tasks

[Support]: Upgrading built-in Eldoc #236

ashlineldridge opened this issue Jan 5, 2024 · 10 comments

Comments

@ashlineldridge
Copy link

ashlineldridge commented Jan 5, 2024

Confirmation

  • I have checked the documentation (README, Wiki, docstrings, etc)
  • I am checking these without reading them.
  • I have searched previous issues to see if my question is a duplicate.

Elpaca Version

Elpaca 3fd9def HEAD -> master, origin/master, origin/HEAD
installer: 0.6
emacs-version: GNU Emacs 29.1 (build 2, aarch64-apple-darwin23.2.0, NS appkit-2487.30 Version 14.2.1 (Build 23C71))
of 2024-01-03
git --version: git version 2.43.0

Operating System

macOS Sonoma 14.2.1 (23C71)

Description

Hi,

I'm having difficulty upgrading the built-in Eldoc on Emacs 29.1. I'm using a later version of Eglot from GNU-Devel ELPA that requires Eldoc 1.14.0 (I have version 1.13.0 built-in).

I am unloading Eldoc as described in #192 - i.e.:

(use-package eldoc
  :preface (unload-feature 'eldoc t)
  :init
  (eldoc-add-command "embark-dwim")
  (eldoc-add-command-completions "avy-goto-"))

However, the Eldoc functions aren't loaded and I get errors when my init file subsequently calls functions like eldoc-add-command:

⛔ Error (use-package): corfu/:init: Symbol’s function definition is void: eldoc-add-command
⛔ Error (use-package): eldoc/:init: Symbol’s function definition is void: eldoc-add-command

Following the more complicated build steps approach from #216 produced similar errors.

Appreciate the assistance.

@progfolio
Copy link
Owner

progfolio commented Jan 5, 2024

(use-package eldoc
  :preface (unload-feature 'eldoc t)
  :init
  (eldoc-add-command "embark-dwim")
  (eldoc-add-command-completions "avy-goto-"))

A good way to check out what's happening is to expand the macro via macroexpand or the macrostep-mode package.
The above expands to the following on my system (it may differ slightly on your system depending on the use-package options you have set):

(progn
  (eval-and-compile (unload-feature 'eldoc t))
  (elpaca eldoc
    (eldoc-add-command "embark-dwim")
    (eldoc-add-command-completions "avy-goto-") (require 'eldoc nil nil)))

You can see that use-package's :init forms are evaluated prior to requiring the package.
eldoc-add-command is not autoloaded, which results in the following error:

⛔ Error (use-package): eldoc/:init: Symbol’s function definition is void: eldoc-add-command

use-package's :config keyword should do the trick:

(use-package eldoc
  :preface (unload-feature 'eldoc t)
  :config
  (eldoc-add-command "embark-dwim")
  (eldoc-add-command-completions "avy-goto-"))

;; Expands to:

(progn
  (eval-and-compile (unload-feature 'eldoc t))
  (elpaca eldoc
    (require 'eldoc nil nil) (eldoc-add-command "embark-dwim")
    (eldoc-add-command-completions "avy-goto-") t))

This error:

⛔ Error (use-package): corfu/:init: Symbol’s function definition is void: eldoc-add-command

is a little trickier. It looks like you have corfu declared prior to eldoc in your config, so adding :after (eldoc) to the use-package declaration probably won't work.
The built-in version would be loaded, so corfu would be immediately loaded.
The simplest solution would be to move corfu's entire declaration after the eldoc declaration. e.g.

(use-package eglot ...)
(use-package corfu ...)

Another solution would be to add :after (upgraded-eldoc) to package declarations where you need to use the new eldoc commands. Then add (provide 'upgraded-eldoc) to the end of eldoc's :config. e.g.

(use-package corfu
  :after   (upgraded-eldoc)
  :config  (eldoc-add-command ...))

(use-package or-like-this
  :config 
  (with-eval-after-load 'upgraded-eldoc
    (eldoc-add-command ...)))

(use-package eldoc
  :preface (unload-feature 'eldoc t)
  :config
  (provide 'upgraded-eldoc))

I believe that should work, but I haven't tested it.

Does that help?

@progfolio progfolio changed the title [Bug/Support]: Trouble upgrading built-in Eldoc [Support]: Upgrading built-in Eldoc Jan 5, 2024
@ashlineldridge
Copy link
Author

Thanks for the reply.

Yes, I used :init in my example as that's how I was configuring the built-in Eldoc, but I have tried many different variations of use-package configuration including using :config, manually specifying :commands and :autoload entries for the eldoc-* commands, moving the use-package form for Eldoc to the beginning of my init, not using use-package at all and instead using the elpaca macro, etc. All of my approaches have produced similar errors related to void symbol definitions.

If I strip my init config right back to just having Elpaca and Eldoc installed using the following configuration:

(use-package eldoc
  :preface (unload-feature 'eldoc t)
  :config
  (eldoc-add-command "embark-dwim")
  (eldoc-add-command-completions "avy-goto-"))

I get the following error:

Debugger entered--Lisp error: (void-function global-eldoc-mode)
  global-eldoc-mode(1)
  custom-set-minor-mode(global-eldoc-mode t)
  custom-initialize-reset(global-eldoc-mode (funcall #'#f(compiled-function () #<bytecode 0x19800016fe5d4>)))
  custom-initialize-delay(global-eldoc-mode (funcall #'#f(compiled-function () #<bytecode 0x19800016fe5d4>)))
  custom-declare-variable(global-eldoc-mode (funcall #'#f(compiled-function () #<bytecode 0x19800016fe5d4>)) "Non-nil if Global Eldoc mode is enabled.\nSee the `..." :set custom-set-minor-mode :initialize custom-initialize-delay :type boolean)
  byte-code("\300\301!\210\302\303\304\305\306DD\307\310\311\312\313\314\315&\11\207" [make-variable-buffer-local eldoc-mode-major-mode custom-declare-variable global-eldoc-mode funcall function #f(compiled-function () #<bytecode 0x19800016fe5d4>) "Non-nil if Global Eldoc mode is enabled.\nSee the `..." :set custom-set-minor-mode :initialize custom-initialize-delay :type boolean] 10)
  require(eldoc nil t)
  (not (require 'eldoc nil t))
  (if (not (require 'eldoc nil t)) (display-warning 'use-package (format "Cannot load %s" 'eldoc) :error) (condition-case-unless-debug err (progn (eldoc-add-command "embark-dwim") (eldoc-add-command-completions "avy-goto-") t) (error (funcall use-package--warning0 :config err))))
  (condition-case err (if (not (require 'eldoc nil t)) (display-warning 'use-package (format "Cannot load %s" 'eldoc) :error) (condition-case-unless-debug err (progn (eldoc-add-command "embark-dwim") (eldoc-add-command-completions "avy-goto-") t) (error (funcall use-package--warning0 :config err)))) ((debug error) (funcall use-package--warning0 :catch err)))
  (condition-case-unless-debug err (if (not (require 'eldoc nil t)) (display-warning 'use-package (format "Cannot load %s" 'eldoc) :error) (condition-case-unless-debug err (progn (eldoc-add-command "embark-dwim") (eldoc-add-command-completions "avy-goto-") t) (error (funcall use-package--warning0 :config err)))) (error (funcall use-package--warning0 :catch err)))
  (progn (defvar use-package--warning0 #'(lambda (keyword err) (let ((msg (format "%s/%s: %s" ... keyword ...))) (display-warning 'use-package msg :error)))) (condition-case-unless-debug err (if (not (require 'eldoc nil t)) (display-warning 'use-package (format "Cannot load %s" 'eldoc) :error) (condition-case-unless-debug err (progn (eldoc-add-command "embark-dwim") (eldoc-add-command-completions "avy-goto-") t) (error (funcall use-package--warning0 :config err)))) (error (funcall use-package--warning0 :catch err))))
  eval((progn (defvar use-package--warning0 #'(lambda (keyword err) (let ((msg ...)) (display-warning 'use-package msg :error)))) (condition-case-unless-debug err (if (not (require 'eldoc nil t)) (display-warning 'use-package (format "Cannot load %s" 'eldoc) :error) (condition-case-unless-debug err (progn (eldoc-add-command "embark-dwim") (eldoc-add-command-completions "avy-goto-") t) (error (funcall use-package--warning0 :config err)))) (error (funcall use-package--warning0 :catch err)))) t)
  elpaca--finalize-queue((elpaca-q init 1 1 complete (26008 26162 578921 0) ((let ((load-file-name "/Users/ae/.config/emacs/var/elpaca/builds/eldoc/el...") (load-in-progress t)) (condition-case err (progn (defvar eldoc-minor-mode-string (purecopy " ElDoc") "String to display in mode line when ElDoc Mode is ...") (custom-autoload 'eldoc-minor-mode-string "eldoc" t) (autoload 'eldoc-mode "eldoc" "Toggle echo area display of Lisp objects at point ..." t) (put 'global-eldoc-mode 'globalized-minor-mode t) (defcustom global-eldoc-mode t "Non-nil if Global Eldoc mode is enabled.\nSee the `..." :set #'custom-set-minor-mode :initialize 'custom-initialize-delay :type 'boolean) (custom-autoload 'global-eldoc-mode "eldoc" nil) (autoload 'global-eldoc-mode "eldoc" "Toggle Eldoc mode in all buffers.\nWith prefix ARG,..." t) (autoload 'turn-on-eldoc-mode "eldoc" "Turn on `eldoc-mode' if the buffer has ElDoc suppo...") (register-definition-prefixes "eldoc" '...) (provide 'eldoc-autoloads)) ((error) (warn "Error loading %S autoloads: %S" "eldoc" err))))) ((eldoc (defvar use-package--warning0 #'(lambda (keyword err) (let ... ...))) (condition-case-unless-debug err (if (not (require ... nil t)) (display-warning 'use-package (format "Cannot load %s" ...) :error) (condition-case-unless-debug err (progn ... ... t) (error ...))) (error (funcall use-package--warning0 :catch err))))) ((eldoc elpaca eldoc "eldoc" eldoc (finished activation info unblocked queued) "/Users/ae/.config/emacs/var/elpaca/repos/eldoc/" "/Users/ae/.config/emacs/var/elpaca/builds/eldoc" nil "/Users/ae/.config/emacs/var/elpaca/repos/eldoc/lis..." nil nil (:package "eldoc" :repo "https://github.com/emacs-mirror/emacs" :local-repo "eldoc" :branch "master" :files ("lisp/emacs-lisp/eldoc.el" (:exclude ".git")) :source "GNU-devel ELPA" :protocol https :inherit t :depth 1) nil nil ((emacs "26.3")) nil 1 (26008 26162 632042 0) init nil ((finished (26008 26162 675643 0) "✓ 0.043 secs" 0) (activation (26008 26162 675630 0) "Continued by: elpaca--activate-package" 2) (activation (26008 26162 675625 0) "Autoloads cached" 0) (activation (26008 26162 675146 0) "Caching autoloads" 0) (activation (26008 26162 675137 0) "Package build dir added to load-path" 0) (activation (26008 26162 675101 0) "Activating package" 0) (info (26008 26162 675097 0) "Continued by: elpaca--add-info-path" 2) (info (26008 26162 675092 0) "No Info dir file found" 0) (unblocked (26008 26162 674454 0) "No external dependencies" 0) (queued (26008 26162 674445 0) "Continued by: elpaca--queue-dependencies" 2) (queued (26008 26162 633168 0) "Continued by: elpaca--process" 2) (queued (26008 26162 632044 0) "Package queued" 1)) t))))
  elpaca--finalize((elpaca eldoc "eldoc" eldoc (finished activation info unblocked queued) "/Users/ae/.config/emacs/var/elpaca/repos/eldoc/" "/Users/ae/.config/emacs/var/elpaca/builds/eldoc" nil "/Users/ae/.config/emacs/var/elpaca/repos/eldoc/lis..." nil nil (:package "eldoc" :repo "https://github.com/emacs-mirror/emacs" :local-repo "eldoc" :branch "master" :files ("lisp/emacs-lisp/eldoc.el" (:exclude ".git")) :source "GNU-devel ELPA" :protocol https :inherit t :depth 1) nil nil ((emacs "26.3")) nil 1 (26008 26162 632042 0) init nil ((finished (26008 26162 675643 0) "✓ 0.043 secs" 0) (activation (26008 26162 675630 0) "Continued by: elpaca--activate-package" 2) (activation (26008 26162 675625 0) "Autoloads cached" 0) (activation (26008 26162 675146 0) "Caching autoloads" 0) (activation (26008 26162 675137 0) "Package build dir added to load-path" 0) (activation (26008 26162 675101 0) "Activating package" 0) (info (26008 26162 675097 0) "Continued by: elpaca--add-info-path" 2) (info (26008 26162 675092 0) "No Info dir file found" 0) (unblocked (26008 26162 674454 0) "No external dependencies" 0) (queued (26008 26162 674445 0) "Continued by: elpaca--queue-dependencies" 2) (queued (26008 26162 633168 0) "Continued by: elpaca--process" 2) (queued (26008 26162 632044 0) "Package queued" 1)) t))
  elpaca--continue-build((elpaca eldoc "eldoc" eldoc (finished activation info unblocked queued) "/Users/ae/.config/emacs/var/elpaca/repos/eldoc/" "/Users/ae/.config/emacs/var/elpaca/builds/eldoc" nil "/Users/ae/.config/emacs/var/elpaca/repos/eldoc/lis..." nil nil (:package "eldoc" :repo "https://github.com/emacs-mirror/emacs" :local-repo "eldoc" :branch "master" :files ("lisp/emacs-lisp/eldoc.el" (:exclude ".git")) :source "GNU-devel ELPA" :protocol https :inherit t :depth 1) nil nil ((emacs "26.3")) nil 1 (26008 26162 632042 0) init nil ((finished (26008 26162 675643 0) "✓ 0.043 secs" 0) (activation (26008 26162 675630 0) "Continued by: elpaca--activate-package" 2) (activation (26008 26162 675625 0) "Autoloads cached" 0) (activation (26008 26162 675146 0) "Caching autoloads" 0) (activation (26008 26162 675137 0) "Package build dir added to load-path" 0) (activation (26008 26162 675101 0) "Activating package" 0) (info (26008 26162 675097 0) "Continued by: elpaca--add-info-path" 2) (info (26008 26162 675092 0) "No Info dir file found" 0) (unblocked (26008 26162 674454 0) "No external dependencies" 0) (queued (26008 26162 674445 0) "Continued by: elpaca--queue-dependencies" 2) (queued (26008 26162 633168 0) "Continued by: elpaca--process" 2) (queued (26008 26162 632044 0) "Package queued" 1)) t))
  elpaca--activate-package((elpaca eldoc "eldoc" eldoc (finished activation info unblocked queued) "/Users/ae/.config/emacs/var/elpaca/repos/eldoc/" "/Users/ae/.config/emacs/var/elpaca/builds/eldoc" nil "/Users/ae/.config/emacs/var/elpaca/repos/eldoc/lis..." nil nil (:package "eldoc" :repo "https://github.com/emacs-mirror/emacs" :local-repo "eldoc" :branch "master" :files ("lisp/emacs-lisp/eldoc.el" (:exclude ".git")) :source "GNU-devel ELPA" :protocol https :inherit t :depth 1) nil nil ((emacs "26.3")) nil 1 (26008 26162 632042 0) init nil ((finished (26008 26162 675643 0) "✓ 0.043 secs" 0) (activation (26008 26162 675630 0) "Continued by: elpaca--activate-package" 2) (activation (26008 26162 675625 0) "Autoloads cached" 0) (activation (26008 26162 675146 0) "Caching autoloads" 0) (activation (26008 26162 675137 0) "Package build dir added to load-path" 0) (activation (26008 26162 675101 0) "Activating package" 0) (info (26008 26162 675097 0) "Continued by: elpaca--add-info-path" 2) (info (26008 26162 675092 0) "No Info dir file found" 0) (unblocked (26008 26162 674454 0) "No external dependencies" 0) (queued (26008 26162 674445 0) "Continued by: elpaca--queue-dependencies" 2) (queued (26008 26162 633168 0) "Continued by: elpaca--process" 2) (queued (26008 26162 632044 0) "Package queued" 1)) t))
  elpaca--continue-build((elpaca eldoc "eldoc" eldoc (finished activation info unblocked queued) "/Users/ae/.config/emacs/var/elpaca/repos/eldoc/" "/Users/ae/.config/emacs/var/elpaca/builds/eldoc" nil "/Users/ae/.config/emacs/var/elpaca/repos/eldoc/lis..." nil nil (:package "eldoc" :repo "https://github.com/emacs-mirror/emacs" :local-repo "eldoc" :branch "master" :files ("lisp/emacs-lisp/eldoc.el" (:exclude ".git")) :source "GNU-devel ELPA" :protocol https :inherit t :depth 1) nil nil ((emacs "26.3")) nil 1 (26008 26162 632042 0) init nil ((finished (26008 26162 675643 0) "✓ 0.043 secs" 0) (activation (26008 26162 675630 0) "Continued by: elpaca--activate-package" 2) (activation (26008 26162 675625 0) "Autoloads cached" 0) (activation (26008 26162 675146 0) "Caching autoloads" 0) (activation (26008 26162 675137 0) "Package build dir added to load-path" 0) (activation (26008 26162 675101 0) "Activating package" 0) (info (26008 26162 675097 0) "Continued by: elpaca--add-info-path" 2) (info (26008 26162 675092 0) "No Info dir file found" 0) (unblocked (26008 26162 674454 0) "No external dependencies" 0) (queued (26008 26162 674445 0) "Continued by: elpaca--queue-dependencies" 2) (queued (26008 26162 633168 0) "Continued by: elpaca--process" 2) (queued (26008 26162 632044 0) "Package queued" 1)) t))
  elpaca--add-info-path((elpaca eldoc "eldoc" eldoc (finished activation info unblocked queued) "/Users/ae/.config/emacs/var/elpaca/repos/eldoc/" "/Users/ae/.config/emacs/var/elpaca/builds/eldoc" nil "/Users/ae/.config/emacs/var/elpaca/repos/eldoc/lis..." nil nil (:package "eldoc" :repo "https://github.com/emacs-mirror/emacs" :local-repo "eldoc" :branch "master" :files ("lisp/emacs-lisp/eldoc.el" (:exclude ".git")) :source "GNU-devel ELPA" :protocol https :inherit t :depth 1) nil nil ((emacs "26.3")) nil 1 (26008 26162 632042 0) init nil ((finished (26008 26162 675643 0) "✓ 0.043 secs" 0) (activation (26008 26162 675630 0) "Continued by: elpaca--activate-package" 2) (activation (26008 26162 675625 0) "Autoloads cached" 0) (activation (26008 26162 675146 0) "Caching autoloads" 0) (activation (26008 26162 675137 0) "Package build dir added to load-path" 0) (activation (26008 26162 675101 0) "Activating package" 0) (info (26008 26162 675097 0) "Continued by: elpaca--add-info-path" 2) (info (26008 26162 675092 0) "No Info dir file found" 0) (unblocked (26008 26162 674454 0) "No external dependencies" 0) (queued (26008 26162 674445 0) "Continued by: elpaca--queue-dependencies" 2) (queued (26008 26162 633168 0) "Continued by: elpaca--process" 2) (queued (26008 26162 632044 0) "Package queued" 1)) t))
  elpaca--continue-build((elpaca eldoc "eldoc" eldoc (finished activation info unblocked queued) "/Users/ae/.config/emacs/var/elpaca/repos/eldoc/" "/Users/ae/.config/emacs/var/elpaca/builds/eldoc" nil "/Users/ae/.config/emacs/var/elpaca/repos/eldoc/lis..." nil nil (:package "eldoc" :repo "https://github.com/emacs-mirror/emacs" :local-repo "eldoc" :branch "master" :files ("lisp/emacs-lisp/eldoc.el" (:exclude ".git")) :source "GNU-devel ELPA" :protocol https :inherit t :depth 1) nil nil ((emacs "26.3")) nil 1 (26008 26162 632042 0) init nil ((finished (26008 26162 675643 0) "✓ 0.043 secs" 0) (activation (26008 26162 675630 0) "Continued by: elpaca--activate-package" 2) (activation (26008 26162 675625 0) "Autoloads cached" 0) (activation (26008 26162 675146 0) "Caching autoloads" 0) (activation (26008 26162 675137 0) "Package build dir added to load-path" 0) (activation (26008 26162 675101 0) "Activating package" 0) (info (26008 26162 675097 0) "Continued by: elpaca--add-info-path" 2) (info (26008 26162 675092 0) "No Info dir file found" 0) (unblocked (26008 26162 674454 0) "No external dependencies" 0) (queued (26008 26162 674445 0) "Continued by: elpaca--queue-dependencies" 2) (queued (26008 26162 633168 0) "Continued by: elpaca--process" 2) (queued (26008 26162 632044 0) "Package queued" 1)) t) "No external dependencies" unblocked)
  elpaca--queue-dependencies((elpaca eldoc "eldoc" eldoc (finished activation info unblocked queued) "/Users/ae/.config/emacs/var/elpaca/repos/eldoc/" "/Users/ae/.config/emacs/var/elpaca/builds/eldoc" nil "/Users/ae/.config/emacs/var/elpaca/repos/eldoc/lis..." nil nil (:package "eldoc" :repo "https://github.com/emacs-mirror/emacs" :local-repo "eldoc" :branch "master" :files ("lisp/emacs-lisp/eldoc.el" (:exclude ".git")) :source "GNU-devel ELPA" :protocol https :inherit t :depth 1) nil nil ((emacs "26.3")) nil 1 (26008 26162 632042 0) init nil ((finished (26008 26162 675643 0) "✓ 0.043 secs" 0) (activation (26008 26162 675630 0) "Continued by: elpaca--activate-package" 2) (activation (26008 26162 675625 0) "Autoloads cached" 0) (activation (26008 26162 675146 0) "Caching autoloads" 0) (activation (26008 26162 675137 0) "Package build dir added to load-path" 0) (activation (26008 26162 675101 0) "Activating package" 0) (info (26008 26162 675097 0) "Continued by: elpaca--add-info-path" 2) (info (26008 26162 675092 0) "No Info dir file found" 0) (unblocked (26008 26162 674454 0) "No external dependencies" 0) (queued (26008 26162 674445 0) "Continued by: elpaca--queue-dependencies" 2) (queued (26008 26162 633168 0) "Continued by: elpaca--process" 2) (queued (26008 26162 632044 0) "Package queued" 1)) t))
  elpaca--continue-build((elpaca eldoc "eldoc" eldoc (finished activation info unblocked queued) "/Users/ae/.config/emacs/var/elpaca/repos/eldoc/" "/Users/ae/.config/emacs/var/elpaca/builds/eldoc" nil "/Users/ae/.config/emacs/var/elpaca/repos/eldoc/lis..." nil nil (:package "eldoc" :repo "https://github.com/emacs-mirror/emacs" :local-repo "eldoc" :branch "master" :files ("lisp/emacs-lisp/eldoc.el" (:exclude ".git")) :source "GNU-devel ELPA" :protocol https :inherit t :depth 1) nil nil ((emacs "26.3")) nil 1 (26008 26162 632042 0) init nil ((finished (26008 26162 675643 0) "✓ 0.043 secs" 0) (activation (26008 26162 675630 0) "Continued by: elpaca--activate-package" 2) (activation (26008 26162 675625 0) "Autoloads cached" 0) (activation (26008 26162 675146 0) "Caching autoloads" 0) (activation (26008 26162 675137 0) "Package build dir added to load-path" 0) (activation (26008 26162 675101 0) "Activating package" 0) (info (26008 26162 675097 0) "Continued by: elpaca--add-info-path" 2) (info (26008 26162 675092 0) "No Info dir file found" 0) (unblocked (26008 26162 674454 0) "No external dependencies" 0) (queued (26008 26162 674445 0) "Continued by: elpaca--queue-dependencies" 2) (queued (26008 26162 633168 0) "Continued by: elpaca--process" 2) (queued (26008 26162 632044 0) "Package queued" 1)) t))
  elpaca--process((elpaca eldoc "eldoc" eldoc (finished activation info unblocked queued) "/Users/ae/.config/emacs/var/elpaca/repos/eldoc/" "/Users/ae/.config/emacs/var/elpaca/builds/eldoc" nil "/Users/ae/.config/emacs/var/elpaca/repos/eldoc/lis..." nil nil (:package "eldoc" :repo "https://github.com/emacs-mirror/emacs" :local-repo "eldoc" :branch "master" :files ("lisp/emacs-lisp/eldoc.el" (:exclude ".git")) :source "GNU-devel ELPA" :protocol https :inherit t :depth 1) nil nil ((emacs "26.3")) nil 1 (26008 26162 632042 0) init nil ((finished (26008 26162 675643 0) "✓ 0.043 secs" 0) (activation (26008 26162 675630 0) "Continued by: elpaca--activate-package" 2) (activation (26008 26162 675625 0) "Autoloads cached" 0) (activation (26008 26162 675146 0) "Caching autoloads" 0) (activation (26008 26162 675137 0) "Package build dir added to load-path" 0) (activation (26008 26162 675101 0) "Activating package" 0) (info (26008 26162 675097 0) "Continued by: elpaca--add-info-path" 2) (info (26008 26162 675092 0) "No Info dir file found" 0) (unblocked (26008 26162 674454 0) "No external dependencies" 0) (queued (26008 26162 674445 0) "Continued by: elpaca--queue-dependencies" 2) (queued (26008 26162 633168 0) "Continued by: elpaca--process" 2) (queued (26008 26162 632044 0) "Package queued" 1)) t))
  mapc(elpaca--process ((elpaca eldoc "eldoc" eldoc (finished activation info unblocked queued) "/Users/ae/.config/emacs/var/elpaca/repos/eldoc/" "/Users/ae/.config/emacs/var/elpaca/builds/eldoc" nil "/Users/ae/.config/emacs/var/elpaca/repos/eldoc/lis..." nil nil (:package "eldoc" :repo "https://github.com/emacs-mirror/emacs" :local-repo "eldoc" :branch "master" :files ("lisp/emacs-lisp/eldoc.el" (:exclude ".git")) :source "GNU-devel ELPA" :protocol https :inherit t :depth 1) nil nil ((emacs "26.3")) nil 1 (26008 26162 632042 0) init nil ((finished (26008 26162 675643 0) "✓ 0.043 secs" 0) (activation (26008 26162 675630 0) "Continued by: elpaca--activate-package" 2) (activation (26008 26162 675625 0) "Autoloads cached" 0) (activation (26008 26162 675146 0) "Caching autoloads" 0) (activation (26008 26162 675137 0) "Package build dir added to load-path" 0) (activation (26008 26162 675101 0) "Activating package" 0) (info (26008 26162 675097 0) "Continued by: elpaca--add-info-path" 2) (info (26008 26162 675092 0) "No Info dir file found" 0) (unblocked (26008 26162 674454 0) "No external dependencies" 0) (queued (26008 26162 674445 0) "Continued by: elpaca--queue-dependencies" 2) (queued (26008 26162 633168 0) "Continued by: elpaca--process" 2) (queued (26008 26162 632044 0) "Package queued" 1)) t)))
  elpaca--process-queue((elpaca-q init 1 1 complete (26008 26162 578921 0) ((let ((load-file-name "/Users/ae/.config/emacs/var/elpaca/builds/eldoc/el...") (load-in-progress t)) (condition-case err (progn (defvar eldoc-minor-mode-string (purecopy " ElDoc") "String to display in mode line when ElDoc Mode is ...") (custom-autoload 'eldoc-minor-mode-string "eldoc" t) (autoload 'eldoc-mode "eldoc" "Toggle echo area display of Lisp objects at point ..." t) (put 'global-eldoc-mode 'globalized-minor-mode t) (defcustom global-eldoc-mode t "Non-nil if Global Eldoc mode is enabled.\nSee the `..." :set #'custom-set-minor-mode :initialize 'custom-initialize-delay :type 'boolean) (custom-autoload 'global-eldoc-mode "eldoc" nil) (autoload 'global-eldoc-mode "eldoc" "Toggle Eldoc mode in all buffers.\nWith prefix ARG,..." t) (autoload 'turn-on-eldoc-mode "eldoc" "Turn on `eldoc-mode' if the buffer has ElDoc suppo...") (register-definition-prefixes "eldoc" '...) (provide 'eldoc-autoloads)) ((error) (warn "Error loading %S autoloads: %S" "eldoc" err))))) ((eldoc (defvar use-package--warning0 #'(lambda (keyword err) (let ... ...))) (condition-case-unless-debug err (if (not (require ... nil t)) (display-warning 'use-package (format "Cannot load %s" ...) :error) (condition-case-unless-debug err (progn ... ... t) (error ...))) (error (funcall use-package--warning0 :catch err))))) ((eldoc elpaca eldoc "eldoc" eldoc (finished activation info unblocked queued) "/Users/ae/.config/emacs/var/elpaca/repos/eldoc/" "/Users/ae/.config/emacs/var/elpaca/builds/eldoc" nil "/Users/ae/.config/emacs/var/elpaca/repos/eldoc/lis..." nil nil (:package "eldoc" :repo "https://github.com/emacs-mirror/emacs" :local-repo "eldoc" :branch "master" :files ("lisp/emacs-lisp/eldoc.el" (:exclude ".git")) :source "GNU-devel ELPA" :protocol https :inherit t :depth 1) nil nil ((emacs "26.3")) nil 1 (26008 26162 632042 0) init nil ((finished (26008 26162 675643 0) "✓ 0.043 secs" 0) (activation (26008 26162 675630 0) "Continued by: elpaca--activate-package" 2) (activation (26008 26162 675625 0) "Autoloads cached" 0) (activation (26008 26162 675146 0) "Caching autoloads" 0) (activation (26008 26162 675137 0) "Package build dir added to load-path" 0) (activation (26008 26162 675101 0) "Activating package" 0) (info (26008 26162 675097 0) "Continued by: elpaca--add-info-path" 2) (info (26008 26162 675092 0) "No Info dir file found" 0) (unblocked (26008 26162 674454 0) "No external dependencies" 0) (queued (26008 26162 674445 0) "Continued by: elpaca--queue-dependencies" 2) (queued (26008 26162 633168 0) "Continued by: elpaca--process" 2) (queued (26008 26162 632044 0) "Package queued" 1)) t))))
  elpaca-process-queues()
  run-hooks(after-init-hook delayed-warnings-hook)
  command-line()
  normal-top-level()

If I use the elpaca macro like so:

(when (featurep 'eldoc)
  (unload-feature 'eldoc t))
(elpaca eldoc)
(elpaca-wait)

;; I have also tried using the build steps approach recommended
;; for seq and it produces the same error:
;; (defun my/elpaca-unload-eldoc (e)
;;   (and (featurep 'eldoc) (unload-feature 'eldoc t))
;;   (elpaca--continue-build e))
;;
;; (defun my/elpaca-eldoc-build-steps ()
;;   (append (butlast (if (file-exists-p (expand-file-name "eldoc" elpaca-builds-directory))
;;                        elpaca--pre-built-steps elpaca-build-steps))
;;           (list #'my/elpaca-unload-eldoc #'elpaca--activate-package)))
;;
;; (elpaca `(eldoc :build ,(my/elpaca-eldoc-build-steps)))

Then I get a warning about the missing global-eldoc-mode but no stacktrace:

⛔ Warning (emacs): Error loading "eldoc" autoloads: (void-function global-eldoc-mode)

I have had many use-package-lifecycle errors that related to :init/:config/:preface, etc, but this seems different.

If I evaluate the value of load-path after the errors above, the build directory for Eldoc is at the head of the list ("/Users/ae/.config/emacs/var/elpaca/builds/eldoc").

I think the Corfu error has the same cause (i.e. global-eldoc-mode is not properly autoloaded) so I've removed it for the time being to simplify the error.

@ashlineldridge
Copy link
Author

The eldoc-autoloads.el file that gets generated from eldoc.el is:

;;; eldoc-autoloads.el --- automatically extracted autoloads (do not edit)   -*- lexical-binding: t -*-
;; Generated by the `loaddefs-generate' function.

;; This file is part of GNU Emacs.

;;; Code:



;;; Generated autoloads from eldoc.el

(defvar eldoc-minor-mode-string (purecopy " ElDoc") "\
String to display in mode line when ElDoc Mode is enabled; nil for none.")
(custom-autoload 'eldoc-minor-mode-string "eldoc" t)
(autoload 'eldoc-mode "eldoc" "\
Toggle echo area display of Lisp objects at point (ElDoc mode).

ElDoc mode is a buffer-local minor mode.  When enabled, the echo
area displays information about a function or variable in the
text where point is.  If point is on a documented variable, it
displays the first line of that variable's doc string.  Otherwise
it displays the argument list of the function called in the
expression point is on.

This is a minor mode.  If called interactively, toggle the `Eldoc
mode' mode.  If the prefix argument is positive, enable the mode,
and if it is zero or negative, disable the mode.

If called from Lisp, toggle the mode if ARG is `toggle'.  Enable
the mode if ARG is nil, omitted, or is a positive number.
Disable the mode if ARG is a negative number.

To check whether the minor mode is enabled in the current buffer,
evaluate `eldoc-mode'.

The mode's hook is called both when the mode is enabled and when
it is disabled.

(fn &optional ARG)" t)
(put 'global-eldoc-mode 'globalized-minor-mode t)
(defcustom global-eldoc-mode t "\
Non-nil if Global Eldoc mode is enabled.
See the `global-eldoc-mode' command
for a description of this minor mode.
Setting this variable directly does not take effect;
either customize it (see the info node `Easy Customization')
or call the function `global-eldoc-mode'." :set #'custom-set-minor-mode :initialize 'custom-initialize-delay :type 'boolean)
(custom-autoload 'global-eldoc-mode "eldoc" nil)
(autoload 'global-eldoc-mode "eldoc" "\
Toggle Eldoc mode in all buffers.
With prefix ARG, enable Global Eldoc mode if ARG is positive;
otherwise, disable it.

If called from Lisp, toggle the mode if ARG is `toggle'.
Enable the mode if ARG is nil, omitted, or is a positive number.
Disable the mode if ARG is a negative number.

Eldoc mode is enabled in all buffers where `turn-on-eldoc-mode' would
do it.

See `eldoc-mode' for more information on Eldoc mode.

(fn &optional ARG)" t)
(autoload 'turn-on-eldoc-mode "eldoc" "\
Turn on `eldoc-mode' if the buffer has ElDoc support enabled.
See `eldoc-documentation-strategy' for more detail.")
(register-definition-prefixes "eldoc" '("eldoc"))

;;; End of scraped data

(provide 'eldoc-autoloads)

;; Local Variables:
;; version-control: never
;; no-byte-compile: t
;; no-update-autoloads: t
;; no-native-compile: t
;; coding: utf-8-emacs-unix
;; End:

;;; eldoc-autoloads.el ends here

@progfolio
Copy link
Owner

Thanks for all the info.
Nothing looks obviously wrong with the generated autoloads.
I'm able to reproduce as well.
I'll take a look into this and get back to you when I figure out what's going on.

@progfolio
Copy link
Owner

progfolio commented Jan 6, 2024

Digging into this more.

  custom-set-minor-mode(global-eldoc-mode t)
  custom-initialize-reset(global-eldoc-mode (funcall #'#f(compiled-function () #<bytecode 0x19800016fe5d4>)))
  custom-initialize-delay(global-eldoc-mode (funcall #'#f(compiled-function () #<bytecode 0x19800016fe5d4>)))

I get a similar error when manually evaluating the autoloads.
It looks like preloaded elisp packages like eldoc are treated specially in custom-initialize-delay.
Here's a rough workaround I've found so far:

(elpaca-test
  :interactive t
  :early-init 
  (setq elpaca-menu-functions '(elpaca-menu-gnu-devel-elpa))
  :init
  (unload-feature 'eldoc t) ;; Unload built-in eldoc

  ;; Workaround custom.el initialization for global-eldoc-mode.
  ;; Not sure about setting this globally.
  ;; Might want to move it into a custom build step which
  ;; replaces `elpaca--activate-package` for eldoc.
  (setq custom-delayed-init-variables '())
  (defvar global-eldoc-mode nil)

  (defun +test-command () (interactive) (message "PASS"))
  (elpaca eldoc
    (require 'eldoc)
    (global-eldoc-mode) ;; This is usually enabled by default by Emacs
    (eldoc-add-command "+test-command")))

or with use-package support enabled:

(elpaca-test
  :interactive t
  :early-init
  (setq elpaca-menu-functions '(elpaca-menu-extensions elpaca-menu-gnu-devel-elpa))
  :init

  (elpaca elpaca-use-package
    (elpaca-use-package-mode)
    (setq elpaca-use-package-by-default t))
  (elpaca-wait)

  (use-package eldoc
    :preface
    (unload-feature 'eldoc t)
    (setq custom-delayed-init-variables '())
    (defvar global-eldoc-mode nil)
    :config
    (global-eldoc-mode)))

I'll keep investigating.

@ashlineldridge
Copy link
Author

I appreciate you looking into this. I think Elpaca will really benefit from presenting a cohesive interface for managing/upgrading both built-in and third-party packages. The workaround works great for now and allows me to re-enable version checking for Eglot (as the latest Eldoc is now being pulled) 👍🏽

@meliache
Copy link

meliache commented Mar 14, 2024

Had the same issue when I needed to update eldoc to use the latest eglot. I always got the warning

⛔ Warning (emacs): eldoc loaded before Elpaca activation

For some reason the use-package version of the workaround doesn't fully work for me, I still get the same above warning. But the pure (elpaca ...) version does work. I included two minimal init files to reproduce the warning of the use-package version below. For testing I just put them in a directory and launch emacs with --init-directory=<test-directory>, and the warning appears. I use Emacs 29.2 with PGTK and Native compilation on Linux.

init.el
;; init.el --- Initialization file  -*- lexical-binding: t; no-byte-compile: t; -*-
(defvar elpaca-installer-version 0.7)
(defvar elpaca-directory (expand-file-name "elpaca/" user-emacs-directory))
(defvar elpaca-builds-directory (expand-file-name "builds/" elpaca-directory))
(defvar elpaca-repos-directory (expand-file-name "repos/" elpaca-directory))
(defvar elpaca-order '(elpaca :repo "https://github.com/progfolio/elpaca.git"
                              :ref nil :depth 1
                              :files (:defaults "elpaca-test.el" (:exclude "extensions"))
                              :build (:not elpaca--activate-package)))
(let* ((repo  (expand-file-name "elpaca/" elpaca-repos-directory))
       (build (expand-file-name "elpaca/" elpaca-builds-directory))
       (order (cdr elpaca-order))
       (default-directory repo))
  (add-to-list 'load-path (if (file-exists-p build) build repo))
  (unless (file-exists-p repo)
    (make-directory repo t)
    (when (< emacs-major-version 28) (require 'subr-x))
    (condition-case-unless-debug err
        (if-let ((buffer (pop-to-buffer-same-window "*elpaca-bootstrap*"))
                 ((zerop (apply #'call-process `("git" nil ,buffer t "clone"
                                                 ,@(when-let ((depth (plist-get order :depth)))
                                                     (list (format "--depth=%d" depth) "--no-single-branch"))
                                                 ,(plist-get order :repo) ,repo))))
                 ((zerop (call-process "git" nil buffer t "checkout"
                                       (or (plist-get order :ref) "--"))))
                 (emacs (concat invocation-directory invocation-name))
                 ((zerop (call-process emacs nil buffer nil "-Q" "-L" "." "--batch"
                                       "--eval" "(byte-recompile-directory \".\" 0 'force)")))
                 ((require 'elpaca))
                 ((elpaca-generate-autoloads "elpaca" repo)))
            (progn (message "%s" (buffer-string)) (kill-buffer buffer))
          (error "%s" (with-current-buffer buffer (buffer-string))))
      ((error) (warn "%s" err) (delete-directory repo 'recursive))))
  (unless (require 'elpaca-autoloads nil t)
    (require 'elpaca)
    (elpaca-generate-autoloads "elpaca" repo)
    (load "./elpaca-autoloads")))
(add-hook 'after-init-hook #'elpaca-process-queues)
(elpaca `(,@elpaca-order))

;; Install elpaca use-package support
(elpaca elpaca-use-package
  ;; Enable elpaca use-package integration
  (elpaca-use-package-mode)
  ;; Assume :ensure t unless otherwise specified.
  (setopt elpaca-use-package-by-default t))

;; wait to get elpaca use-package integration
(elpaca-wait)

(use-package eldoc
  :preface
  ;; avoid loading of built-in eldoc, see https://github.com/progfolio/elpaca/issues/236#issuecomment-1879838229
  (unload-feature 'eldoc t)
  (setq custom-delayed-init-variables '())
  (defvar global-eldoc-mode nil)
  :demand t
  :config
  (global-eldoc-mode))

(elpaca-wait)
early-init.el
(setq package-enable-at-startup nil)
(setq elpaca-menu-functions '(elpaca-menu-extensions elpaca-menu-gnu-devel-elpa))

@tomaskrehlik
Copy link

Same for me, the use-package workaround keeps showing the Warning. I am on MacOS, built from master as of 2023-12-02.

@valignatev
Copy link

Just checking in, use-package workaround doesn't work for me either

@progfolio
Copy link
Owner

Just checking in, use-package workaround doesn't work for me either

Please refrain from "+1" type comments. They send an email to everyone subscribed to the issue. A thumbs up on the comment works just as well without doing so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants