unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* automate command after saving
@ 2015-11-19  9:56 Martin Kaffanke
  2015-11-19 14:17 ` Phillip Lord
  0 siblings, 1 reply; 5+ messages in thread
From: Martin Kaffanke @ 2015-11-19  9:56 UTC (permalink / raw)
  To: help-gnu-emacs

Hi there,

I'd like to run a command after saving, but just if I switch it on.

Following scenario:

When I write on  an org file, before printing I look at the pdf version
created by

pandoc -t latex -o filename-without-org-but-with.pdf filename.org

And then I switch to emacs to do corrections.

Now I'd like to automatically run pandoc again when I switch back to
evince (which automaticaly loads the pdf new when changed on disk).

How could a make a switch for emacs to automatically run pandoc again
after C-x C-s?

Thanks for your Ideas,
Martin

-- 
Mag. Martin Kaffanke
http://www.kaffanke.at
+43 650 4514224




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

* Re: automate command after saving
  2015-11-19  9:56 automate command after saving Martin Kaffanke
@ 2015-11-19 14:17 ` Phillip Lord
  2015-11-19 15:10   ` Marcin Borkowski
                     ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Phillip Lord @ 2015-11-19 14:17 UTC (permalink / raw)
  To: Martin Kaffanke; +Cc: help-gnu-emacs



You could do this using after-save-hook. So, something like

(add-hook 'after-save-hook
          'pandoc-hook)

(defun pandoc-hook()
  (compile "pandoc -t latex...."))

Personally, I do this outside Emacs, though, with this little bash
script.

#!/bin/bash
make $*
while inotifywait -r -e MODIFY --exclude ".#*" --exclude ".*~" .
do
    make $*;
done;

Cheap, cheerful but effective.

Phil

Martin Kaffanke <martin@kaffanke.at> writes:

> Hi there,
>
> I'd like to run a command after saving, but just if I switch it on.
>
> Following scenario:
>
> When I write on  an org file, before printing I look at the pdf version
> created by
>
> pandoc -t latex -o filename-without-org-but-with.pdf filename.org
>
> And then I switch to emacs to do corrections.
>
> Now I'd like to automatically run pandoc again when I switch back to
> evince (which automaticaly loads the pdf new when changed on disk).
>
> How could a make a switch for emacs to automatically run pandoc again
> after C-x C-s?
>
> Thanks for your Ideas,
> Martin

-- 
Phillip Lord,                           Phone: +44 (0) 191 208 7827
Lecturer in Bioinformatics,             Email: phillip.lord@newcastle.ac.uk
School of Computing Science,            http://homepages.cs.ncl.ac.uk/phillip.lord
Room 914 Claremont Tower,               skype: russet_apples
Newcastle University,                   twitter: phillord
NE1 7RU                                 



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

* Re: automate command after saving
  2015-11-19 14:17 ` Phillip Lord
@ 2015-11-19 15:10   ` Marcin Borkowski
  2015-11-19 19:03   ` Martin Kaffanke
       [not found]   ` <mailman.250.1447959815.31583.help-gnu-emacs@gnu.org>
  2 siblings, 0 replies; 5+ messages in thread
From: Marcin Borkowski @ 2015-11-19 15:10 UTC (permalink / raw)
  To: Phillip Lord; +Cc: help-gnu-emacs, Martin Kaffanke


On 2015-11-19, at 15:17, Phillip Lord <phillip.lord@newcastle.ac.uk> wrote:

> You could do this using after-save-hook. So, something like
>
> (add-hook 'after-save-hook
>           'pandoc-hook)
>
> (defun pandoc-hook()
>   (compile "pandoc -t latex...."))
>
> Personally, I do this outside Emacs, though, with this little bash
> script.

You could also use focus-out-hook to run the compilation each time you
/leave Emacs/.

Hth,

-- 
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Faculty of Mathematics and Computer Science
Adam Mickiewicz University



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

* Re: automate command after saving
  2015-11-19 14:17 ` Phillip Lord
  2015-11-19 15:10   ` Marcin Borkowski
@ 2015-11-19 19:03   ` Martin Kaffanke
       [not found]   ` <mailman.250.1447959815.31583.help-gnu-emacs@gnu.org>
  2 siblings, 0 replies; 5+ messages in thread
From: Martin Kaffanke @ 2015-11-19 19:03 UTC (permalink / raw)
  To: Phillip Lord; +Cc: help-gnu-emacs


Phillip Lord writes:

> You could do this using after-save-hook. So, something like
>
> (add-hook 'after-save-hook
>           'pandoc-hook)
>
> (defun pandoc-hook()
>   (compile "pandoc -t latex...."))

That sounds interesting, but is this a 'per buffer hook' or something?
Maybe I find out a possibility to automatically create the pathes too
and do a trigger-hook so I can switch it on or of on a specific buffer.
But this seems to be a good start.

Your bash script is also interesting, but as this is mosty required on
org-attachments, the path is not really human guessable, so its better
to have it out of emacs.

Thanks,
Martin



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

* Re: automate command after saving
       [not found]   ` <mailman.250.1447959815.31583.help-gnu-emacs@gnu.org>
@ 2015-11-20 14:00     ` Joost Kremers
  0 siblings, 0 replies; 5+ messages in thread
From: Joost Kremers @ 2015-11-20 14:00 UTC (permalink / raw)
  To: help-gnu-emacs

Martin Kaffanke wrote:
>
> Phillip Lord writes:
>
>> You could do this using after-save-hook. So, something like
>>
>> (add-hook 'after-save-hook
>>           'pandoc-hook)
>>
>> (defun pandoc-hook()
>>   (compile "pandoc -t latex...."))
>
> That sounds interesting, but is this a 'per buffer hook' or something?

Hooks can usually have a global and a buffer-local value. See the
documentation for `add-hook' for details.


-- 
Joost Kremers                                   joostkremers@fastmail.fm
Selbst in die Unterwelt dringt durch Spalten Licht
EN:SiS(9)


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

end of thread, other threads:[~2015-11-20 14:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-19  9:56 automate command after saving Martin Kaffanke
2015-11-19 14:17 ` Phillip Lord
2015-11-19 15:10   ` Marcin Borkowski
2015-11-19 19:03   ` Martin Kaffanke
     [not found]   ` <mailman.250.1447959815.31583.help-gnu-emacs@gnu.org>
2015-11-20 14:00     ` Joost Kremers

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).