all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Run an external program on the file visited in current buffer and open a new buffer with results
@ 2006-04-18 14:12 Suttles, Andrew
  2006-04-18 14:21 ` Kevin Rodgers
  0 siblings, 1 reply; 7+ messages in thread
From: Suttles, Andrew @ 2006-04-18 14:12 UTC (permalink / raw)



[-- Attachment #1.1: Type: text/plain, Size: 2559 bytes --]

I use emacs to edit large data files which I submit to a computer
program for analysis.  My normal method of operation is to 1) edit the
file in emacs, 2) close or minimize emacs, 3) run the program on the
file in a shell window, 4) watch for program completion, then 5) view
the output file in a new buffer.  I'm getting proficient enough to do
these types of things without leaving emacs (multiple buffers with
shells open), but I know there must be a better way.

 

I'd like to edit a data file in a buffer and then execute an elisp
command which will run "program" on the file being edited and then pop
up a new frame with the resultant output file after the analysis.  I've
tried using shell command, but emacs blocks while the program is running
(from 5 mins to 10+ hours).  If I use shell command asynchronously, it
works fine, but I have to constantly watch for program termination
before opening the output file in a new buffer.

 

I've tried the lisp code below which doesn't quite work...

 

The goal here is to save the current buffer, open a shell process, run
"program" on the file visited in the buffer, exit the shell after the
program finishes, detect that the process is dead, and then visit the
output file in a new frame.  The problem is that when "program" is run
synchronously, the program must finish before the sentinel gets set.
For some reason, setting the sentinel and then issuing the command
doesn't seem to work.  

 

I'm sure I'm not doing this the most efficient way.  Any help would be
appreciated.

 

<lisp code retyped from different computer - assume all tabs and
parenthesis are correct in the original>

 

(defun acs-run-program-current-buffer ()

  (interactive)

  (prong

    (save-buffer)

    (save-excursion

      (let ((infile (buffer-file-name (current-buffer)))

            (outfile (concat (file-name-sans-extension (buffer-file-name
(current-buffer))) ".f06"))

            (shellname (concat "PROGRAM->" (buffer-file-name
(current-buffer)))))

        (switch-to-buffer (shell shellname))

        (comint-simple-send

          (get-buffer-proccess (current-buffer)

            (concat "program -switch " infile "; exit"))

        (set-process-sentinel

          (get-buffer-process (current-buffer)

                                      (lambda (process event)

                                        (kill-buffer (current-buffer))

                                        (find-file-other-frame
outfile))))))))


[-- Attachment #1.2: Type: text/html, Size: 8584 bytes --]

[-- Attachment #2: Type: text/plain, Size: 152 bytes --]

_______________________________________________
help-gnu-emacs mailing list
help-gnu-emacs@gnu.org
http://lists.gnu.org/mailman/listinfo/help-gnu-emacs

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2006-04-21 13:17 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <mailman.535.1145369538.9609.help-gnu-emacs@gnu.org>
2006-04-18 18:13 ` Run an external program on the file visited in current buffer and open a new buffer with results Alan Mackenzie
2006-04-19 16:01   ` Mathias Dahl
2006-04-21  7:48     ` Annamalai Gurusami
2006-04-21 13:17   ` Hadron Quark
2006-04-18 18:22 ` Peter Tury
2006-04-18 14:12 Suttles, Andrew
2006-04-18 14:21 ` Kevin Rodgers

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.