AmaiKinono / puni

Structured editing (soft deletion, expression navigating & manipulating) that supports many major modes out of the box.
GNU General Public License v3.0
401 stars 21 forks source link

Custom keybindings does not get loaded #32

Closed alternateved closed 2 years ago

alternateved commented 2 years ago

Hello!

As noted in the README:

;; The autoloads of Puni are set up so you can enable `puni-mode` or
;; `puni-global-mode` before `puni` is actually loaded. Only after you press
;; any key that calls Puni commands, it's loaded.

What in situation when one would want to define custom keybindings? I have a couple of bindings defined like so:

(eval-after-load 'puni
  #'(lambda nil
      (progn
        (define-key puni-mode-map
                    [C-up]
                    #'puni-raise)
        (define-key puni-mode-map
                    [C-down]
                    #'puni-splice)
        (define-key puni-mode-map
                    [C-right]
                    #'puni-slurp-forward)
        (define-key puni-mode-map
                    [C-left]
                    #'puni-barf-forward))))

It seems that those won't get loaded until I use some other puni binding like puni-kill-line. Is there a way to work around that?

Kind wishes, alternateved

AmaiKinono commented 2 years ago

I think just remove the with-eval-after-load wrapper would make things work.

alternateved commented 2 years ago

Ah right! I feel stupid for asking such a question. Without with-eval-after-load it works.

I am not 100% sure (since I don't use it currently), but I think use-package :bind macro uses with-eval-after-load, so similarly custom bindings won't work there.

EDIT: After checking it, it seems that this:

(use-package puni
  :bind (:map puni-mode-map
              ("C-<down>" . puni-splice)))

Expands to this:

(progn
  (defvar use-package--warning18
    #'(lambda
        (keyword err)
        (let
            ((msg
              (format "%s/%s: %s" 'puni keyword
                      (error-message-string err))))
          (display-warning 'use-package msg :error))))
  (condition-case-unless-debug err
      (progn
        (unless
            (fboundp 'puni-splice)
          (autoload #'puni-splice "puni" nil t))
        (bind-keys :package puni :map puni-mode-map
                   ("C-<down>" . puni-splice)))
    (error
     (funcall use-package--warning18 :catch err))))

So it should be no problem.

AmaiKinono commented 2 years ago

Great ;) I'll close the issue then.