emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* org-remember-AFTER-finalize-hook , anyone?
@ 2010-01-30 16:54 Stefano Zacchiroli
  2010-01-30 18:23 ` Ryan Thompson
  0 siblings, 1 reply; 5+ messages in thread
From: Stefano Zacchiroli @ 2010-01-30 16:54 UTC (permalink / raw)
  To: emacs-orgmode

Short summary: I'd like to have a org-remember-after-finalize-hook which
is invoked *after* remember-finalize in function org-remember-finalize.
Does it exist and I've missed it or there is a work-around for its lack?

In more detail, my use case is that I invoke remember from mutt (more on
this when I've solved this last remaining issue) to store org notes
which have backlink to the originating mail. To that end, I use
org-protocol with emacsclient, invoking the following pseudo command:

  emacsclient -t 'org-protocol:/remember:/m/mutt:$mid/mail/$note_body'

It works fine. However, after having hit C-c C-c , only the org-mode
*window* goes away, whereas the whole emacsclient instance stays around,
usually with the scratch buffer. Given that I've invoked it only to
execute org-protocol, it would be nice for the whole emacsclient
instance to go away at the end.

Having the requested hook I can hack a command which close the whole
frame.

Additionally I wonder: isn't this a bug in org-protocol? Can't it just
use the whole frame and make it go away at the end?

TIA,
Cheers.

-- 
Stefano Zacchiroli -o- PhD in Computer Science \ PostDoc @ Univ. Paris 7
zack@{upsilon.cc,pps.jussieu.fr,debian.org} -<>- http://upsilon.cc/zack/
Dietro un grande uomo c'è ..|  .  |. Et ne m'en veux pas si je te tutoie
sempre uno zaino ...........| ..: |.... Je dis tu à tous ceux que j'aime

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

* Re: org-remember-AFTER-finalize-hook , anyone?
  2010-01-30 16:54 org-remember-AFTER-finalize-hook , anyone? Stefano Zacchiroli
@ 2010-01-30 18:23 ` Ryan Thompson
  2010-01-30 23:45   ` Stefano Zacchiroli
  0 siblings, 1 reply; 5+ messages in thread
From: Ryan Thompson @ 2010-01-30 18:23 UTC (permalink / raw)
  To: Stefano Zacchiroli; +Cc: emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 1972 bytes --]

Ooh, I solved this problem before, but then I accidentally deleted all my
files. I have a backup, but I haven't gotten around to restoring everything
yet. I'll get back to you later.

-Ryan

On Sat, Jan 30, 2010 at 8:54 AM, Stefano Zacchiroli <zack@upsilon.cc> wrote:

> Short summary: I'd like to have a org-remember-after-finalize-hook which
> is invoked *after* remember-finalize in function org-remember-finalize.
> Does it exist and I've missed it or there is a work-around for its lack?
>
> In more detail, my use case is that I invoke remember from mutt (more on
> this when I've solved this last remaining issue) to store org notes
> which have backlink to the originating mail. To that end, I use
> org-protocol with emacsclient, invoking the following pseudo command:
>
>  emacsclient -t 'org-protocol:/remember:/m/mutt:$mid/mail/$note_body'
>
> It works fine. However, after having hit C-c C-c , only the org-mode
> *window* goes away, whereas the whole emacsclient instance stays around,
> usually with the scratch buffer. Given that I've invoked it only to
> execute org-protocol, it would be nice for the whole emacsclient
> instance to go away at the end.
>
> Having the requested hook I can hack a command which close the whole
> frame.
>
> Additionally I wonder: isn't this a bug in org-protocol? Can't it just
> use the whole frame and make it go away at the end?
>
> TIA,
> Cheers.
>
> --
> Stefano Zacchiroli -o- PhD in Computer Science \ PostDoc @ Univ. Paris 7
> zack@{upsilon.cc,pps.jussieu.fr,debian.org} -<>- http://upsilon.cc/zack/
> Dietro un grande uomo c'è ..|  .  |. Et ne m'en veux pas si je te tutoie
> sempre uno zaino ...........| ..: |.... Je dis tu à tous ceux que j'aime
>
>
> _______________________________________________
> 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
>

[-- Attachment #1.2: Type: text/html, Size: 2622 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] 5+ messages in thread

* Re: org-remember-AFTER-finalize-hook , anyone?
  2010-01-30 18:23 ` Ryan Thompson
@ 2010-01-30 23:45   ` Stefano Zacchiroli
  2010-03-28 21:12     ` Ryan Thompson
  0 siblings, 1 reply; 5+ messages in thread
From: Stefano Zacchiroli @ 2010-01-30 23:45 UTC (permalink / raw)
  To: emacs-orgmode

On Sat, Jan 30, 2010 at 10:23:20AM -0800, Ryan Thompson wrote:
> Ooh, I solved this problem before, but then I accidentally deleted all my
> files. I have a backup, but I haven't gotten around to restoring everything
> yet. I'll get back to you later.

