Re: [O] Handling errors in command line exporting of agenda?
On Fri, Aug 5, 2011 at 6:34 PM, suvayu ali fatkasuvayu+li...@gmail.com wrote: Hi John, On Sat, Aug 6, 2011 at 12:15 AM, John Hendy jw.he...@gmail.com wrote: 1) writing a script that could handle the failure and leave the current agenda exported text file if it happened Do you run into the same problem if you one the file before hand in read only mode? Something like this before the agenda command might work. (find-file-read-only FILENAME) How would I do this via the command line? Also, it's pulling from about 10 project files, so I'm not sure if I'd have to do this for every file or how that works since the org-batch-agenda command seems to be pulling from all of them. Perhaps there's some way to trigger emacs to think, Everything is read-only from here out? Thanks, John -- Suvayu Open source is the future. It sets us free.
Re: [O] Handling errors in command line exporting of agenda?
Hi John, On Mon, Aug 8, 2011 at 8:12 PM, John Hendy jw.he...@gmail.com wrote: Do you run into the same problem if you one the file before hand in read only mode? Something like this before the agenda command might work. (find-file-read-only FILENAME) How would I do this via the command line? Also, it's pulling from about 10 project files, so I'm not sure if I'd have to do this for every file or how that works since the org-batch-agenda command seems to be pulling from all of them. Perhaps there's some way to trigger emacs to think, Everything is read-only from here out? If you can use wildcards to specify your files, it might be possible by just one extra call to --eval. Something like this might work: emacs --batch -l ~/.emacs --eval '(find-file-read-only wildcard t)' \ --eval '(org-batch-agenda w)' ~/org/aux/agenda-export.txt find-file-read-only is an interactive compiled Lisp function in `files.el'. It is bound to C-x C-r. (find-file-read-only FILENAME optional WILDCARDS) Edit file FILENAME but don't allow changes. Like C-x C-f, but marks buffer as read-only. Use C-x C-q to permit editing. Hope this helps. -- Suvayu Open source is the future. It sets us free.
Re: [O] Handling errors in command line exporting of agenda?
On Mon, Aug 8, 2011 at 1:28 PM, suvayu ali fatkasuvayu+li...@gmail.com wrote: Hi John, On Mon, Aug 8, 2011 at 8:12 PM, John Hendy jw.he...@gmail.com wrote: Do you run into the same problem if you one the file before hand in read only mode? Something like this before the agenda command might work. (find-file-read-only FILENAME) How would I do this via the command line? Also, it's pulling from about 10 project files, so I'm not sure if I'd have to do this for every file or how that works since the org-batch-agenda command seems to be pulling from all of them. Perhaps there's some way to trigger emacs to think, Everything is read-only from here out? If you can use wildcards to specify your files, it might be possible by just one extra call to --eval. Something like this might work: emacs --batch -l ~/.emacs --eval '(find-file-read-only wildcard t)' \ --eval '(org-batch-agenda w)' ~/org/aux/agenda-export.txt Hmm. That might work. Everything I pull from is in ~/org... could the wildcard simply be ~/*.org? Forgive my emacs wildcard ignorance. I did some filename regexp magic *once* and it took me like two hours to learn the syntax just to turn camera directory names from 10#_MMDD to -MM-DD... Thanks again, John find-file-read-only is an interactive compiled Lisp function in `files.el'. It is bound to C-x C-r. (find-file-read-only FILENAME optional WILDCARDS) Edit file FILENAME but don't allow changes. Like C-x C-f, but marks buffer as read-only. Use C-x C-q to permit editing. Hope this helps. -- Suvayu Open source is the future. It sets us free.
Re: [O] Handling errors in command line exporting of agenda?
Hi John, On Mon, Aug 8, 2011 at 8:53 PM, John Hendy jw.he...@gmail.com wrote: If you can use wildcards to specify your files, it might be possible by just one extra call to --eval. Something like this might work: emacs --batch -l ~/.emacs --eval '(find-file-read-only wildcard t)' \ --eval '(org-batch-agenda w)' ~/org/aux/agenda-export.txt Hmm. That might work. Everything I pull from is in ~/org... could the wildcard simply be ~/*.org? Forgive my emacs wildcard ignorance. As far as I know, emacs accepts any wildcard that is valid in the shell. Since all your files are in ~/org, I would say try ~/org/*.org. The '~/org/' limits it to files within your org directory and the '*.org'[1] limits it to all files with a .org extension. I hope this helps. :) Footnotes: [1] The asterisk (*) stands for zero or more characters. You can find more details in `man bash` under the heading Pattern Matching. -- Suvayu Open source is the future. It sets us free.
Re: [O] Handling errors in command line exporting of agenda?
On Mon, Aug 8, 2011 at 1:59 PM, suvayu ali fatkasuvayu+li...@gmail.com wrote: Hi John, On Mon, Aug 8, 2011 at 8:53 PM, John Hendy jw.he...@gmail.com wrote: If you can use wildcards to specify your files, it might be possible by just one extra call to --eval. Something like this might work: emacs --batch -l ~/.emacs --eval '(find-file-read-only wildcard t)' \ --eval '(org-batch-agenda w)' ~/org/aux/agenda-export.txt Hmm. That might work. Everything I pull from is in ~/org... could the wildcard simply be ~/*.org? Forgive my emacs wildcard ignorance. As far as I know, emacs accepts any wildcard that is valid in the shell. Since all your files are in ~/org, I would say try ~/org/*.org. The '~/org/' limits it to files within your org directory and the '*.org'[1] limits it to all files with a .org extension. Bummer, this is not working: ,--- | emacs -batch -l ~/.emacs -eval '(find-file-read-only ~/org/*.org t)' \ | -eval '(org-batch-agenda e)' ~/org/aux/agenda-export.txt `--- Do you see anything wrong with that? I guess I wonder what that first part will do as perhaps the org-batch-agenda command is not necessarily going to follow suit with the read-only command. As in, does the first eval command affect anything that the org-batch-agenda command is going to do? Is it trying to do the equivalent of opening up all *.org files in read-only buffers and then run the agenda export? Thanks, John I hope this helps. :) Footnotes: [1] The asterisk (*) stands for zero or more characters. You can find more details in `man bash` under the heading Pattern Matching. -- Suvayu Open source is the future. It sets us free.
Re: [O] Handling errors in command line exporting of agenda?
Hi John, On Mon, Aug 8, 2011 at 9:48 PM, John Hendy jw.he...@gmail.com wrote: -batch -l ~/.emacs -eval Your problem is the long options are wrong. According to the manpages, there should be 2 hyphens. --eval and --batch. GL -- Suvayu Open source is the future. It sets us free.
Re: [O] Handling errors in command line exporting of agenda?
On Mon, Aug 8, 2011 at 3:22 PM, suvayu ali fatkasuvayu+li...@gmail.com wrote: Hi John, On Mon, Aug 8, 2011 at 9:48 PM, John Hendy jw.he...@gmail.com wrote: -batch -l ~/.emacs -eval Your problem is the long options are wrong. According to the manpages, there should be 2 hyphens. --eval and --batch. Well, that might be *a* problem, but it's not *the* problem. This produces the same results: ,--- | emacs --batch -l ~/.emacs --eval '(find-file-read-only ~/org/*.org t)' \ | --eval '(org-batch-agenda e)' ~/org/aux/agenda-export.txt `--- I get this from the command line: ,--- | ...~/org/rigor.org locked by jwhendy... (pid 10935): (s, q, p, ?)? `--- Which means that when executed from cron, it won't proceed. Also, good to know re. the man pages... however Worg is wrong, then. Directly from Worg [1]: ,-- | Let's say you generate an export from the command line, such as the following: | ,--- | | emacs -batch -l ~/.emacs -eval '(org-batch-agenda e)' | `--- | | or | | ,--- | |emacs -batch -l ~/.emacs -eval '(org-publish-all)' | `--- `-- The manual contains the same syntax. [2] [1] http://orgmode.org/worg/org-faq.html (see How can I preserve faces when I export an agenda from the command line?). [2] http://orgmode.org/manual/Extracting-agenda-information.html#Extracting-agenda-information Best regards, John GL -- Suvayu Open source is the future. It sets us free.
Re: [O] Handling errors in command line exporting of agenda?
suvayu ali fatkasuvayu+li...@gmail.com wrote: Hi John, On Mon, Aug 8, 2011 at 9:48 PM, John Hendy jw.he...@gmail.com wrote: -batch -l ~/.emacs -eval Your problem is the long options are wrong. According to the manpages, there should be 2 hyphens. --eval and --batch. Nope - emacs recognizes both (presumably the single hyphen ones are deprecated but they still work: emacs -batch -eval '(message foo)' works fine. Nick
Re: [O] Handling errors in command line exporting of agenda?
John Hendy jw.he...@gmail.com wrote: On Mon, Aug 8, 2011 at 1:59 PM, suvayu ali fatkasuvayu+li...@gmail.com wrote: Hi John, On Mon, Aug 8, 2011 at 8:53 PM, John Hendy jw.he...@gmail.com wrote: If you can use wildcards to specify your files, it might be possible by just one extra call to --eval. Something like this might work: emacs --batch -l ~/.emacs --eval '(find-file-read-only wildcard t)' \ --eval '(org-batch-agenda w)' ~/org/aux/agenda-export.txt Hmm. That might work. Everything I pull from is in ~/org... could the wildcard simply be ~/*.org? Forgive my emacs wildcard ignorance. As far as I know, emacs accepts any wildcard that is valid in the shell. Since all your files are in ~/org, I would say try ~/org/*.org. The '~/org/' limits it to files within your org directory and the '*.org'[1] limits it to all files with a .org extension. Not true - if you want wildcards expanded, you have to do it yourself. E.g. C-h f file-expand-wildcards , | file-expand-wildcards is a compiled Lisp function in `files.el'. | | (file-expand-wildcards PATTERN optional FULL) | | Expand wildcard pattern PATTERN. | This returns a list of file names which match the pattern. | | If PATTERN is written as an absolute file name, | the values are absolute also. | | If PATTERN is written as a relative file name, it is interpreted | relative to the current default directory, `default-directory'. | The file names returned are normally also relative to the current | default directory. However, if FULL is non-nil, they are absolute. ` Nick Bummer, this is not working: ,--- | emacs -batch -l ~/.emacs -eval '(find-file-read-only ~/org/*.org t)' \ | -eval '(org-batch-agenda e)' ~/org/aux/agenda-export.txt `--- Do you see anything wrong with that? I guess I wonder what that first part will do as perhaps the org-batch-agenda command is not necessarily going to follow suit with the read-only command. As in, does the first eval command affect anything that the org-batch-agenda command is going to do? Is it trying to do the equivalent of opening up all *.org files in read-only buffers and then run the agenda export? Thanks, John I hope this helps. :) Footnotes: [1] The asterisk (*) stands for zero or more characters. You can find more details in `man bash` under the heading Pattern Matching. -- Suvayu Open source is the future. It sets us free.
Re: [O] Handling errors in command line exporting of agenda?
On Mon, Aug 8, 2011 at 3:37 PM, Nick Dokos nicholas.do...@hp.com wrote: John Hendy jw.he...@gmail.com wrote: On Mon, Aug 8, 2011 at 1:59 PM, suvayu ali fatkasuvayu+li...@gmail.com wrote: Hi John, On Mon, Aug 8, 2011 at 8:53 PM, John Hendy jw.he...@gmail.com wrote: If you can use wildcards to specify your files, it might be possible by just one extra call to --eval. Something like this might work: emacs --batch -l ~/.emacs --eval '(find-file-read-only wildcard t)' \ --eval '(org-batch-agenda w)' ~/org/aux/agenda-export.txt Hmm. That might work. Everything I pull from is in ~/org... could the wildcard simply be ~/*.org? Forgive my emacs wildcard ignorance. As far as I know, emacs accepts any wildcard that is valid in the shell. Since all your files are in ~/org, I would say try ~/org/*.org. The '~/org/' limits it to files within your org directory and the '*.org'[1] limits it to all files with a .org extension. Not true - if you want wildcards expanded, you have to do it yourself. E.g. C-h f file-expand-wildcards , | file-expand-wildcards is a compiled Lisp function in `files.el'. | | (file-expand-wildcards PATTERN optional FULL) | | Expand wildcard pattern PATTERN. | This returns a list of file names which match the pattern. | | If PATTERN is written as an absolute file name, | the values are absolute also. | | If PATTERN is written as a relative file name, it is interpreted | relative to the current default directory, `default-directory'. | The file names returned are normally also relative to the current | default directory. However, if FULL is non-nil, they are absolute. ` Thanks. I tried with this based on this new information: ,--- | emacs --batch -l ~/.emacs --eval '(find-file-read-only \ | (file-expand-wildcards ~/org/*.org) t)' \ | --eval '(org-batch-agenda e)' ~/org/aux/agenda-export.txt `--- But I get this error: ,--- | Wrong type argument: stringp, (~/org/file1.org ~/org/file2.org... etc.) `--- I'm assuming something about how I used this is returning the wrong data type? As another option, if I run this and just respond with p when I'm asked about the lock (proceed), it works. I'm assuming that running agenda won't mess up an unsaved file, but that it just accesses it for todos and other information. If this is the case and an automatic proceed is safe... is there a way to pass some sort of --force option to emacs from the command line to override the lock when it's encountered? I'm running through cron and thus am not able to manually respond to the prompt. Thanks, John Nick Bummer, this is not working: ,--- | emacs -batch -l ~/.emacs -eval '(find-file-read-only ~/org/*.org t)' \ | -eval '(org-batch-agenda e)' ~/org/aux/agenda-export.txt `--- Do you see anything wrong with that? I guess I wonder what that first part will do as perhaps the org-batch-agenda command is not necessarily going to follow suit with the read-only command. As in, does the first eval command affect anything that the org-batch-agenda command is going to do? Is it trying to do the equivalent of opening up all *.org files in read-only buffers and then run the agenda export? Thanks, John I hope this helps. :) Footnotes: [1] The asterisk (*) stands for zero or more characters. You can find more details in `man bash` under the heading Pattern Matching. -- Suvayu Open source is the future. It sets us free.
Re: [O] Handling errors in command line exporting of agenda?
John Hendy jw.he...@gmail.com wrote: On Mon, Aug 8, 2011 at 3:37 PM, Nick Dokos nicholas.do...@hp.com wrote: John Hendy jw.he...@gmail.com wrote: On Mon, Aug 8, 2011 at 1:59 PM, suvayu ali fatkasuvayu+li...@gmail.com wrote: Hi John, On Mon, Aug 8, 2011 at 8:53 PM, John Hendy jw.he...@gmail.com wrote: If you can use wildcards to specify your files, it might be possible by just one extra call to --eval. Something like this might work: emacs --batch -l ~/.emacs --eval '(find-file-read-only wildcard t)' \ --eval '(org-batch-agenda w)' ~/org/aux/agenda-export.txt Hmm. That might work. Everything I pull from is in ~/org... could the wildcard simply be ~/*.org? Forgive my emacs wildcard ignorance. As far as I know, emacs accepts any wildcard that is valid in the shell. Since all your files are in ~/org, I would say try ~/org/*.org. The '~/org/' limits it to files within your org directory and the '*.org'[1] limits it to all files with a .org extension. Not true - if you want wildcards expanded, you have to do it yourself. E.g. C-h f file-expand-wildcards , | file-expand-wildcards is a compiled Lisp function in `files.el'. | | (file-expand-wildcards PATTERN optional FULL) | | Expand wildcard pattern PATTERN. | This returns a list of file names which match the pattern. | | If PATTERN is written as an absolute file name, | the values are absolute also. | | If PATTERN is written as a relative file name, it is interpreted | relative to the current default directory, `default-directory'. | The file names returned are normally also relative to the current | default directory. However, if FULL is non-nil, they are absolute. ` Thanks. I tried with this based on this new information: ,--- | emacs --batch -l ~/.emacs --eval '(find-file-read-only \ | (file-expand-wildcards ~/org/*.org) t)' \ | --eval '(org-batch-agenda e)' ~/org/aux/agenda-export.txt `--- But I get this error: ,--- | Wrong type argument: stringp, (~/org/file1.org ~/org/file2.org... etc.) `--- I'm assuming something about how I used this is returning the wrong data type? Yes: | This returns a list of file names which match the pattern. so you have to loop over the list. Nick PS. BTW, don't take this as an endorsement of the course you are following. I don't have the time to think much about it, and I don't have a better solution, but personally, I would try to find another method: my knee-jerk reaction was to use emacsclient if emacs is running (if not, fall back to emacs --batch: since no other instance is running, you wouldn't have to deal with locking in that case). But that may or may not work - I just don't know. As another option, if I run this and just respond with p when I'm asked about the lock (proceed), it works. I'm assuming that running agenda won't mess up an unsaved file, but that it just accesses it for todos and other information. If this is the case and an automatic proceed is safe... is there a way to pass some sort of --force option to emacs from the command line to override the lock when it's encountered? I'm running through cron and thus am not able to manually respond to the prompt. Thanks, John Nick Bummer, this is not working: ,--- | emacs -batch -l ~/.emacs -eval '(find-file-read-only ~/org/*.org t)' \ | -eval '(org-batch-agenda e)' ~/org/aux/agenda-export.txt `--- Do you see anything wrong with that? I guess I wonder what that first part will do as perhaps the org-batch-agenda command is not necessarily going to follow suit with the read-only command. As in, does the first eval command affect anything that the org-batch-agenda command is going to do? Is it trying to do the equivalent of opening up all *.org files in read-only buffers and then run the agenda export? Thanks, John I hope this helps. :) Footnotes: [1] The asterisk (*) stands for zero or more characters. You can find more details in `man bash` under the heading Pattern Matching. -- Suvayu Open source is the future. It sets us free.
Re: [O] Handling errors in command line exporting of agenda?
Hi Nick, On Mon, Aug 8, 2011 at 10:37 PM, Nick Dokos nicholas.do...@hp.com wrote: As far as I know, emacs accepts any wildcard that is valid in the shell. Since all your files are in ~/org, I would say try ~/org/*.org. The '~/org/' limits it to files within your org directory and the '*.org'[1] limits it to all files with a .org extension. Not true - if you want wildcards expanded, you have to do it yourself. E.g. C-h f file-expand-wildcards I should have been more precise. I meant to say in the context of the current function or other functions which _accept_ wildcards as valid arguments. Of course internally they use file-expand-wildcards, easily verified by looking at the source of find-file. :) -- Suvayu Open source is the future. It sets us free.
Re: [O] Handling errors in command line exporting of agenda?
suvayu ali fatkasuvayu+li...@gmail.com wrote: Hi Nick, On Mon, Aug 8, 2011 at 10:37 PM, Nick Dokos nicholas.do...@hp.com wrote: As far as I know, emacs accepts any wildcard that is valid in the shell. Since all your files are in ~/org, I would say try ~/org/*.org. The '~/org/' limits it to files within your org directory and the '*.org'[1] limits it to all files with a .org extension. Not true - if you want wildcards expanded, you have to do it yourself. E.g. C-h f file-expand-wildcards I should have been more precise. I meant to say in the context of the current function or other functions which _accept_ wildcards as valid arguments. Of course internally they use file-expand-wildcards, easily verified by looking at the source of find-file. :) No, you were precise enough, but I was too careless to see it (and of course *knew* that find-file does not expand wildcards, even though the last time I looked at the code or its doc was probably 20 years ago: I have an inherent bias to assume that things don't change after I learn about them :-) ). You are right about find-file and friends re wildcards. I don't know why this does not work: $ emacs --batch --eval '(progn (find-file-read-only ~/lib/org/*.org t) (org-batch-agenda t))' 2/dev/null Global list of TODO items of type: ALL Available with `N r': (0)ALL and nothing after it, but when I evaluate (org-batch-agenda t) in the running emacs, I get everything. Nick
Re: [O] Handling errors in command line exporting of agenda?
Hi John, On Sat, Aug 6, 2011 at 12:15 AM, John Hendy jw.he...@gmail.com wrote: 1) writing a script that could handle the failure and leave the current agenda exported text file if it happened Do you run into the same problem if you one the file before hand in read only mode? Something like this before the agenda command might work. (find-file-read-only FILENAME) -- Suvayu Open source is the future. It sets us free.
Re: [O] Handling errors in command line exporting of agenda?
On Sat, Aug 6, 2011 at 1:34 AM, suvayu ali fatkasuvayu+li...@gmail.com wrote: if you one the file if you open* the file Sorry for the typo. -- Suvayu Open source is the future. It sets us free.