Skip to content

Commit

Permalink
Abstract kbd function/macro
Browse files Browse the repository at this point in the history
This is no meaning on 24.3 or higher Emacs and still old Emacs can not
use mykie.
  • Loading branch information
yuutayamada committed Feb 9, 2015
1 parent 23a0212 commit fe1c92e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 9 additions & 1 deletion lisp/mykie.el
Original file line number Diff line number Diff line change
Expand Up @@ -632,10 +632,18 @@ Otherwise return KW-AND-CONDITION's first element."
(before (run-hooks 'mykie:region-before-init-hook))
(after (run-hooks 'mykie:region-after-init-hook)))))

(defun mykie:kbd (key)
(kbd key))

;; TODO: Fix this to work around in old version Emacs
(when (version< emacs-version "24.3")
(defadvice mykie:kbd (around macro->function activate)
(setq ad-return-value (apply (macroexpand (list 'kbd (ad-get-arg 0)))))))

(defun mykie:format-key (key)
(cl-typecase key
(vector key)
(string (kbd key))
(string (mykie:kbd key))
(t (error "Invalid key"))))

(defmacro mykie:define-key (keymap key &rest args)
Expand Down
2 changes: 1 addition & 1 deletion test/test-helper.el
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
(with-temp-buffer
(test-init expect)
(when test-region-state (set-mark (point)))
(call-interactively (lookup-key map (kbd key)))
(call-interactively (lookup-key map (mykie:kbd key)))
(case expect
(readonly (toggle-read-only 0))
((url C-u&url) (should (equal test-url mykie:current-thing)))
Expand Down

0 comments on commit fe1c92e

Please sign in to comment.