From fa5b0d75d2b38f962e6bd3f6f5086dd04ae8609d Mon Sep 17 00:00:00 2001 From: tj Date: Thu, 25 Apr 2013 11:49:32 +0200 Subject: [PATCH] error call in keybinding macro replaced with warning message. --- outshine.el | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/outshine.el b/outshine.el index e039bfb..d6a5407 100644 --- a/outshine.el +++ b/outshine.el @@ -408,27 +408,26 @@ t Everywhere except in headlines" ;; copied from Alexander Vorobiev ;; http://www.mail-archive.com/emacs-orgmode@gnu.org/msg70648.html + (defmacro outshine-define-key-with-fallback (keymap key def condition &optional mode) - "Define key with fallback. Binds KEY to definition DEF in keymap KEYMAP, the - binding is active when the CONDITION is true. Otherwise turns MODE off and - re-enables previous definition for KEY. If MODE is nil, tries to recover it -by stripping off \"-map\" from KEYMAP name." - `(define-key - ,keymap ,key - (lambda () (interactive) - (if ,condition ,def - (let* ((,(if mode mode - (let* ((keymap-str (symbol-name keymap)) - (mode-name-end (- (string-width keymap-str) - 4))) - (if (string= "-map" (substring keymap-str - mode-name-end)) + "Define key with fallback. +Binds KEY to definition DEF in keymap KEYMAP, the binding is +active when the CONDITION is true. Otherwise turns MODE off and +re-enables previous definition for KEY. If MODE is nil, tries to +recover it by stripping off \"-map\" from KEYMAP name." + `(define-key ,keymap ,key (lambda () (interactive) + (if ,condition ,def + (let* ((,(if mode mode + (let* ((keymap-str (symbol-name keymap)) + (mode-name-end (- (string-width keymap-str) 4))) + (if (string= "-map" (substring keymap-str mode-name-end)) (intern (substring keymap-str 0 mode-name-end)) - (error "Could not deduce mode name from keymap name -(\"-map\" missing?)")))) nil) -(original-func (key-binding ,key))) -(call-interactively original-func)))))) + (message "Could not deduce mode name from keymap name")) + ;; (\\"-map\\" missing?)") + )) nil) + (original-func (key-binding ,key))) + (call-interactively original-func)))))) ;; *** Normalize regexps