emacs-evil / evil

The extensible vi layer for Emacs.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`describe-char` doesn't work outside of evail unless `(ad-deactivate #'describe-char)` is evaluated

flexibeast opened this issue · comments

This has been an ongoing issue for a while now, but i've only just got to this item on my to-do list.

Context: Gentoo, Emacs 29.1, evil-20240104.1115.

Trying to calling describe-char outside of evil results in:

Debugger entered--entering a function:
* (evil-local-mode)
  (evil-emacs-state nil)
  (evil-change-state emacs)
  (ad-Advice-describe-char #f(compiled-function (pos &optional buffer) "Describe position POS (interactively, point) and the char after POS.\nPOS is taken to be in BUFFER, or the current buffer if BUFFER is nil.\nThe information is displayed in buffer `*Help*'.\n\nThe position information includes POS; the total size of BUFFER; the\nregion limits, if narrowed; the column number; and the horizontal\nscroll amount, if the buffer is horizontally scrolled.\n\nThe character information includes:\n its codepoint;\n its charset (see `char-charset'), overridden by the `charset' text\n   property at POS, if any;\n the codepoint of the character in the above charset;\n the character's script (as defined by `char-script-table')\n the character's syntax, as produced by `syntax-after'\n   and `internal-describe-syntax-value';\n its category (see `char-category-set' and `describe-char-categories');\n how to input the character using the keyboard and input methods;\n how the character is encoded in BUFFER and in BUFFER's file;\n the font and font glyphs used to display the character;\n the composition information for displaying the character (if relevant);\n the character's canonical name and other properties defined by the\n   Unicode Data Base;\n and widgets, buttons, overlays, and text properties relevant to POS." (interactive "d") #<bytecode 0x1e425497b1fcb023>) 1)
  (apply ad-Advice-describe-char #f(compiled-function (pos &optional buffer) "Describe position POS (interactively, point) and the char after POS.\nPOS is taken to be in BUFFER, or the current buffer if BUFFER is nil.\nThe information is displayed in buffer `*Help*'.\n\nThe position information includes POS; the total size of BUFFER; the\nregion limits, if narrowed; the column number; and the horizontal\nscroll amount, if the buffer is horizontally scrolled.\n\nThe character information includes:\n its codepoint;\n its charset (see `char-charset'), overridden by the `charset' text\n   property at POS, if any;\n the codepoint of the character in the above charset;\n the character's script (as defined by `char-script-table')\n the character's syntax, as produced by `syntax-after'\n   and `internal-describe-syntax-value';\n its category (see `char-category-set' and `describe-char-categories');\n how to input the character using the keyboard and input methods;\n how the character is encoded in BUFFER and in BUFFER's file;\n the font and font glyphs used to display the character;\n the composition information for displaying the character (if relevant);\n the character's canonical name and other properties defined by the\n   Unicode Data Base;\n and widgets, buttons, overlays, and text properties relevant to POS." (interactive "d") #<bytecode 0x1e425497b1fcb023>) 1)
  (describe-char 1)
  (funcall-interactively describe-char 1)
  (call-interactively describe-char record nil)
  (command-execute describe-char record)
  (execute-extended-command nil "describe-char")
  [snip]

i've spent some time trying to work out what's going on, stepping through the related calls in evil-integration.el, without success. The only way i've found to deal with this problem is to evaluate:

(ad-deactivate #'describe-char)

after which describe-char works without issues.

Thanks for the bug report @flexibeast . Could you provide some repro instructions? Specifically in a make emacs session (check out evil's Makefile for more details) if possible. Evil isn't easy to get "outside" of once activated, so want to make sure I'm doing the same thing you're doing when trying to repro.

.... dang. It works in the Emacs instance opened via make emacs. (And 224/225 tests passed, with one skipped: evil-test-jump-buffers).

i'm actually not surprised; i've suspected the issue is something specific to my setup, as it's the sort of thing that other users would probably be reporting otherwise. But i've not had any good ideas about how to approach this. i have ~180 packages installed, and my config is a literate Org file that, once tangled, is nearly 3000 lines long, but many packages aren't specifically configured beyond their defaults. So i'm not sure whether bisection would work ....

By "outside of evil" i meant: i don't have evil enabled globally, and usually only enable it per-buffer via evil-local-mode.

Here's the entirety of evil-related stuff in my config:

[excerpt from the value assigned to `mode-line-format`:]
'(:eval
  (if evil-state
      " (v)"))
...
(define-key personal-global-map (kbd "e") #'evil-local-mode-y-or-n)
...
(require 'evil)

(setq evil-emacs-state-cursor '("red" box))
(setq evil-normal-state-cursor '("green" box))
(setq evil-visual-state-cursor '("orange" box))
(setq evil-insert-state-cursor '("red" bar))
(setq evil-replace-state-cursor '("red" bar))
(setq evil-operator-state-cursor '("red" hollow))

;; KLUDGE:
;; Remove all advice on `describe-char', including the advice added by
;; evil-integration.el, to get `describe-char' working again.
(ad-deactivate #'describe-char)
...
(defun evil-local-mode-y-or-n ()
  (interactive)
  (if (member 'evil-local-mode local-minor-modes)
      (evil-local-mode -1)
    (if (y-or-n-p "Enable evil-local-mode?")
        (evil-local-mode))))

evil-local-mode-y-or-n is there because i found myself accidentally invoking the binding for evil-local-mode in personal-global-map, not realising i'd done so, and was then confused as to what was happening in responses to my keyboard inputs. :-P

I still can't reproduce this error, having tried running emacs like so:

emacs -Q -L . -l evil.el

and manually enabling and disabling evil-local-mode in various buffers, describe-char still works in both instances. I'll close this issue for now, but please feel free to reopen if you can provide repro instructions in such a limited environment. If you're not aware, it looks like org-babel-tangle is an option for extracting the source code from a literate config. Maybe worth a try if bisection is tricky as is.

Yeah, my config gets tangled at each startup, so i did a bisect-and-restart thing.

Embarrassingly, it turned out that a while back, for reasons i now can't remember, i'd put a couple of lines in a separate file i have for ELisp dev purposes, which i load from my main config file:

(debug-on-entry #'evil-mode)
(debug-on-entry #'evil-local-mode)

Commenting out those lines has resulted in things working again.

Sorry for the noise, and for wasting your time!

No problem, glad it's sorted!