Skip to content

fix :bind-keymap symbol evaluation #542

@conao3

Description

@conao3

Description

Maybe Too early to evaluate symbols.
The current behavior is trying to set the key-map itself bound to the symbol, not the symbol of the keymap, so it will not work correctly when added to the keymap afterwards.

Issue leaf-block

(leaf project
  :doc "Operations on the current project"
  :tag "builtin"
  :added "2024-08-30"
  :bind-keymap (("C-x C-p" . project-prefix-map)))

become

(leaf-key-bind-keymap "C-x C-p" project-prefix-map nil 'project)

become

(progn
      (require 'project)
      (leaf-key "C-x C-p" project-prefix-map nil))

become

(let*
          ((old (lookup-key global-map (kbd "C-x C-p")))
           (value
            `(global-map "C-x C-p" nil
                         ,(and old (not (numberp old)) old)
                         "/Users/conao/dev/repo/dotfiles/.dotfiles/.emacs.d/lisp/c--builtin.el")))
        (leaf-safe-push value leaf-key-bindlist)
        (define-key global-map (kbd "C-x C-p")
                    '(keymap (109 . magit-project-status)
                             (2 . project-list-buffers)
                             (111 . project-any-command)
                             (120
                              . project-execute-extended-command)
                             (114 . project-query-replace-regexp)
                             (71
                              . project-or-external-find-regexp)
                             (103 . project-find-regexp)
                             (112 . project-switch-project)
                             (107 . project-kill-buffers)
                             (101 . project-eshell)
                             (99 . project-compile)
                             (118 . project-vc-dir)
                             (68 . project-dired)
                             (100 . project-find-dir)
                             (115 . project-shell)
                             (98 . project-switch-to-buffer)
                             (70 . project-or-external-find-file)
                             (102 . project-find-file)
                             (38 . project-async-shell-command)
                             (33 . project-shell-command))))

Expected output from macroexpand-1 of the leaf-block

(define-key global-map (kbd "C-x C-p") project-prefix-map)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions