Skip to content

Instantly share code, notes, and snippets.

@shrdlu68
Created March 1, 2018 13:17
Show Gist options
  • Save shrdlu68/19e979b8b63be290e4d1b3116ea6c899 to your computer and use it in GitHub Desktop.
Save shrdlu68/19e979b8b63be290e4d1b3116ea6c899 to your computer and use it in GitHub Desktop.
;;; Make multiple binding with a common prefix
(in-package :next)
(defmacro defhydra (name prefix &body suffixes)
`(progn
(defun ,name ()
(with-result (suffix (read-from-minibuffer
(mode *minibuffer*)))
(cond ,@(map 'list (lambda (arg)
(list (list 'equal 'suffix (first arg))
(list (second arg))))
suffixes))))
(define-key *global-map* ,prefix #',name)))
(defhydra switch-buffer (kbd "s")
("p" switch-buffer-previous)
("n" switch-buffer-next))
(defhydra load-url (kbd "c")
("l" set-url-current-buffer)
("L" set-url-new-buffer))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment