stardiviner
4/25/2014 - 11:54 AM

init-my-prog-document.el

;;; keybindings prefix

;; I want to make a keybinding prefix more smart, make it can define key depend on current major mode.
;; with my poor Elisp knowledge, I only know the follow code. But this is globall.

(define-prefix-command 'my-help-document-prefix-map)
;; FIXME: don't set prefix as global, set it major mode locally.
(global-set-key (kbd "C-h d") 'my-help-document-prefix-map)

(dolist (hook '(ruby-mode-hook
                ))
  (add-hook hook (lambda ()
                   ;; here when I press [C-h d d] I found I can see 'yari in emacs-lisp-mode.
                   ;; this is not the good way. so I want to make prefix keybinding more smart.
                   ;; can Elisp do this?
                   (define-key my-help-document-prefix-map (kbd "d") 'yari)
                   (define-key my-help-document-prefix-map (kbd "D") 'yari-helm)
                   )))

(eval-after-load "cider"
  ;; '(define-key cider-mode-map (kbd "C-h d") 'ac-nrepl-popup-doc)
  '(define-key my-help-document-prefix-map (kbd "d") 'ac-nrepl-popup-doc)
)