Skip to content
This repository has been archived by the owner on Jun 25, 2024. It is now read-only.

The texts for the same key in different keymaps are overridden each other #352

Closed
goofansu opened this issue Jul 19, 2023 · 2 comments
Closed

Comments

@goofansu
Copy link

goofansu commented Jul 19, 2023

Minimal config:

;; Package manager
(defvar bootstrap-version)
(let ((bootstrap-file
       (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
      (bootstrap-version 6))
  (unless (file-exists-p bootstrap-file)
    (with-current-buffer
        (url-retrieve-synchronously
         "https://raw.githubusercontent.com/radian-software/straight.el/develop/install.el"
         'silent 'inhibit-cookies)
      (goto-char (point-max))
      (eval-print-last-sexp)))
  (load bootstrap-file nil 'nomessage))

(straight-use-package 'use-package)
(setq straight-use-package-by-default t)

;; Keybindings
(use-package general
  :config
  (general-define-key
   :prefix "C-c m"
   :keymaps 'org-mode-map
   "t" '(:ignore t :which-key "tasks")
   "tt" #'org-todo
   )

  (general-define-key
   :prefix "C-c m"
   :keymaps 'emacs-lisp-mode-map
   "t" '(:ignore t :which-key "eval")
   "tt" #'eval-defun
   ))

(use-package which-key
  :config (which-key-mode))

Demo

CleanShot.2023-07-20.at.00.48.24.mp4

Reproduce

With the Minimal config below:

  1. Visiting an emacs-lisp mode file, C-c m t shows +eval;
  2. Visiting an org mode file, C-c m t shows +tasks;
  3. Visiting the file in step 1, C-c m t shows +tasks too, which is unexpected.

But I don't confirm whether it is a bug in which-key or general.el.

@goofansu goofansu changed the title The text for a same key in different keymaps are overridden each other The texts for the same key in different keymaps are overridden each other Jul 19, 2023
@goofansu
Copy link
Author

Seems the same as noctuid/general.el#186, closing.

@goofansu
Copy link
Author

For anyone encounters the problem, the solution is to add :major-modes t, for example:

(use-package general
  :config
  (general-define-key
   :prefix "C-c m"
   :keymaps 'org-mode-map
   :major-modes t
   "t" '(:ignore t :wk "tasks")
   "tt" #'org-todo
   )

  (general-define-key
   :prefix "C-c m"
   :keymaps 'emacs-lisp-mode-map
   :major-modes t
   "t" '(:ignore t :wk "eval")
   "tt" #'eval-defun
   ))

References

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

No branches or pull requests

1 participant