How can I make C-p an Emacs prefix key for Devel::PerlySense?

前端 未结 2 2022
闹比i
闹比i 2021-02-03 11:01

I just installed Devel::PerlySense 0.0180.

I have put the following in my .emacs file:

 ; PerlySense
 (load \"~/perly-sense\")

 (global-unset-key \"\\C-         


        
相关标签:
2条回答
  • 2021-02-03 11:05

    Emacs, by default, only allows certain keys to be prefixes (the start of multi-key commands). See http://www.gnu.org/software/emacs/manual/html_node/elisp/Prefix-Keys.html You need to create a keymap and bind it to C-p.

    0 讨论(0)
  • 2021-02-03 11:08

    The explicit answer to your question is this:

    (define-prefix-command 'perly-sense-map)
    (global-set-key (kbd "C-p") 'perly-sense-map)
    (define-key perly-sense-map (kbd "C-d") 'perly-sense-smart-docs-at-point)
    (define-key perly-sense-map (kbd "C-g") 'perly-sense-smart-go-to-at-point)
    

    For more information as to what's being done, check out documentation for

    • define-prefix-command
    • keymaps
    • kbd

    In the original post, you mixed using kbd and the older "\C-p" notation. You can read this large tutorial discussing keybindings, which has tons of information (more than what you probably need). I find the kbd usage to be the easiest, you just pass it the string that you'd see when you do help on a key (C-h k).

    0 讨论(0)
提交回复
热议问题