stumpwm-devel
[Top][All Lists]
Advanced

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

[STUMP] [PATCH] Renamed interactive-command; new optional "interactivep"


From: Lionel Flandrin
Subject: [STUMP] [PATCH] Renamed interactive-command; new optional "interactivep" parameter.
Date: Tue, 15 Jul 2008 01:11:43 +0200

* Renamed interactive-command to eval-command which now takes an
  optional "interactivep" parameter. This parameter is set to T in the
  :key-press handler (when called from a keyboard binding) and in
  "colon". It's used to know if %interactivep% should be set to T in
  the called command.
* Renamed "call-interactively" to "call-command" for consistency.
---
 command.lisp          |   16 ++++++++--------
 events.lisp           |    9 ++++-----
 sample-stumpwmrc.lisp |    2 +-
 3 files changed, 13 insertions(+), 14 deletions(-)

diff --git a/command.lisp b/command.lisp
index 9e46d84..ae2059a 100644
--- a/command.lisp
+++ b/command.lisp
@@ -356,7 +356,7 @@ then describes the symbol."
 
 ;;;
 
-(defun call-interactively (command &optional (input ""))
+(defun call-command (command &optional (input ""))
   "Parse the command's arguments from input given the command's
 argument specifications then execute it. Returns a string or nil if
 user aborted."
@@ -400,25 +400,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-command 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 +443,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 +452,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..f18b959 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]