Download text files and call $EDITOR - clic - Clic is an command line interacti… | |
git clone git://bitreich.org/clic/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65… | |
Log | |
Files | |
Refs | |
Tags | |
README | |
LICENSE | |
--- | |
commit 8082edf6c70c5873c19f92730e8e0db5bceb1dee | |
parent 8605ef1699e170afed26d4266f2bf3db53225e73 | |
Author: Solene Rapenne <[email protected]> | |
Date: Thu, 11 Jan 2018 20:53:01 +0000 | |
Download text files and call $EDITOR | |
Diffstat: | |
M clic.lisp | 41 +++++++++++++++++------------… | |
1 file changed, 23 insertions(+), 18 deletions(-) | |
--- | |
diff --git a/clic.lisp b/clic.lisp | |
@@ -479,24 +479,29 @@ | |
(cond | |
;;;; output is a text file ? | |
;;;; call the $PAGER ! | |
- ((string= "0" type) | |
- ;;; generate a string from *buffer* array | |
- (let ((text (string-right-trim ; remove last newline | |
- (string #\Newline) | |
- (format nil "~{~a~%~}" ; concatenate lines | |
- (loop for line across *buffer* | |
- collect line))))) | |
- ;; create input stream used as stdin for $PAGER | |
- (let ((input (make-string-input-stream text))) | |
- (uiop:run-program (list (uiop:getenv "PAGER")) | |
- :input input | |
- :output :interactive)) | |
- ;; display last menu | |
- (pop *history*) | |
- (when *previous-buffer* | |
- (setf *buffer* (copy-array *previous-buffer*)) | |
- (setf *links* (make-hash-table)) | |
- (display-buffer "1")))) | |
+ ((string= "0" type) | |
+ ;;; generate a string from *buffer* array | |
+ (let* ((uri (location-uri (car *history*))) | |
+ (filename (subseq uri (1+ (position #\/ uri :from-end t)))) | |
+ (path (concatenate 'string "/tmp/" filename))) | |
+ (print filename) | |
+ (print path) | |
+ (with-open-file (output path | |
+ :direction :output | |
+ :if-does-not-exist :create | |
+ :if-exists :supersede) | |
+ (loop for line across *buffer* | |
+ do | |
+ (format output "~a~%" line))) | |
+ (uiop:run-program (list (or (uiop:getenv "EDITOR") "less") path) | |
+ :input :interactive | |
+ :output :interactive)) | |
+ ;; display last menu | |
+ (pop *history*) | |
+ (when *previous-buffer* | |
+ (setf *buffer* (copy-array *previous-buffer*)) | |
+ (setf *links* (make-hash-table)) | |
+ (display-buffer "1"))) | |
;; image | |
((or |