[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[STUMP] [PATCH] Modified implementation of defcommand to add a local %in
From: |
Lionel Flandrin |
Subject: |
[STUMP] [PATCH] Modified implementation of defcommand to add a local %interactivep% variable |
Date: |
Tue, 15 Jul 2008 00:15:22 +0200 |
* %interactivep% is set to t if the defcommand is called directly from
"colon" or a keybinding.
---
command.lisp | 8 ++++++--
events.lisp | 3 ++-
primitives.lisp | 3 +++
3 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/command.lisp b/command.lisp
index d7866ef..9e46d84 100644
--- a/command.lisp
+++ b/command.lisp
@@ -51,7 +51,10 @@
"Create a command function and store its interactive hints in
*command-hash*."
(check-type name symbol)
`(progn
- (defun ,name ,args ,@body)
+ (defun ,name ,args
+ (let ((%interactivep% *interactivep*)
+ (*interactivep* nil))
+ ,@body))
(setf (gethash ',name *command-hash*)
(make-command :name ',name
:args ',interactive-args))))
@@ -448,4 +451,5 @@ supplied, the text will appear in the prompt."
(unless cmd
(throw 'error :abort))
(when (plusp (length cmd))
- (interactive-command cmd))))
+ (let ((*interactivep* t))
+ (interactive-command cmd)))))
diff --git a/events.lisp b/events.lisp
index 854dce9..f82cd56 100644
--- a/events.lisp
+++ b/events.lisp
@@ -638,7 +638,8 @@ the window in it's frame."
;; reprocessed after restarting to the top level. So fake
;; it, and put the restart here.
(with-simple-restart (top-level "Return to stumpwm's top level")
- (apply eventfn event-slots))
+ (let ((*interactivep* t))
+ (apply eventfn event-slots)))
(xlib:display-finish-output *display*))
((or xlib:window-error xlib:drawable-error) (c)
;; Asynchronous errors are handled in the error
diff --git a/primitives.lisp b/primitives.lisp
index fee1fc4..3f73cc6 100644
--- a/primitives.lisp
+++ b/primitives.lisp
@@ -524,6 +524,9 @@ single char keys are supported.")
(defvar *executing-stumpwm-command* nil
"True when executing external commands.")
+(defvar *interactivep* nil
+ "True when a defcommand is executed from colon or a keybinding")
+
;;; The restarts menu macro
(defmacro with-restarts-menu (&body body)
--
1.5.6
- [STUMP] [PATCH] Modified implementation of defcommand to add a local %interactivep% variable,
Lionel Flandrin <=