[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[O] Changing capture frame/window behavior depending on source
From: |
Josiah Schwab |
Subject: |
[O] Changing capture frame/window behavior depending on source |
Date: |
Fri, 06 Dec 2013 21:52:32 -0800 |
User-agent: |
mu4e 0.9.9.5; emacs 24.3.1 |
Hi All,
I have some bookmarks in chrome which trigger capture via org-protocol.
I would like the windowing behavior of capture to be different depending
where it is invoked.
For example, when I invoke capture from my bookmark, I want the frame
that the capture used to vanish after C-c C-c or C-c C-k. I achieved
this via the following code.
(defun jws/org-protocol-capture-p ()
"Return true if this capture was initiated via org-protocol."
(equal (buffer-name (org-capture-get :original-buffer)) " *server*"))
(defun jws/org-capture-after-finalize ()
"Delete frame if capture was initiated via org-protocol"
(if (jws/org-protocol-capture-p) (delete-frame)))
(add-hook 'org-capture-after-finalize-hook 'jws/org-capture-after-finalize)
When I invoke the capture from my bookmark, I also want capture to be
the only window in the frame. I can make all captures act that way by
setting (add-hook 'org-capture-mode-hook 'delete-other-windows)
But when I tried to have this part be source dependent with
(defun jws/org-capture-initialize ()
(if (jws/org-protocol-capture-p) 'delete-other-windows))
(add-hook 'org-capture-mode-hook 'jws/org-capture-initialize)
it still gave me a frame with two windows, for reasons I don't
understand. I stepped through the code with edebug and confirmed that
jws/org-protocol-capture-p was evaluating to true.
Or perhaps there is there something more suitable for my hook than
'delete-other-windows? Has anyone successfully done something similar?
Best,
Josiah
- [O] Changing capture frame/window behavior depending on source,
Josiah Schwab <=