1

In my emacs config i wrote:

    (use-package gnus
      :bind (("<f12>" . gnus)
         :map gnus-group-mode-map
         ("q" . gnus-group-suspend)
         ("Q" . gnus-group-exit))
    :config ........)

After i load emacs, f12 works, but "q" and "Q" do not work in gnus buffer. Only when i manually load the same code these keys work.

Could you help me to automatically bound these keys?

3
  • I bind keys if i add in :config section: (with-eval-after-load "gnus-group" (bind-key "q" #'gnus-group-suspend gnus-group-mode-map) (bind-key "Q" #'gnus-group-exit gnus-group-mode-map)) ). Is it possible to make it more pleasant with use-package?
    – RCV
    Commented Apr 10, 2017 at 15:43
  • 1
    (use-package gnus-group ...)?
    – npostavs
    Commented Apr 13, 2017 at 20:23
  • This is John Wiegley's config for gnus: github.com/jwiegley/dot-emacs/blob/master/dot-gnus.el . Try adapting his code. He uses that (use-package gnus-group ...) and bind-key.
    – Heikki
    Commented Apr 14, 2017 at 9:01

2 Answers 2

1

I think that when use-package is evaluated the gnus-group-mode-map has no value so the key binding is not made.

Refer to https://github.com/jwiegley/use-package/issues/503

The following might work (but you lose the deferred loading)

(use-package gnus
  :init
     (require 'gnus)
  :bind (("<f12>" . gnus)
     :map gnus-group-mode-map
     ("q" . gnus-group-suspend)
     ("Q" . gnus-group-exit)))
0

Keyword :map needs to be inside parenthesis. You can have multiple :bind keywords, so it is clearer to separate keys bound to separate modes. This should work:

(use-package gnus
  :bind (("<f12>" . gnus))
  :bind (:map gnus-group-mode-map
              ("q" . gnus-group-suspend)
              ("Q" . gnus-group-exit))
  :config ........)

I did not tried this code but it is based on my functioning elfeed config.

2
  • This does not work. According to use-package tutorial one can write like this :bind (("M-s O" . moccur) :map isearch-mode-map ("M-o" . isearch-moccur) ("M-O" . isearch-moccur-all))
    – RCV
    Commented Apr 13, 2017 at 15:36
  • There might be something that you are missing in how gnus works. use-package is a macro and you can use a package called macro-step to explore the generated lisp code github.com/joddie/macrostep . Copy and eval the generated code.
    – Heikki
    Commented Apr 14, 2017 at 4:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.