;;;; runner.jl -- run commands with completion on executables in PATH ;;;; (C) Stefan Kamphausen ;;;; Time-stamp: <21-May-2004 11:05:57 skamphausen> (require 'prompt) (defvar runner-completion-table ()) (defun runner-build-completion-table () "Find all executable files in PATH and cache them. This skips any entries in PATH that are not directories. Call this manually when you want to rebuild the list after installation of new programs." (interactive) (let ((dirs (delete-if-not file-directory-p (string-split ":" (getenv "PATH"))))) (setq runner-completion-table ()) (while dirs (setq runner-completion-table (append runner-completion-table (directory-files (car dirs)))) (setq dirs (cdr dirs))))) (defun runner-run () "Run a programm interactively. Uses a completion table built from the files in PATH, but accepts any string. If you want to keep your own hotlist, so you're not annoyed by too many completions, simply set runner-completion-table to the desired list and it won't be rebuild automatically." (when (null runner-completion-table) (runner-build-completion-table)) (let ((cmd (prompt-from-list runner-completion-table "Run Command: " "" t))) (system (concat cmd " &"))))