conao3 / leaf.el

Flexible, declarative, and modern init.el package configuration
GNU General Public License v3.0
505 stars 28 forks source link

request: don't defer keymap bindings when :leaf-defer is nil #273

Open leotaku opened 5 years ago

leotaku commented 5 years ago

Description

Currently using a leaf block with :leaf-defer set to nil to bind keys to a keymap causes the bindings to be deferred to the leaf name.

I do not think this behavior is intuitive or useful, which is why I am asking for this change.

Issue leaf-block

(leaf foo
  :leaf-defer nil
  :bind (:some-map
         ("C-w" . bar)))

Output from macroexpand-1 of the leaf-block

(prog1 'foo
  (leaf-handler-leaf-protect foo
    (autoload #'bar "foo" nil t)
    (leaf-keys
     ((:some-map :package foo
                 ("C-w" . bar))))))

Expected output from macroexpand-1 of the leaf-block

(prog1 'foo
  (leaf-handler-leaf-protect foo
    (autoload #'bar "foo" nil t)
    (leaf-keys
     ((:some-map 
       ("C-w" . bar))))))
conao3 commented 5 years ago

I think it's right. But I don't want to include relationships between keywords more than necessary.

The example you gave may not be intuitive or useful. But please tell me the actual example you encountered. Then I can think more specifically.

wsw0108 commented 3 years ago
;;; -*- lexical-binding: t -*-

(leaf flycheck
  :ensure t
  :hook
  (sh-mode-hook . flycheck-mode)
  (emacs-lisp-mode-hook . flycheck-mode)
  :defvar (flycheck-emacs-lisp-load-path)
  :bind
  (:flycheck-mode-map
   ("M-n" . flycheck-next-error)
   ("M-p" . flycheck-previous-error))
  :config
  (setq-default flycheck-disabled-checkers '(emacs-lisp-checkdoc))
  (setq flycheck-emacs-lisp-load-path 'inherit))

(leaf flycheck-projectile
  :ensure t
  :leaf-defer nil                       ;
  ;; :require t
  :bind
  (projectile-command-map
   ("L" . flycheck-projectile-list-errors)))

(provide 'init-flycheck)

;;; init-flycheck.el ends here

the bind to L has no effect

conao3 commented 3 years ago

please try

(leaf flycheck-projectile
  :ensure t
  :leaf-defer nil                       ;
  ;; :require t
  :bind
  (projectile-command-map
   :package projectile
   ("L" . flycheck-projectile-list-errors)))
wsw0108 commented 3 years ago

Thanks. It works, with or without :leaf-defer nil.