stumpwm-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[STUMP] [PATCH] interactive-command renamed to eval-command; new argumen


From: Lionel Flandrin
Subject: [STUMP] [PATCH] interactive-command renamed to eval-command; new argument "interactivep"
Date: Wed, 16 Jul 2008 00:39:46 +0200

From: Lionel Flandrin <address@hidden>

* interactive-command renamed to the less ambiguous "eval-command".
* Optional argument "interactivep" used to know if the command should
  be run with %interactivep% set to T.
* (declare (ignorable %interactivep%)) in defcommand to avoid a warning
  about the potentially unused variable.
---
 command.lisp          |   15 ++++++++-------
 events.lisp           |    9 ++++-----
 sample-stumpwmrc.lisp |    2 +-
 3 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/command.lisp b/command.lisp
index 9e46d84..8c51a85 100644
--- a/command.lisp
+++ b/command.lisp
@@ -54,6 +54,7 @@
      (defun ,name ,args
        (let ((%interactivep% *interactivep*)
             (*interactivep* nil))
+        (declare (ignorable %interactivep%))
         ,@body))
      (setf (gethash ',name *command-hash*)
            (make-command :name ',name
@@ -400,25 +401,26 @@ user aborted."
           (apply (command-name cmd-data) args)
         (setf *last-command* command)))))
 
-(defun interactive-command (cmd)
+(defun eval-command (cmd &optional interactivep)
   "exec cmd and echo the result."
   (labels ((parse-and-run-command (input)
              (let* ((arg-line (make-argument-line :string input
                                                   :start 0))
                     (cmd (argument-pop arg-line)))
-               (call-interactively cmd arg-line))))
+               (let ((*interactivep* interactivep))
+                (call-interactively cmd arg-line)))))
     (multiple-value-bind (result error-p)
         ;; this fancy footwork lets us grab the backtrace from where the
         ;; error actually happened.
         (restart-case
             (handler-bind 
                 ((error (lambda (c)
-                          (invoke-restart 'interactive-command-error
+                          (invoke-restart 'eval-command-error
                                           (format nil "^B^1*Error In Command 
'^b~a^B': ^n~A~a" 
                                                   cmd c (if 
*show-command-backtrace* 
                                                             (backtrace-string) 
""))))))
               (parse-and-run-command cmd))
-          (interactive-command-error (err-text)
+          (eval-command-error (err-text)
             (values err-text t)))
       ;; interactive commands update the modeline
       (update-all-mode-lines)
@@ -442,7 +444,7 @@ know lisp very well. One might put the following in one's 
rc file:
   \"split\")
 @end example"
   (loop for i in commands do
-        (interactive-command i)))
+        (eval-command i)))
 
 (defcommand colon (&optional initial-input) (:rest)
   "Read a command from the user. @var{initial-text} is optional. When
@@ -451,5 +453,4 @@ supplied, the text will appear in the prompt."
     (unless cmd
       (throw 'error :abort))
     (when (plusp (length cmd))
-      (let ((*interactivep* t))
-       (interactive-command cmd)))))
+      (eval-command cmd t))))
diff --git a/events.lisp b/events.lisp
index f82cd56..e9ee1d8 100644
--- a/events.lisp
+++ b/events.lisp
@@ -281,7 +281,7 @@ The Caller is responsible for setting up the input focus."
                ((eq cmd t))
                (cmd
                 (unmap-message-window (current-screen))
-                (interactive-command cmd) t)
+                (eval-command cmd t) t)
                (t (message "~{~a ~}not bound." (mapcar 'print-key (nreverse 
key-seq))))))))))
 
 (defun bytes-to-window (bytes)
@@ -304,7 +304,7 @@ chunks."
                         (interactive-p (car data))
                         (cmd (map 'string 'code-char (nbutlast (cdr data)))))
                    (declare (ignore interactive-p))
-                   (interactive-command cmd)
+                   (eval-command cmd)
                    (xlib:change-property win :rp_command_result (map 'list 
'char-code "0TODO") :string 8)
                    (xlib:display-finish-output *display*)))
                bytes-after)))
@@ -321,7 +321,7 @@ chunks."
           (*executing-stumpwm-command* t))
       (setf (screen-last-msg screen) '()
             (screen-last-msg-highlights screen) '())
-      (interactive-command cmd)
+      (eval-command cmd)
       (xlib:change-property win :stumpwm_command_result
                             (string-to-bytes (format nil "~{~{~a~%~}~}" 
(nreverse (screen-last-msg screen))))
                             :string 8)
@@ -638,8 +638,7 @@ 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")
-              (let ((*interactivep* t))
-                (apply eventfn event-slots)))
+              (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/sample-stumpwmrc.lisp b/sample-stumpwmrc.lisp
index 8ef329e..26235e7 100644
--- a/sample-stumpwmrc.lisp
+++ b/sample-stumpwmrc.lisp
@@ -12,7 +12,7 @@
 (defcommand colon1 (&optional (initial "")) (:rest)
   (let ((cmd (read-one-line (current-screen) ": " initial)))
     (when cmd
-      (interactive-command cmd (current-screen)))))
+      (eval-command cmd t))))
 
 ;; Read some doc
 (define-key *root-map* (kbd "d") "exec gv")
-- 
1.5.6





reply via email to

[Prev in Thread] Current Thread [Next in Thread]