;; ;; The next few sections were added to allow for easy process creation ;; on the Atari ST/TT. ;; (provide 'launch-command) ;; ;; (sjk)++ Make blank delimited string into a word list... ;; (defun parse-string (arg1) (let ((start 0) (w 0) (result nil)) (while (not (equal (+ 1 w start) (length arg1))) (cond ((string= " " (substring arg1 (+ start w) (+ 1 start w))) (setq result (append result (list (substring arg1 start (+ start w))))) (setq start (+ start w 1)) (setq w 0) )) (setq w (+ 1 w)) ) (setq result (append result (list (substring arg1 start (length arg1))))) ) ) ;; ;; (sjk)++ build list of (first rest) from space delimited string of words. ;; (defun first-rest (command-line) (let* ((temp (parse-string command-line)) (prog (car temp))) (cond ((cdr temp) (list prog (substring command-line (+ 1 (length prog)) (length command-line)))) (t (list prog ""))) ) ) ;; ;; (sjk)++ build concat of ("s1" ... "sn") ;; (defun strcat (arg) (cond ((car arg) (concat (car arg) " " (strcat (cdr arg)))) ( t nil )) ) ;; ;; (sjk)++ I can't take the credit for these, they are really ;; just copies of shell-command, and shell-vommand-on-region ;; that where hacked a bit to launch arbitrary commands ;; directly without the need for a subshell. The only problem ;; is that they do not do shell type regex expansions on thier ;; arguments. ;; (defun launch-command (command-name args &optional flag) "Execute string COMMAND-NAME with ARGS as its arguments; display output, if any. Optional third arg non-nil (prefix arg, if interactive) means insert output in current buffer after point (leave mark after it)." (if flag (progn (barf-if-buffer-read-only) (push-mark) (apply 'call-process (append (list command-name nil t nil) args)) (exchange-point-and-mark)) (launch-command-on-region (point) (point) command-name args nil))) ;; ;; (sjk)++ See comment on the above function. ;; (defun launch-command-on-region (start end command-name args &optional flag interactive) "Execute string COMMAND-NAME with ARGS as its arguments, region as input. Normally display output (if any) in temp buffer; Prefix arg means replace the region with it. Noninteractive args are START, END, COMMAND-NAME, ARGS, FLAG. Noninteractively FLAG means insert output in place of text from START to END, and put point at the end, but don't alter the mark." (if flag ;; Replace specified region with output from command. (let ((swap (and interactive (< (point) (mark))))) ;; Don't muck with mark ;; unless called interactively. (and interactive (push-mark)) (apply 'call-process-region (append (list start end command-name t t t) args)) (and interactive swap (exchange-point-and-mark))) (let ((buffer (get-buffer-create "*Compilation*"))) (save-excursion (set-buffer buffer) (erase-buffer) (set-window-start (display-buffer buffer) 1) (setq mode-name "Compilation") (setq mode-line-process '(": running")) (set-buffer-modified-p (buffer-modified-p)) (princ (concat "Command line: " command-name " " (strcat args) "\n") (get-buffer "*Compilation*")) (sit-for 1)) (if (eq buffer (current-buffer)) (setq start 1 end 1)) (apply 'call-process-region (append (list start end command-name) (list nil buffer nil) args)) (if (save-excursion (set-buffer buffer) (> (buffer-size) 0)) (set-window-start (display-buffer buffer) 1) (princ "(Command completed with no output)" (get-buffer "*Compilation*")))))) ;; ;; End of added section ;;