Re: [gedit-list] save current file



On Wed, 2008-12-24 at 16:30 -0700, Doug McNutt wrote:
> At 17:29 -0500 12/24/08, John Kitzmiller wrote:
> >
> >For an External Tool, how to save/overwrite the current file with same
> >name before running command on it?
> >
> >e.g. (You may have seen this before...):
> >
> >#!/bin/sh
> >---> what goes in here to save current file? <---
> >mpost "$GEDIT_CURRENT_DOCUMENT_NAME"
> >
> >The result I seek is what happens with the LaTeX plugin: when a .tex
> >file is modified, it is saved prior to processing.
> 
> It is possible to select  "current document" to be sent to the tool 
> using the edit tools option at the bottom of the tools window but you 
> can get the same result with appropriate comment lines in the tool 
> itself right under the #! line.
> 
> Have a look at a tool in $HOME/,genome2/gedit/tools/ to see the format.
> 
> For a really big document that might be painful but you should be 
> able to read standard in and just rewrite 
> $GEDIT_CURRENT_DOCUMENT_NAME.
> 
> But using the path variable would remove the possibility that your 
> tool is using the wrong directory - did it read a shell startup 
> script for you?
> 
> 

Thanks for reply Doug.

I think the answer to your last question is yes. If I have a correct .mp
file and use the tool I have defined...

#!/bin/sh
mpost "$GEDIT_CURRENT_DOCUMENT_NAME"

...a proper postscript file is created which I can view (evince or
gsview, etc). But if I make changes to the source file (in gedit) the
tab is starred (as expected) but not saved (obviously). The tool then
runs, as far as I can tell--and I can experiment more--on the last saved
version (which may be a ~filename somewhere?) and no changes are made to
the postscript file.

The output must be set to 'Display in Bottom Pane' as that output is the
metapost runtime message (error or otherwise), not the postscript file
for viewing.

I had tried the settings in the tool window before posting my query, but
none seem to save the current text code file before running it through
mpost. What I think I may need is a bash command to save the current
file, then run the saved file through mpost? I tried some, like cp, mv,
but I am floundering. Also went to trying regular expressions to pass a
ctr+s, but more floundering and that seems like the wrong approach
anyway.

Methinks my immediate question boils down to this: how (best) to use
External Tool to save current file? I must be missing something obvious.

--J





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]