In the meantime, I've implemented a workaround, based on the following
idea:

  (add-hook 'org-remember-mode-hook 'delete-other-windows)
  (defadvice org-remember-finalize (after delete-frame-at-end activate)
    "Delete frame at remember finalization"
    (delete-frame))
  (defadvice org-remember-kill (after delete-frame-at-end activate)
    "Delete frame at remember abort"
    (delete-frame))

It works properly, but it assumes that org-remember is invoked only
externally via org-protocol (i.e. if I invoke org-remember by hand I
risk my frame).

So I've conceived the following horror to constraint the effect to
org-protocol invocation (yes, with a serious race condition involved):

  (add-hook 'org-remember-mode-hook 'delete-other-windows)
  (setq my-org-protocol-flag nil)
  (defadvice org-remember-finalize (after delete-frame-at-end activate)
    "Delete frame at remember finalization"
    (progn
      (if my-org-protocol-flag (delete-frame))
      (setq my-org-protocol-flag nil)))
  (defadvice org-remember-kill (after delete-frame-at-end activate)
    "Delete frame at remember abort"
    (progn
      (if my-org-protocol-flag (delete-frame))
      (setq my-org-protocol-flag nil)))
  (defadvice org-protocol-remember (before set-org-protocol-flag activate)
    (setq my-org-protocol-flag t))

Any suggestions on how to achieve the same result in a more proper way
will be appreciated ...

Cheers.

-- 
Stefano Zacchiroli -o- PhD in Computer Science \ PostDoc @ Univ. Paris 7
zack@{upsilon.cc,pps.jussieu.fr,debian.org} -<>- http://upsilon.cc/zack/
Dietro un grande uomo c'è ..|  .  |. Et ne m'en veux pas si je te tutoie
sempre uno zaino ...........| ..: |.... Je dis tu à tous ceux que j'aime

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

* Re: org-remember-AFTER-finalize-hook , anyone?
  2010-01-30 23:45   ` Stefano Zacchiroli
@ 2010-03-28 21:12     ` Ryan Thompson
  2010-03-28 21:13       ` Ryan Thompson
  0 siblings, 1 reply; 5+ messages in thread
From: Ryan Thompson @ 2010-03-28 21:12 UTC (permalink / raw)
  To: Stefano Zacchiroli; +Cc: emacs-orgmode

Ok, I finally recreated my setup. There's some bug in emacs daemon
where if no X frame currently exist and you use emacsclient -e
'(some-function-that-creates-a-frame)', then the frame that is created
will immediately be deleted when the command terminates. (Note: this
is only a problem with an emacs that wasn't started originally with an
X frame, i.e. either emacs -nw or emacs --daemon) To fix this, the key
is to use emacsclient -c to create a new frame, and then use -e to
eval some code that creates the frame you actually want, and then
deletes the first frame. Here's my script:

#!/bin/sh

exec emacsclient -c -e '
(let ((sacframe (selected-frame))) ; the frame create by the -c
options is the "sacrificial frame"
  (make-frame-invisible sacframe t)
  (remember-other-frame)
  (delete-frame sacframe t))
'

Put that in a script in your $PATH somewhere and add a keybinding
using e.g. xbindkeys. Personally, I use Windows Key + R.


On Sat, Jan 30, 2010 at 4:45 PM, Stefano Zacchiroli <zack@upsilon.cc> wrote:
> On Sat, Jan 30, 2010 at 10:23:20AM -0800, Ryan Thompson wrote:
>> Ooh, I solved this problem before, but then I accidentally deleted all my
>> files. I have a backup, but I haven't gotten around to restoring everything
>> yet. I'll get back to you later.
>
> In the meantime, I've implemented a workaround, based on the following
> idea:
>
>  (add-hook 'org-remember-mode-hook 'delete-other-windows)
>  (defadvice org-remember-finalize (after delete-frame-at-end activate)
>    "Delete frame at remember finalization"
>    (delete-frame))
>  (defadvice org-remember-kill (after delete-frame-at-end activate)
>    "Delete frame at remember abort"
>    (delete-frame))
>
> It works properly, but it assumes that org-remember is invoked only
> externally via org-protocol (i.e. if I invoke org-remember by hand I
> risk my frame).
>
> So I've conceived the following horror to constraint the effect to
> org-protocol invocation (yes, with a serious race condition involved):
>
>  (add-hook 'org-remember-mode-hook 'delete-other-windows)
>  (setq my-org-protocol-flag nil)
>  (defadvice org-remember-finalize (after delete-frame-at-end activate)
>    "Delete frame at remember finalization"
>    (progn
>      (if my-org-protocol-flag (delete-frame))
>      (setq my-org-protocol-flag nil)))
>  (defadvice org-remember-kill (after delete-frame-at-end activate)
>    "Delete frame at remember abort"
>    (progn
>      (if my-org-protocol-flag (delete-frame))
>      (setq my-org-protocol-flag nil)))
>  (defadvice org-protocol-remember (before set-org-protocol-flag activate)
>    (setq my-org-protocol-flag t))
>
> Any suggestions on how to achieve the same result in a more proper way
> will be appreciated ...
>
> Cheers.
>
> --
> Stefano Zacchiroli -o- PhD in Computer Science \ PostDoc @ Univ. Paris 7
> zack@{upsilon.cc,pps.jussieu.fr,debian.org} -<>- http://upsilon.cc/zack/
> Dietro un grande uomo c'è ..|  .  |. Et ne m'en veux pas si je te tutoie
> sempre uno zaino ...........| ..: |.... Je dis tu à tous ceux que j'aime
>
>
> _______________________________________________
> 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] 5+ messages in thread

* Re: org-remember-AFTER-finalize-hook , anyone?
  2010-03-28 21:12     ` Ryan Thompson
