all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Suttles, Andrew" <andrew.suttles@analexcleveland.com>
Subject: Run an external program on the file visited in current buffer and open a new buffer with results
Date: Tue, 18 Apr 2006 10:12:13 -0400	[thread overview]
Message-ID: <0D0D1C0745AFFC48BEFB3B6B803EAEE906693A@cratos.analexcleveland.com> (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

             reply	other threads:[~2006-04-18 14:12 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-04-18 14:12 Suttles, Andrew [this message]
2006-04-18 14:21 ` Run an external program on the file visited in current buffer and open a new buffer with results Kevin Rodgers
     [not found] <mailman.535.1145369538.9609.help-gnu-emacs@gnu.org>
2006-04-18 18:13 ` 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0D0D1C0745AFFC48BEFB3B6B803EAEE906693A@cratos.analexcleveland.com \
    --to=andrew.suttles@analexcleveland.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.