diff options
author | Artur Malabarba <bruce.connor.am@gmail.com> | 2015-01-05 16:31:10 -0200 |
---|---|---|
committer | Artur Malabarba <bruce.connor.am@gmail.com> | 2015-01-05 16:31:10 -0200 |
commit | e061fb947a02290314be7247d81963e7bfd0987b (patch) | |
tree | 63fd0fe99a0e5970a9bcf6319e5c22fb6b97859b /sx.el | |
parent | 51b5f280119745074e9d16042b5608f25cbb6e06 (diff) |
Move define-conditional-key to sx.el
Diffstat (limited to 'sx.el')
-rw-r--r-- | sx.el | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -247,6 +247,18 @@ Anything before the (sub)domain is removed." (rx string-start (or (and (0+ word) (optional ":") "//"))) "" url))) +(defmacro sx--define-conditional-key (keymap key def &rest body) + "In KEYMAP, define key sequence KEY as DEF conditionally. +This is like `define-key', except the definition \"disapears\" +whenever BODY evaluates to nil." + (declare (indent 3) + (debug (form form form &rest sexp))) + `(define-key ,keymap ,key + '(menu-item + ,(format "maybe-%s" (or (car (cdr-safe def)) def)) ignore + :filter (lambda (&optional _) + (when (progn ,@body) ,def))))) + ;;; Printing request data (defvar sx--overlays nil |