@ 2010-03-28 21:13       ` Ryan Thompson
  0 siblings, 0 replies; 5+ messages in thread
From: Ryan Thompson @ 2010-03-28 21:13 UTC (permalink / raw)
  To: Stefano Zacchiroli; +Cc: emacs-orgmode

Oh, I guess you're using org-protocol, so your're going to have to do
something a little different. But I hope my post gives you the idea of
how to do it.

On Sun, Mar 28, 2010 at 2:12 PM, Ryan Thompson <rct@thompsonclan.org> wrote:
> Ok, I finally recreated my setup. There's some bug in emacs daemon
> where if no X frame currently exist and you use emacsclient -e
> '(some-function-that-creates-a-frame)', then the frame that is created
> will immediately be deleted when the command terminates. (Note: this
> is only a problem with an emacs that wasn't started originally with an
> X frame, i.e. either emacs -nw or emacs --daemon) To fix this, the key
> is to use emacsclient -c to create a new frame, and then use -e to
> eval some code that creates the frame you actually want, and then
> deletes the first frame. Here's my script:
>
> #!/bin/sh
>
> exec emacsclient -c -e '
> (let ((sacframe (selected-frame))) ; the frame create by the -c
> options is the "sacrificial frame"
>  (make-frame-invisible sacframe t)
>  (remember-other-frame)
>  (delete-frame sacframe t))
> '
>
> Put that in a script in your $PATH somewhere and add a keybinding
> using e.g. xbindkeys. Personally, I use Windows Key + R.
>
>
> On Sat, Jan 30, 2010 at 4:45 PM, Stefano Zacchiroli <zack@upsilon.cc> wrote:
>> On Sat, Jan 30, 2010 at 10:23:20AM -0800, Ryan Thompson wrote:
>>> Ooh, I solved this problem before, but then I accidentally deleted all my
>>> files. I have a backup, but I haven't gotten around to restoring everything
>>> yet. I'll get back to you later.
>>
>> In the meantime, I've implemented a workaround, based on the following
>> idea:
>>
>>  (add-hook 'org-remember-mode-hook 'delete-other-windows)
>>  (defadvice org-remember-finalize (after delete-frame-at-end activate)
>>    "Delete frame at remember finalization"
>>    (delete-frame))
>>  (defadvice org-remember-kill (after delete-frame-at-end activate)
>>    "Delete frame at remember abort"
>>    (delete-frame))
>>
>> It works properly, but it assumes that org-remember is invoked only
>> externally via org-protocol (i.e. if I invoke org-remember by hand I
>> risk my frame).
>>
>> So I've conceived the following horror to constraint the effect to
>> org-protocol invocation (yes, with a serious race condition involved):
>>
>>  (add-hook 'org-remember-mode-hook 'delete-other-windows)
>>  (setq my-org-protocol-flag nil)
>>  (defadvice org-remember-finalize (after delete-frame-at-end activate)
>>    "Delete frame at remember finalization"
>>    (progn
>>      (if my-org-protocol-flag (delete-frame))
>>      (setq my-org-protocol-flag nil)))
>>  (defadvice org-remember-kill (after delete-frame-at-end activate)
>>    "Delete frame at remember abort"
>>    (progn
>>      (if my-org-protocol-flag (delete-frame))
>>      (setq my-org-protocol-flag nil)))
>>  (defadvice org-protocol-remember (before set-org-protocol-flag activate)
>>    (setq my-org-protocol-flag t))
>>
>> Any suggestions on how to achieve the same result in a more proper way
>> will be appreciated ...
>>
>> Cheers.
>>
>> --
>> Stefano Zacchiroli -o- PhD in Computer Science \ PostDoc @ Univ. Paris 7
>> zack@{upsilon.cc,pps.jussieu.fr,debian.org} -<>- http://upsilon.cc/zack/
>> Dietro un grande uomo c'è ..|  .  |. Et ne m'en veux pas si je te tutoie
>> sempre uno zaino ...........| ..: |.... Je dis tu à tous ceux que j'aime
>>
>>
>> _______________________________________________
>> 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] 5+ messages in thread

end of thread, other threads:[~2010-03-28 21:13 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-01-30 16:54 org-remember-AFTER-finalize-hook , anyone? Stefano Zacchiroli
2010-01-30 18:23 ` Ryan Thompson
2010-01-30 23:45   ` Stefano Zacchiroli
2010-03-28 21:12     ` Ryan Thompson
2010-03-28 21:13       ` Ryan Thompson

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).