bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#68999: 29.1; `use-package' macro expands to reference to unloaded `p


From: kaction
Subject: bug#68999: 29.1; `use-package' macro expands to reference to unloaded `personal-keybindings'
Date: Fri, 09 Feb 2024 04:11:30 -0500

Hello.

I have the following code in my `init.el' (particular key chord or its
binding is not important):

    (use-package elisp-mode
        :bind (:map emacs-lisp-mode-map
                    ("C-c j" . next-line)))


which expands to the following code that refers to the
`personal-keybindings' variable (caret-highlighted).

  (progn
    (defvar use-package--warning0
      (function
       (lambda
         (keyword err)
         (let
             ((msg
               (format "%s/%s: %s" 'elisp-mode keyword
                       (error-message-string err))))
           (display-warning 'use-package msg :error)))))
    (condition-case err
        (progn
          (if
              (fboundp 'next-line)
              nil
            (autoload
              (function next-line)
              "elisp-mode" nil t))
          (if
              (boundp 'emacs-lisp-mode-map)
              (let*
                  ((name "C-c j")
                   (key
                    (if
                        (vectorp name)
                        name
                      (read-kbd-macro name)))
                   (kmap
                    (or
                     (if
                         (and emacs-lisp-mode-map
                              (symbolp emacs-lisp-mode-map))
                         (symbol-value emacs-lisp-mode-map)
                       emacs-lisp-mode-map)
                     global-map))
                   (kdesc
                    (cons
                     (if
                         (stringp name)
                         name
                       (key-description name))
                     (if
                         (symbolp emacs-lisp-mode-map)
                         emacs-lisp-mode-map 'emacs-lisp-mode-map)))
                   (binding
                    (lookup-key kmap key)))
                (let
                    ((entry
                      (assoc kdesc personal-keybindings))
                                   ^^^^^^^^^^^^^^^^^^^^
                     (details
                      (list
                       (function next-line)
                       (unless
                           (numberp binding)
                         binding))))
                  (if entry
                      (setcdr entry details)
                    (add-to-list 'personal-keybindings
                                 (cons kdesc details))))
                (define-key kmap key
                            (function next-line)))
            (eval-after-load 'elisp-mode
              '(bind-key "C-c j"
                         (function next-line)
                         emacs-lisp-mode-map nil))))
      ((debug error)
       (funcall use-package--warning0 :catch err))))

Note that nothing in this code refers to any autoloaded functions
defined in `bind-key.el', where `defvar' for that variable resides.

That is not an issue when code is interpreted, since `use-package'
requires `bind-key', but when code is compiled, that results in
`void-variable` error.

I ended up adding following line into my `init.el' that I compile:

     (defvar personal-keybindings nil)

but probably more robust solution would be to add `defvar` (or maybe
even `require') into expansion of the `use-package` itself, or
precisely, into `bind-keys` macro it uses.


In GNU Emacs 29.1 (build 1, x86_64-pc-linux-gnu, X toolkit, cairo
version 1.18.0, Xaw3d scroll bars)
Windowing system distributor 'The X.Org Foundation', version 11.0.12101009
System Description: NixOS 23.11 (Tapir)

Configured using:
 'configure
 --prefix=/nix/store/0pzd74q495bbdnyjxcdqmzksv96g3ffk-emacs-29.1
 --disable-build-details --with-modules --with-x-toolkit=athena
 --with-xft --with-cairo --with-native-compilation --with-tree-sitter
 --with-xinput2'

Configured features:
CAIRO FREETYPE GIF GLIB GMP GNUTLS GSETTINGS JPEG JSON LIBOTF LIBXML2
M17N_FLT MODULES NATIVE_COMP NOTIFY INOTIFY PDUMPER PNG RSVG SECCOMP
SOUND SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS TREE_SITTER WEBP X11
XAW3D XDBE XIM XINPUT2 XPM LUCID ZLIB

Important settings:
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

Major mode: ELisp/d

Minor modes in effect:
  global-git-commit-mode: t
  magit-auto-revert-mode: t
  auto-revert-mode: t
  server-mode: t
  company-mode: t
  global-flycheck-mode: t
  flycheck-mode: t
  global-whitespace-mode: t
  global-display-line-numbers-mode: t
  display-line-numbers-mode: t
  direnv-mode: t
  yas-minor-mode: t
  override-global-mode: t
  evil-paredit-mode: t
  paredit-mode: t
  shell-dirtrack-mode: t
  evil-mode: t
  evil-local-mode: t
  windmove-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  show-paren-mode: t
  mouse-wheel-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  column-number-mode: t
  line-number-mode: t
  transient-mark-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  hs-minor-mode: t

Load-path shadows:
/home/kaction/.nix-profile/share/emacs/site-lisp/site-start hides 
/run/current-system/sw/share/emacs/site-lisp/site-start
~/devel/kaction-emacs/macrostep/macrostep hides 
/home/kaction/.emacs.d/elpa/macrostep-0.9.2/macrostep
~/devel/kaction-emacs/macrostep/macrostep-c hides 
/home/kaction/.emacs.d/elpa/macrostep-0.9.2/macrostep-c
/home/kaction/.nix-profile/share/emacs/site-lisp/site-start hides 
/nix/store/0pzd74q495bbdnyjxcdqmzksv96g3ffk-emacs-29.1/share/emacs/site-lisp/site-start
/home/kaction/.emacs.d/elpa/transient-20220325.1619/transient hides 
/nix/store/0pzd74q495bbdnyjxcdqmzksv96g3ffk-emacs-29.1/share/emacs/29.1/lisp/transient
/home/kaction/.emacs.d/elpa/bind-key-20210210.1609/bind-key hides 
/nix/store/0pzd74q495bbdnyjxcdqmzksv96g3ffk-emacs-29.1/share/emacs/29.1/lisp/use-package/bind-key
/home/kaction/.emacs.d/elpa/use-package-20230426.2324/use-package-lint hides 
/nix/store/0pzd74q495bbdnyjxcdqmzksv96g3ffk-emacs-29.1/share/emacs/29.1/lisp/use-package/use-package-lint
/home/kaction/.emacs.d/elpa/use-package-20230426.2324/use-package hides 
/nix/store/0pzd74q495bbdnyjxcdqmzksv96g3ffk-emacs-29.1/share/emacs/29.1/lisp/use-package/use-package
/home/kaction/.emacs.d/elpa/use-package-20230426.2324/use-package-delight hides 
/nix/store/0pzd74q495bbdnyjxcdqmzksv96g3ffk-emacs-29.1/share/emacs/29.1/lisp/use-package/use-package-delight
/home/kaction/.emacs.d/elpa/use-package-20230426.2324/use-package-diminish 
hides 
/nix/store/0pzd74q495bbdnyjxcdqmzksv96g3ffk-emacs-29.1/share/emacs/29.1/lisp/use-package/use-package-diminish
/home/kaction/.emacs.d/elpa/use-package-20230426.2324/use-package-bind-key 
hides 
/nix/store/0pzd74q495bbdnyjxcdqmzksv96g3ffk-emacs-29.1/share/emacs/29.1/lisp/use-package/use-package-bind-key
/home/kaction/.emacs.d/elpa/use-package-20230426.2324/use-package-ensure hides 
/nix/store/0pzd74q495bbdnyjxcdqmzksv96g3ffk-emacs-29.1/share/emacs/29.1/lisp/use-package/use-package-ensure
/home/kaction/.emacs.d/elpa/use-package-20230426.2324/use-package-jump hides 
/nix/store/0pzd74q495bbdnyjxcdqmzksv96g3ffk-emacs-29.1/share/emacs/29.1/lisp/use-package/use-package-jump
/home/kaction/.emacs.d/elpa/use-package-20230426.2324/use-package-core hides 
/nix/store/0pzd74q495bbdnyjxcdqmzksv96g3ffk-emacs-29.1/share/emacs/29.1/lisp/use-package/use-package-core

Features:
(shadow emacsbug quail dabbrev vc-hg vc-bzr vc-src vc-sccs vc-svn vc-cvs
vc-rcs log-view bug-reference vc pulse color magit-extras face-remap
magit-bookmark magit-submodule magit-obsolete magit-blame magit-stash
magit-reflog magit-bisect magit-push magit-pull magit-fetch magit-clone
magit-remote magit-commit magit-sequence magit-notes magit-worktree
magit-tag magit-merge magit-branch magit-reset magit-files magit-refs
magit-status magit magit-repos magit-apply magit-wip magit-log
which-func imenu magit-diff smerge-mode diff git-commit log-edit
pcvs-util add-log magit-core magit-autorevert autorevert magit-margin
magit-transient magit-process with-editor server magit-mode transient
magit-git magit-base magit-section org-element org-persist org-id
org-refile avl-tree oc-basic ol-eww eww xdg url-queue mm-url ol-rmail
ol-mhe ol-irc ol-info ol-gnus nnselect gnus-art mm-uu mml2015 gnus-sum
shr pixel-fill kinsoku url-file svg dom gnus-group gnus-undo gnus-start
gnus-dbus dbus xml gnus-cloud nnimap nnmail mail-source utf7 nnoo
parse-time gnus-spec gnus-int gnus-range gnus-win gnus nnheader range
ol-docview doc-view filenotify jka-compr image-mode exif ol-bibtex
bibtex iso8601 ol-bbdb ol-w3m ol-doi org-link-doi org ob ob-tangle
ob-ref ob-lob ob-table ob-exp org-macro org-src ob-comint org-pcomplete
org-list org-footnote org-faces org-entities noutline outline
ob-emacs-lisp ob-core ob-eval org-cycle org-table ol org-fold
org-fold-core org-keys oc org-loaddefs org-version org-compat org-macs
bookmark qp textsec uni-scripts idna-mapping ucs-normalize
uni-confusable textsec-check sort mail-extr help-fns radix-tree
mm-archive mule-util misearch multi-isearch vc-git vc-dispatcher sql
view pcmpl-unix em-unix em-term term ehelp em-script em-prompt em-ls
em-hist em-pred em-glob em-extpipe em-cmpl em-dirs esh-var em-basic
em-banner em-alias esh-mode eshell esh-cmd esh-ext esh-opt esh-proc
esh-io esh-arg esh-module esh-groups esh-util files-x company-oddmuse
company-keywords company-etags etags fileloop generator xref project
company-gtags company-dabbrev-code company-dabbrev company-files
company-clang company-capf company-cmake company-semantic
company-template company-bbdb company hideshow flycheck find-func
disp-table whitespace display-line-numbers alect-black-alt-theme
alect-themes direnv dash config notmuch notmuch-tree notmuch-jump
notmuch-hello notmuch-show notmuch-print notmuch-crypto notmuch-mua
notmuch-message notmuch-draft notmuch-maildir-fcc notmuch-address
notmuch-company notmuch-parser format-spec notmuch-wash diff-mode coolj
goto-addr icalendar diary-lib diary-loaddefs cal-menu calendar
cal-loaddefs notmuch-tag crm notmuch-lib notmuch-compat pcase hl-line
message sendmail yank-media dired dired-loaddefs rfc822 mml mailabbrev
mail-utils gmm-utils mailheader mm-view mml-smime mml-sec epa derived
epg rfc6068 epg-config gnus-util time-date smime gnutls puny dig
mm-decode mm-bodies mm-encode mail-parse rfc2231 rfc2047 rfc2045 mm-util
ietf-drums mail-prsvr gemini-mode time-stamp haskell-snippets
yasnippet-snippets yasnippet use-package-bind-key bind-key evil-paredit
paredit macrostep easy-mmode evil evil-keybindings evil-integration
evil-maps evil-commands reveal flyspell ispell evil-jumps
evil-command-window evil-search evil-ex shell pcomplete evil-types
evil-macros evil-repeat evil-states evil-core comp comp-cstr warnings rx
cl-extra help-mode advice evil-common windmove calc calc-loaddefs
calc-macs thingatpt rect evil-digraphs evil-vars edmacro kmacro
use-package-ensure use-package-core cus-edit pp cus-load icons wid-edit
compile text-property-search comint ansi-osc ansi-color ring
abyss-theme-autoloads adwaita-dark-theme-autoloads
blackboard-theme-autoloads direnv-autoloads evil-collection-autoloads
annalist-autoloads evil-org-autoloads evil-paredit-autoloads
execline-autoloads gemtext-mode-autoloads macrostep-autoloads
neotree-autoloads notmuch-autoloads orgit-autoloads compat-autoloads
pytest-autoloads todotxt-autoloads use-package-autoloads
vi-tilde-fringe-autoloads w3m-load info yaml-mode-autoloads package
browse-url url url-proxy url-privacy url-expand url-methods url-history
url-cookie generate-lisp-file url-domsuf url-util mailcap url-handlers
url-parse auth-source cl-seq eieio eieio-core cl-macs password-cache
json subr-x map byte-opt gv bytecomp byte-compile url-vars cl-loaddefs
cl-lib rmc iso-transl tooltip cconv eldoc paren electric uniquify
ediff-hook vc-hooks lisp-float-type elisp-mode mwheel term/x-win x-win
term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe
tabulated-list replace newcomment text-mode lisp-mode prog-mode register
page tab-bar menu-bar rfn-eshadow isearch easymenu timer select
scroll-bar mouse jit-lock font-lock syntax font-core term/tty-colors
frame minibuffer nadvice seq simple cl-generic indonesian philippine
cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao
korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech
european ethiopic indian cyrillic chinese composite emoji-zwj charscript
charprop case-table epa-hook jka-cmpr-hook help abbrev obarray oclosure
cl-preloaded button loaddefs theme-loaddefs faces cus-face macroexp
files window text-properties overlay sha1 md5 base64 format env
code-pages mule custom widget keymap hashtable-print-readable backquote
threads inotify dynamic-setting system-font-setting font-render-setting
cairo x-toolkit xinput2 x multi-tty make-network-process native-compile
emacs)

Memory information:
((conses 16 788644 79559)
 (symbols 48 40698 44)
 (strings 32 164641 11315)
 (string-bytes 1 6835142)
 (vectors 16 112314)
 (vector-slots 8 2672922 120694)
 (floats 8 564 304)
 (intervals 56 5742 467)
 (buffers 984 70))





reply via email to

[Prev in Thread] Current Thread [Next in Thread]