From e061fb947a02290314be7247d81963e7bfd0987b Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Mon, 5 Jan 2015 16:31:10 -0200 Subject: Move define-conditional-key to sx.el --- sx-switchto.el | 12 ------------ sx.el | 12 ++++++++++++ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/sx-switchto.el b/sx-switchto.el index 458586a..ed83360 100644 --- a/sx-switchto.el +++ b/sx-switchto.el @@ -54,18 +54,6 @@ ;;; These are keys which depend on context. ;;;; For instance, it makes no sense to have `switch-site' bound to a ;;;; key on a buffer with no `sx-question-list--site' variable. -(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))))) - (sx--define-conditional-key sx-switchto-map "s" #'sx-question-list-switch-site (and (boundp 'sx-question-list--site) sx-question-list--site)) diff --git a/sx.el b/sx.el index 9924308..bfc647d 100644 --- a/sx.el +++ b/sx.el @@ -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 -- cgit v1.2.3