reddit / emacs

Interpreting debug output (maybe related to python-mode, which-key)

wWA5RnA4n2P3w2WvfHq · 2022-02-23 08:57
I am very sorry for that broad question. But I have problems to figuring out which of the components is relevant here. *EDIT*: Please do not waste your time to much here. I answered my question myself (see below). I try to use (Emacs in-build `python` mode) (`"GNU Emacs 27.2 (build 1, x86_64-w64-mingw32)"`) but receive this debug output when opening a `py`\-file. ```Lisp Debugger entered--Lisp error: (void-function which-key-add-key-based-replacements) which-key-add-key-based-replacements("C-l " "lsp" "C-l w" "workspaces" "C-l F" "folders" "C-l =" "formatting" "C-l T" "toggle" "C-l g" "goto" "C-l h" "help" "C-l r" "refactor" "C-l a" "code actions" "C-l G" "peek" "C-l wD" "disconnect" "C-l wd" "describe session" "C-l wq" "shutdown server" "C-l wr" "restart server" "C-l ws" "start server" "C-l ==" "format buffer" "C-l =r" "format region" "C-l Fa" "add folder" "C-l Fb" "un-blacklist folder" "C-l Fr" "remove folder" "C-l TD" "toggle modeline diagnostics" "C-l TL" "toggle log io" "C-l TS" "toggle sideline" "C-l TT" "toggle treemacs integration" "C-l Ta" "toggle modeline code actions" ...) apply(which-key-add-key-based-replacements ("C-l " "lsp" "C-l w" "workspaces" "C-l F" "folders" "C-l =" "formatting" "C-l T" "toggle" "C-l g" "goto" "C-l h" "help" "C-l r" "refactor" "C-l a" "code actions" "C-l G" "peek" "C-l wD" "disconnect" "C-l wd" "describe session" "C-l wq" "shutdown server" "C-l wr" "restart server" "C-l ws" "start server" "C-l ==" "format buffer" "C-l =r" "format region" "C-l Fa" "add folder" "C-l Fb" "un-blacklist folder" "C-l Fr" "remove folder" "C-l TD" "toggle modeline diagnostics" "C-l TL" "toggle log io" "C-l TS" "toggle sideline" "C-l TT" "toggle treemacs integration" "C-l Ta" "toggle modeline code actions" ...)) lsp-enable-which-key-integration(t) (progn (lsp-enable-which-key-integration t) t) (condition-case err (progn (lsp-enable-which-key-integration t) t) ((debug error) (funcall use-package--warning5 :config err))) (closure (t) nil (condition-case err (progn (lsp-enable-which-key-integration t) t) ((debug error) (funcall use-package--warning5 :config err))))() eval-after-load-helper("c:/Users/user/AppData/Roaming/.emacs.d/elpa/lsp-mo...") run-hook-with-args(eval-after-load-helper "c:/Users/user/AppData/Roaming/.emacs.d/elpa/lsp-mo...") do-after-load-evaluation("c:/Users/user/AppData/Roaming/.emacs.d/elpa/lsp-mo...") lsp-deferred() run-hooks(change-major-mode-after-body-hook prog-mode-hook python-mode-hook) apply(run-hooks (change-major-mode-after-body-hook prog-mode-hook python-mode-hook)) run-mode-hooks(python-mode-hook) python-mode() set-auto-mode-0(python-mode nil) set-auto-mode() normal-mode(t) after-find-file(nil t) find-file-noselect-1(#<buffer x.py> "z:/Emacs_on_WINDOWS/x.py" nil nil "z:/Emacs_on_WINDOWS/x.py" (0 2049)) find-file-noselect("z:/Emacs_on_WINDOWS/x.py" nil nil nil) find-file("z:/Emacs_on_WINDOWS/x.py") counsel-find-file-action("z:/Emacs_on_WINDOWS/x.py") ivy-call() ivy-read("Find file: " read-file-name-internal :matcher counsel--find-file-matcher :initial-input nil :action counsel-find-file-action :preselect nil :require-match confirm-after-completion :history file-name-history :keymap (keymap (remap keymap (undo . counsel-find-file-undo)) (67108960 lambda (&optional arg) "nil (`nil')" (interactive "p") (if (string= "" ivy-text) (execute-kbd-macro (kbd "M-o b")) (self-insert-command arg))) (96 . counsel-file-jump-from-find) (C-backspace . counsel-up-directory) (67108991 . counsel-up-directory)) :caller counsel-find-file) counsel--find-file-1("Find file: " nil counsel-find-file-action counsel-find-file) counsel-find-file() funcall-interactively(counsel-find-file) call-interactively(counsel-find-file nil nil) command-execute(counsel-find-file) ``` The `init.el` is that ```lisp ;; -*- lexical-binding: t; -*- (toggle-debug-on-error) ;; === Package setup === (require 'package) (setq package-archives '(("melpa" . "https://melpa.org/packages/") ("org" . "https://orgmode.org/elpa/") ("elpa" . "https://elpa.gnu.org/packages/"))) ;; Initializes the package infrastructure (package-initialize) ;; === use-package == ;; use-package to simplify the config file (unless (package-installed-p 'use-package) (package-refresh-contents) (package-install 'use-package)) (require 'use-package) (setq use-package-always-ensure 't) ;; === Improved search field ; M-o opens "context menu" of a search item (use-package ivy :diminish :bind (("C-s" . swiper)) :config (ivy-mode 1) (setq ivy-use-selectable-prompt t) ) ;; === COUNSEL ; add some extra infos to some minibuffers ; e.g. ivy-rich need it (use-package counsel :bind (("M-x" . counsel-M-x) ("C-x b" . counsel-switch-buffer) ; counsel-ibuffer ("C-x C-f" . counsel-find-file))) ;; === Add docstring column to function search results (use-package ivy-rich :init (ivy-rich-mode 1)) ;; === EVIL (use-package evil :init (setq evil-want-integration t) (setq evil-want-keybinding nil) (setq evil-want-C-i-jump nil) :config (evil-mode 1) ;; Use visual line motions even outside of visual-line-mode buffers (evil-global-set-key 'motion "j" 'evil-next-visual-line) (evil-global-set-key 'motion "k" 'evil-previous-visual-line) ;; Set "normal" vi-mode in specific buffers (evil-set-initial-state 'messages-buffer-mode 'normal) (evil-set-initial-state 'dashboard-mode 'normal) ) (use-package evil-collection :after evil :config (evil-collection-init) ) ; lsp-find-definiton ; lsp-find-reference ; lsp-rename (use-package lsp-mode :commands (lsp lsp-deferred) :init (setq lsp-keymap-prefix "C-l") :config (lsp-enable-which-key-integration t) ) (use-package python-mode :ensure nil :hook (python-mode . lsp-deferred) :custom (python-shell-interpreter "python3") ) ; pip3 install 'python-language-server[all] (use-package company :after lsp-mode :hook (lsp-mode . company-mode) :bind (:map company-active-map ("<tab>" . company-complete-selection)) (:map lsp-mode-map ("<tab>" . company-indent-or-complete-common)) :custom (company-minimum-prefix-length 1) (company-idle-delay 0.0)) (use-package company-box :hook (company-mode . company-box-mode)) ``` I am aware that there is another python mode on elpa which can confuse sometimes. But in that setup I am sure that I use the inbuild Emacs-own python mode because: The `use-package` directive says `:ensure nil`, the file behind `python-mode()` mentioned in the debug output is localized in `c:/Program Files/Emacs/x86_64/share/emacs/27.2/lisp/progmodes/` and the folder `C:\Users\user\AppData\Roaming\.emacs.d\elpa` does not contain anything related to `python`.
wWA5RnA4n2P3w2WvfHq · 2022-02-23 09:02
Ah, I got it myself. Sorry for wasting your time. It was the line `(lsp-enable-which-key-integration t)` The `which-key` package is never loaded. I removed it in the past from that `el` to make it more minimal.