Add completion for file names

Check for an empty file name before executing
This commit is contained in:
mainzelm 2003-11-18 10:35:29 +00:00
parent 92b8549db8
commit d5f792b3d4
3 changed files with 37 additions and 8 deletions

View File

@ -0,0 +1,25 @@
(define *cache* #f)
(define (executables-in-path)
(or *cache*
(begin
(set! *cache* (executables-in-path-list (thread-fluid exec-path-list)))
*cache*)))
(define (executables-in-path-list path-list)
(append-map! dir-executables path-list))
(define (dir-executables dir)
(if (file-readable? dir)
(map file-name-nondirectory
(filter executable? (glob (string-append dir "/*"))))
'()))
(define (executable? name)
(with-errno-handler
((errno packet)
(else #f))
(let ((info (file-info name)))
(and (file-info-executable? info)
(file-info-regular? info)))))

View File

@ -79,6 +79,13 @@
utils)
(files button))
(define-structure file-name-completion
(export executables-in-path)
(open scheme-with-scsh
srfi-1
thread-fluids)
(files file-name-completion))
;; *** key-grab ******************************************************
(define-structure key-grab
@ -215,7 +222,7 @@
utils key-grab
manager
move-wm split-wm switch-wm
prompt)
prompt file-name-completion)
(files root-manager))
(define-structure main

View File

@ -316,9 +316,10 @@
(exec (prompt (root-wm:dpy root-wm) (wm:window cm)
(get-option-value (root-wm:options root-wm)
'execute-question)
#f exec-complete)))
(if exec
(run (sh -c ,(string-append exec " &"))))))
#f (finite-complete (executables-in-path)))))
(and exec
(not (string=? exec ""))
(run (sh -c ,(string-append exec " &"))))))
((attach)
(let* ((cm (root-wm:current-manager root-wm))
(windows-above (window-path (wm:dpy cm) (wm:window cm)))
@ -366,10 +367,6 @@
(else (warn "unknown binding command" command))))
(warn "unhandled root message" msg)))))
(define (exec-complete str pos)
;; TODO
(cons str pos))
(define (finite-complete strings)
(lambda (str pos)
(let* ((s (substring str 0 pos))