* Clean capture from command line?
@ 2010-11-16 20:43 Allen S. Rout
2010-11-16 22:26 ` Eric S Fraga
2010-11-17 18:24 ` tycho garen
0 siblings, 2 replies; 9+ messages in thread
From: Allen S. Rout @ 2010-11-16 20:43 UTC (permalink / raw)
To: emacs-orgmode
I'm one of the legion gradually slipping more and more of my day-to-day
process into org-mode. (Thanks, Carsten!)
One of the things I'd like to be able to do is capture a new TODO from a
command line. e.g.
shell$ capture "Fred wants a new database VM, 60G"
and maybe eventually something obnoxious with e.g. zenity, so that a key
chord popped up a text dialog which would just seamlessly get fed to
org-capture. Basically, I want to make the notation and just keep
sailing. Of course, I've got the relevant org files open in an emacs on
another desktop: miles and miles away. :) The obvious solution
shell$ emacsclient -c -e "(org-capture)"
(and maybe a '-t', to keep it in the tty)
has a problem: when I finish the capture, I'm left with the session, and
worse, when I try to close the emacsclient, (C-x #) it tells me "No
server buffers remain to edit", and I have to M-x delete-frame.
Harshing my buzz, definitely.
A gmane search on 'capture command line' in this group didn't seem to
help much. Am I thinking about the problem the wrong way? How do
you-all do that sort of ad-hoc capture?
- Allen S. Rout
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Clean capture from command line?
2010-11-16 20:43 Clean capture from command line? Allen S. Rout
@ 2010-11-16 22:26 ` Eric S Fraga
2010-11-16 23:35 ` Friedrich Delgado
2010-11-17 18:24 ` tycho garen
1 sibling, 1 reply; 9+ messages in thread
From: Eric S Fraga @ 2010-11-16 22:26 UTC (permalink / raw)
To: Allen S. Rout; +Cc: emacs-orgmode
asr@ufl.edu (Allen S. Rout) writes:
> I'm one of the legion gradually slipping more and more of my day-to-day
> process into org-mode. (Thanks, Carsten!)
>
> One of the things I'd like to be able to do is capture a new TODO from a
> command line. e.g.
>
> shell$ capture "Fred wants a new database VM, 60G"
>
> and maybe eventually something obnoxious with e.g. zenity, so that a key
> chord popped up a text dialog which would just seamlessly get fed to
> org-capture. Basically, I want to make the notation and just keep
> sailing. Of course, I've got the relevant org files open in an emacs on
> another desktop: miles and miles away. :) The obvious solution
>
> shell$ emacsclient -c -e "(org-capture)"
>
> (and maybe a '-t', to keep it in the tty)
>
> has a problem: when I finish the capture, I'm left with the session, and
> worse, when I try to close the emacsclient, (C-x #) it tells me "No
> server buffers remain to edit", and I have to M-x delete-frame.
> Harshing my buzz, definitely.
I tried the following:
: $ emacsclient -t -e "(progn (org-capture) (delete-frame))"
which /sort of/ works: it brings up capture, allows me to type in
various bits of the capture template (like headline and tags, if
requested) but then quits immediately (and deletes the frame) when org
is supposed to give me a chance to add to the entry I have created.
So this is a halfway point to a solution to your problem maybe?
--
: Eric S Fraga (GnuPG: 0xC89193D8FFFCF67D) in Emacs 23.2.1
: using Org-mode version 7.3 (release_7.3.78.g9b811)
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Clean capture from command line?
2010-11-16 22:26 ` Eric S Fraga
@ 2010-11-16 23:35 ` Friedrich Delgado
2010-11-18 17:32 ` Allen S. Rout
0 siblings, 1 reply; 9+ messages in thread
From: Friedrich Delgado @ 2010-11-16 23:35 UTC (permalink / raw)
To: emacs-orgmode
I use zsh and I already use this:
,----[ ~/bin/uriescapepwd.pl ]
#!/usr/bin/perl -w
use URI::Escape qw/ uri_escape uri_escape_utf8 /;
use Cwd qw/getcwd abs_path/;
$pwd = abs_path(getcwd);
print uri_escape_utf8($pwd);
`----
,----[ .zshrc snippet ]
# bind <f9>n to org-store-link
bindkey -s "\e[20~n" 'emacsclient org-protocol://store-link://file:`uriescapepwd.pl`\n'
`----
(I stole this from somewhere, can't remember where, possibly this
list.)
it should be easy to just do
,----
# bind <f9>t to org-remember
bindkey -s "\e[20~t" 'emacsclient org-protocol://remember://file:`uriescapepwd.pl`\n'
`----
(I'm old school.)
or even
,----
# bind <f9>t to org-remember
bindkey -s "\e[20~t" 'emacsclient org-protocol://capture://file:`uriescapepwd.pl`\n'
`----
I didn't test this, since I very rarely even use the first binding.
I'm pretty sure this must be possible with bash and other shells as
well.
Of course this leaves you in the emacsclient again, so you probably
want to follow Eric's hints on top of that.
Eric S Fraga schrieb:
> asr@ufl.edu (Allen S. Rout) writes:
> > One of the things I'd like to be able to do is capture a new TODO from a
> > command line. e.g.
> >
> > shell$ capture "Fred wants a new database VM, 60G"
> >
> > and maybe eventually something obnoxious with e.g. zenity, so that a key
> > chord popped up a text dialog which would just seamlessly get fed to
> > org-capture. Basically, I want to make the notation and just keep
> > sailing. Of course, I've got the relevant org files open in an emacs on
> > another desktop: miles and miles away. :) The obvious solution
> >
> > shell$ emacsclient -c -e "(org-capture)"
> >
> > (and maybe a '-t', to keep it in the tty)
> >
> > has a problem: when I finish the capture, I'm left with the session, and
> > worse, when I try to close the emacsclient, (C-x #) it tells me "No
> > server buffers remain to edit", and I have to M-x delete-frame.
> > Harshing my buzz, definitely.
>
> I tried the following:
>
> : $ emacsclient -t -e "(progn (org-capture) (delete-frame))"
>
> which /sort of/ works: it brings up capture, allows me to type in
> various bits of the capture template (like headline and tags, if
> requested) but then quits immediately (and deletes the frame) when org
> is supposed to give me a chance to add to the entry I have created.
>
> So this is a halfway point to a solution to your problem maybe?
>
---Zitatende---
--
Friedrich Delgado <friedel@nomaden.org>
TauPan on Ircnet and Freenode ;)
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Clean capture from command line?
2010-11-16 23:35 ` Friedrich Delgado
@ 2010-11-18 17:32 ` Allen S. Rout
2010-11-27 6:56 ` [Accepted] " Carsten Dominik
0 siblings, 1 reply; 9+ messages in thread
From: Allen S. Rout @ 2010-11-18 17:32 UTC (permalink / raw)
To: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 1307 bytes --]
Friedrich Delgado <friedel@nomaden.org> writes:
> I use zsh and I already use this:
>
> ,----[ ~/bin/uriescapepwd.pl ]
> #!/usr/bin/perl -w
> use URI::Escape qw/ uri_escape uri_escape_utf8 /;
> use Cwd qw/getcwd abs_path/;
> $pwd = abs_path(getcwd);
> print uri_escape_utf8($pwd);
> `----
Woot, one step.
Then I also did a quick filter.
---
use URI::Escape qw/ uri_escape uri_escape_utf8 /;
use Cwd qw/getcwd abs_path/;
print uri_escape_utf8(<>);
---
At that point, I could do:
---
emacsclient -c org-protocol://capture:/I/file:`~/bin/uriescapepwd`/`~/bin/uriescapepwd`/`/usr/bin/zenity --entry --text="New TODO" |~/bin/uriescape`
----
The 'I' selects template, in which I'm using :immediate-finish. That's
one.
For the 'Close the client frame' purpose, I applied the attached patch,
and then I could, in my own myorg.el file:
-----
( defun asr-org-capture-finalize ()
"If we set the correct property in the capture template, then delete frame."
( if (org-capture-get :asr-delete-frame-on-finalize)
(delete-frame)
)
)
(add-hook 'org-capture-after-finalize-hook 'asr-org-capture-finalize )
-----
which lets me define a capture template with property
:asr-delete-frame-on-finalize 1
and then use that template.
Thanks, Eric and Friedrich...
- Allen S. Rout
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Add post-finalize hook --]
[-- Type: text/x-diff, Size: 1104 bytes --]
From 2086fe4be30d5383b9db4d5db91da6b03357c128 Mon Sep 17 00:00:00 2001
From: Allen S. Rout <asr@ufl.edu>
Date: Wed, 17 Nov 2010 12:52:02 -0500
Subject: [PATCH 3/3] Add post-finalize hook
---
lisp/org-capture.el | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/lisp/org-capture.el b/lisp/org-capture.el
index 2abe5c7..5d2f8d3 100644
--- a/lisp/org-capture.el
+++ b/lisp/org-capture.el
@@ -313,6 +313,12 @@ The remember buffer is still current when this hook runs."
:group 'org-capture
:type 'hook)
+(defcustom org-capture-after-finalize-hook nil
+ "Hook that is run right after a capture process is finalized.
+ Suitable for window cleanup"
+ :group 'org-capture
+ :type 'hook)
+
;;; The property list for keeping information about the capture process
(defvar org-capture-plist nil
@@ -548,6 +554,8 @@ bypassed."
;; Restore the window configuration before capture
(set-window-configuration return-wconf))
+
+ (run-hooks 'org-capture-after-finalize-hook)
(when abort-note
(cond
((equal abort-note 'clean)
--
1.7.0.4
[-- Attachment #3: Type: text/plain, Size: 201 bytes --]
_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [Accepted] Re: Clean capture from command line?
2010-11-18 17:32 ` Allen S. Rout
@ 2010-11-27 6:56 ` Carsten Dominik
0 siblings, 0 replies; 9+ messages in thread
From: Carsten Dominik @ 2010-11-27 6:56 UTC (permalink / raw)
To: emacs-orgmode
Patch 390 (http://patchwork.newartisans.com/patch/390/) is now "Accepted".
Maintainer comment: No comment
This relates to the following submission:
http://mid.gmane.org/%3C874obebkqi.fsf%40ufl.edu%3E
Here is the original message containing the patch:
> Content-Type: text/plain; charset="utf-8"
> MIME-Version: 1.0
> Content-Transfer-Encoding: 7bit
> Subject: [Orgmode] Re: Clean capture from command line?
> Date: Thu, 18 Nov 2010 22:32:53 -0000
> From: Allen S. Rout <asr@ufl.edu>
> X-Patchwork-Id: 390
> Message-Id: <874obebkqi.fsf@ufl.edu>
> To: emacs-orgmode@gnu.org
>
> Friedrich Delgado <friedel@nomaden.org> writes:
>
> > I use zsh and I already use this:
> >
> > ,----[ ~/bin/uriescapepwd.pl ]
> > #!/usr/bin/perl -w
> > use URI::Escape qw/ uri_escape uri_escape_utf8 /;
> > use Cwd qw/getcwd abs_path/;
> > $pwd = abs_path(getcwd);
> > print uri_escape_utf8($pwd);
> > `----
>
> Woot, one step.
>
> Then I also did a quick filter.
>
> ---
> use URI::Escape qw/ uri_escape uri_escape_utf8 /;
> use Cwd qw/getcwd abs_path/;
>
> print uri_escape_utf8(<>);
> ---
>
> At that point, I could do:
>
> ---
>
> emacsclient -c org-protocol://capture:/I/file:`~/bin/uriescapepwd`/`~/bin/uriescapepwd`/`/usr/bin/zenity --entry --text="New TODO" |~/bin/uriescape`
>
> ----
>
> The 'I' selects template, in which I'm using :immediate-finish. That's
> one.
>
> For the 'Close the client frame' purpose, I applied the attached patch,
> and then I could, in my own myorg.el file:
>
> -----
>
> ( defun asr-org-capture-finalize ()
> "If we set the correct property in the capture template, then delete frame."
> ( if (org-capture-get :asr-delete-frame-on-finalize)
> (delete-frame)
> )
> )
>
>
> (add-hook 'org-capture-after-finalize-hook 'asr-org-capture-finalize )
>
> -----
>
>
> which lets me define a capture template with property
>
> :asr-delete-frame-on-finalize 1
>
> and then use that template.
>
> Thanks, Eric and Friedrich...
>
>
> - Allen S. Rout
>
> >From 2086fe4be30d5383b9db4d5db91da6b03357c128 Mon Sep 17 00:00:00 2001
> From: Allen S. Rout <asr@ufl.edu>
> Date: Wed, 17 Nov 2010 12:52:02 -0500
> Subject: [PATCH 3/3] Add post-finalize hook
>
> ---
> lisp/org-capture.el | 8 ++++++++
> 1 files changed, 8 insertions(+), 0 deletions(-)
>
> diff --git a/lisp/org-capture.el b/lisp/org-capture.el
> index 2abe5c7..5d2f8d3 100644
> --- a/lisp/org-capture.el
> +++ b/lisp/org-capture.el
> @@ -313,6 +313,12 @@ The remember buffer is still current when this hook runs."
> :group 'org-capture
> :type 'hook)
>
> +(defcustom org-capture-after-finalize-hook nil
> + "Hook that is run right after a capture process is finalized.
> + Suitable for window cleanup"
> + :group 'org-capture
> + :type 'hook)
> +
> ;;; The property list for keeping information about the capture process
>
> (defvar org-capture-plist nil
> @@ -548,6 +554,8 @@ bypassed."
>
> ;; Restore the window configuration before capture
> (set-window-configuration return-wconf))
> +
> + (run-hooks 'org-capture-after-finalize-hook)
> (when abort-note
> (cond
> ((equal abort-note 'clean)
> --
> 1.7.0.4
>
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Clean capture from command line?
2010-11-16 20:43 Clean capture from command line? Allen S. Rout
2010-11-16 22:26 ` Eric S Fraga
@ 2010-11-17 18:24 ` tycho garen
2010-11-17 19:11 ` Eric S Fraga
1 sibling, 1 reply; 9+ messages in thread
From: tycho garen @ 2010-11-17 18:24 UTC (permalink / raw)
To: emacs-orgmode
[-- Attachment #1.1: Type: text/plain, Size: 1449 bytes --]
> One of the things I'd like to be able to do is capture a new TODO from a
> command line. e.g.
I use the following code that I got from Jack Moffit
(http://www.metajack.im), that does more or less what you're looking
for, I think. Add the following block to your org configs.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defadvice capture-finalize (after delete-capture-frame activate)
"Advise capture-finalize to close the frame if it is the capture frame"
(if (equal "capture" (frame-parameter nil 'name))
(delete-frame)))
(defadvice capture-destroy (after delete-capture-frame activate)
"Advise capture-destroy to close the frame if it is the rememeber frame"
(if (equal "capture" (frame-parameter nil 'name))
(delete-frame)))
(defun make-capture-frame ()
"Create a new frame and run org-capture."
(interactive)
(make-frame '((name . "capture")))
(select-frame-by-name "capture")
(delete-other-windows)
(org-capture)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Then call emacs as follows:
emacsclient -n -e '(make-capture-frame)'
Even better than calling from the command line in my experience is
triggering directly from your window manager, or something like
quicksliver if you use OS X...
I hope this is a start....
--
tycho(ish) @
garen@tychoish.com
http://www.tychoish.com/
http://www.cyborginstitute.com/
"don't get it right, get it written" -- james thurber
[-- Attachment #1.2: Type: application/pgp-signature, Size: 198 bytes --]
[-- Attachment #2: Type: text/plain, Size: 201 bytes --]
_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Clean capture from command line?
2010-11-17 18:24 ` tycho garen
@ 2010-11-17 19:11 ` Eric S Fraga
2010-11-18 2:18 ` Matt Lundin
0 siblings, 1 reply; 9+ messages in thread
From: Eric S Fraga @ 2010-11-17 19:11 UTC (permalink / raw)
To: tycho garen; +Cc: emacs-orgmode
tycho garen <garen@tychoish.com> writes:
>> One of the things I'd like to be able to do is capture a new TODO from a
>> command line. e.g.
>
> I use the following code that I got from Jack Moffit
> (http://www.metajack.im), that does more or less what you're looking
> for, I think. Add the following block to your org configs.
>
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>
> (defadvice capture-finalize (after delete-capture-frame activate)
> "Advise capture-finalize to close the frame if it is the capture frame"
> (if (equal "capture" (frame-parameter nil 'name))
> (delete-frame)))
>
> (defadvice capture-destroy (after delete-capture-frame activate)
> "Advise capture-destroy to close the frame if it is the rememeber frame"
> (if (equal "capture" (frame-parameter nil 'name))
> (delete-frame)))
>
> (defun make-capture-frame ()
> "Create a new frame and run org-capture."
> (interactive)
> (make-frame '((name . "capture")))
> (select-frame-by-name "capture")
> (delete-other-windows)
> (org-capture)
> )
>
>
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>
> Then call emacs as follows:
>
> emacsclient -n -e '(make-capture-frame)'
Doesn't work for me, for some strange reason.
I think you may have forgotten to say that the advices have to be
activated? If so, I assume this would be done by:
--8<---------------cut here---------------start------------->8---
(ad-activate 'capture-finalize)
(ad-activate 'capture-destroy)
--8<---------------cut here---------------end--------------->8---
But, in any case, this doesn't seem to make any difference in my case.
The capture process itself works. I get my menu of templates just fine.
Org captures the information when it should, i.e. if I finish normally
(C-c C-c), and ignores it if I abort (C-c C-k). In either case, the
frame, named "capture", remains.
Hitting my "delete-frame" button (the Windows menu key to the right of
my spacebar -- had to use these keys for something) works just fine so
the problem is not with the delete frame function.
Any suggestions? There's no error of any form that I can see.
--
: Eric S Fraga (GnuPG: 0xC89193D8FFFCF67D) in Emacs 23.2.1
: using Org-mode version 7.3 (release_7.3.86.gb3d6f)
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Clean capture from command line?
2010-11-17 19:11 ` Eric S Fraga
@ 2010-11-18 2:18 ` Matt Lundin
2010-11-18 7:20 ` Eric S Fraga
0 siblings, 1 reply; 9+ messages in thread
From: Matt Lundin @ 2010-11-18 2:18 UTC (permalink / raw)
To: Eric S Fraga; +Cc: emacs-orgmode
Eric S Fraga <ucecesf@ucl.ac.uk> writes:
> tycho garen <garen@tychoish.com> writes:
>
>>> One of the things I'd like to be able to do is capture a new TODO from a
>>> command line. e.g.
>>
>> I use the following code that I got from Jack Moffit
>> (http://www.metajack.im), that does more or less what you're looking
>> for, I think. Add the following block to your org configs.
>>
>> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>>
>> (defadvice capture-finalize (after delete-capture-frame activate)
>> "Advise capture-finalize to close the frame if it is the capture frame"
>> (if (equal "capture" (frame-parameter nil 'name))
>> (delete-frame)))
>>
>> (defadvice capture-destroy (after delete-capture-frame activate)
>> "Advise capture-destroy to close the frame if it is the rememeber frame"
>> (if (equal "capture" (frame-parameter nil 'name))
>> (delete-frame)))
>>
>> (defun make-capture-frame ()
>> "Create a new frame and run org-capture."
>> (interactive)
>> (make-frame '((name . "capture")))
>> (select-frame-by-name "capture")
>> (delete-other-windows)
>> (org-capture)
>> )
>>
>>
>> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>>
>> Then call emacs as follows:
>>
>> emacsclient -n -e '(make-capture-frame)'
>
> Doesn't work for me, for some strange reason.
>
> I think you may have forgotten to say that the advices have to be
> activated? If so, I assume this would be done by:
>
> (ad-activate 'capture-finalize)
> (ad-activate 'capture-destroy)
>
> But, in any case, this doesn't seem to make any difference in my case.
>
Yes, that is not the problem. The advice is already activated in the
definition itself (see the "activate" parameter).
> The capture process itself works. I get my menu of templates just fine.
> Org captures the information when it should, i.e. if I finish normally
> (C-c C-c), and ignores it if I abort (C-c C-k). In either case, the
> frame, named "capture", remains.
> Hitting my "delete-frame" button (the Windows menu key to the right of
> my spacebar -- had to use these keys for something) works just fine so
> the problem is not with the delete frame function.
>
> Any suggestions? There's no error of any form that I can see.
The problem is that the functions capture-finalize and capture-destroy
do not exist. I imagine the original code was designed for remember mode
(which does have the functions remember-destroy and remember-finalize).
The relevant function in org-capture.el, I believe, is
org-capture-finalize. I think the following defadvice should work:
--8<---------------cut here---------------start------------->8---
(defadvice org-capture-finalize (after delete-capture-frame activate)
"Advise capture-finalize to close the frame if it is the capture frame"
(if (equal "capture" (frame-parameter nil 'name))
(delete-frame)))
--8<---------------cut here---------------end--------------->8---
Best,
Matt
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Clean capture from command line?
2010-11-18 2:18 ` Matt Lundin
@ 2010-11-18 7:20 ` Eric S Fraga
0 siblings, 0 replies; 9+ messages in thread
From: Eric S Fraga @ 2010-11-18 7:20 UTC (permalink / raw)
To: Matt Lundin; +Cc: emacs-orgmode
Matt Lundin <mdl@imapmail.org> writes:
[...]
> The problem is that the functions capture-finalize and capture-destroy
> do not exist. I imagine the original code was designed for remember mode
> (which does have the functions remember-destroy and remember-finalize).
>
> The relevant function in org-capture.el, I believe, is
> org-capture-finalize. I think the following defadvice should work:
>
> (defadvice org-capture-finalize (after delete-capture-frame activate)
> "Advise capture-finalize to close the frame if it is the capture frame"
> (if (equal "capture" (frame-parameter nil 'name))
> (delete-frame)))
>
> Best,
> Matt
Ah ha! Yes, this works perfectly fine. Thanks!
--
: Eric S Fraga (GnuPG: 0xC89193D8FFFCF67D) in Emacs 23.2.1
: using Org-mode version 7.3 (release_7.3.89.g97f4c)
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2010-12-01 5:05 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-16 20:43 Clean capture from command line? Allen S. Rout
2010-11-16 22:26 ` Eric S Fraga
2010-11-16 23:35 ` Friedrich Delgado
2010-11-18 17:32 ` Allen S. Rout
2010-11-27 6:56 ` [Accepted] " Carsten Dominik
2010-11-17 18:24 ` tycho garen
2010-11-17 19:11 ` Eric S Fraga
2010-11-18 2:18 ` Matt Lundin
2010-11-18 7:20 ` Eric S Fraga
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
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).