From 9f258de18367e521e2eff1a1e86b9f88fb99ae22 Mon Sep 17 00:00:00 2001 From: Michael Raitza Date: Sat, 13 Oct 2012 14:07:58 +0200 Subject: [PATCH] Refactored run-program-from-query-string. --- src/clfswm-util.lisp | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/clfswm-util.lisp b/src/clfswm-util.lisp index 6a298f3..841cbed 100644 --- a/src/clfswm-util.lisp +++ b/src/clfswm-util.lisp @@ -603,13 +603,21 @@ (let ((commands (command-in-path))) (defun run-program-from-query-string () "Run a program from the query input" - (multiple-value-bind (program return) - (query-string "Run:" "" commands) - (when (and (equal return :return) program (not (equal program ""))) - (setf *second-mode-leave-function* (let ((cmd (concatenate 'string "cd $HOME && " program))) - (lambda () - (do-shell cmd)))) - (leave-second-mode))))) + (labels ((run-program-from-query-string-fun () + (multiple-value-bind (program return) + (query-string "Run:" "" commands) + (when (and (equal return :return) program (not (equal program ""))) + (let ((cmd (concatenate 'string "cd $HOME && exec " program))) + (lambda () + (do-shell cmd))))))) + (let ((fun (run-program-from-query-string-fun))) + (when fun + (if *in-second-mode* + (progn + (setf *second-mode-leave-function* fun) + (leave-second-mode)) + (funcall fun))))))) + -- 2.11.4.GIT