[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[MIT-Scheme-devel] Request feedback on design of dired commands
From: |
Richard Loveland |
Subject: |
[MIT-Scheme-devel] Request feedback on design of dired commands |
Date: |
Fri, 06 Sep 2013 20:27:48 -0400 |
I've written a couple of simple dired commands to help me transition to
an ``all-Edwin'' lifestyle -- I'd love to get some feedback on them from
this list:
* DIRED-DO-SHELL-COMMAND
* DIRED-RUN-PROGRAM-IN-BACKGROUND (not sure about this name,
suggestions welcome)
The code is below, along with questions.
The first command is pretty straightforward. I don't like that it uses
the UNIXism "&", though. I'd like to rewrite this in something portable
to Windows, et al. There could just be a conditional that checks if
Scheme is running on a non-UNIX system, but I'd be happy to use a more
robust cross-platform idiom if y'all can recommend one.
(define-command dired-do-shell-command
"Run a shell command on the file or directory at point.
Note that this is a synchronous operation; Edwin will not accept
input until the shell command finishes."
(lambda ()
(list ((environment-lookup
(->environment '(edwin process)) 'shell-command-prompt)
"Shell command on file: ")
(command-argument)))
(lambda (command pathname)
(run-shell-command
(string-append command " "
(->namestring (dired-current-pathname)) " " "&"))))
The second, DIRED-RUN-PROGRAM-IN-BACKGROUND, was written because Edwin
was blocking on the call to RUN-SHELL-COMMAND in the above, even with
the appended "&".
It'd be cool to unify the two if there's a better way to get all this
functionality into one command.
(define-command dired-run-program-in-background
"Run a program on the file or directory at point.
This starts the program as a background subprocess, so you can
continue using Edwin."
(lambda ()
(let ((shell-command-prompt
(environment-lookup
(->environment '(edwin process)) 'shell-command-prompt)))
(list
(shell-command-prompt "With arguments: ")
(shell-command-prompt "Run program on file: ")
(command-argument))))
(lambda (user-args program-name pathname)
(let* ((program (os/find-program program-name (user-homedir-pathname)
(ref-variable exec-path))) ; modify in .edwin as needed
(filename (->namestring (dired-current-pathname)))
(arguments (list->vector (list user-args filename))))
(start-subprocess-in-background program arguments #f))))
(define-key 'dired #\! 'dired-do-shell-command)
(define-key 'dired #\& 'dired-run-program-in-background)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [MIT-Scheme-devel] Request feedback on design of dired commands,
Richard Loveland <=