2f0928adebb9

Add `exit` support
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Sat, 19 May 2018 17:42:21 -0400
parents a537826e3141
children 0a3160c5895c
branches/tags (none)
files src/main.lisp

Changes

--- a/src/main.lisp	Thu May 10 22:02:42 2018 -0400
+++ b/src/main.lisp	Sat May 19 17:42:21 2018 -0400
@@ -27,6 +27,14 @@
   (setf *pos* (clamp 0 (1- (length *urls*))
                      (+ *pos* delta))))
 
+(defun quit (&optional code)
+  #+sbcl (sb-ext:exit :code code)
+  #+ccl (ccl:quit code)
+  #+abcl (ext:quit :status code)
+  #+ecl (ext:quit code)
+  #-(or ccl sbcl ecl abcl)
+  (error "QUIT not supported on this implementation"))
+
 
 ;;;; Actions ------------------------------------------------------------------
 (defclass* (action :conc-name "") ()
@@ -40,13 +48,15 @@
 (defmacro define-action (keys program &key
                          (url 'url)
                          (arguments `(list ,url))
+                         exit
                          tty)
   `(create-action
      (lambda (,url)
        (external-program:run ,program ,arguments
                              ,@(if tty
                                  '(:output t :input t)
-                                 '())))
+                                 '()))
+       (when ,exit (quit)))
      ,keys
      ,tty))