emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Changing capture frame/window behavior depending on source
@ 2013-12-07  5:52 Josiah Schwab
  2013-12-17  0:56 ` Josiah Schwab
  0 siblings, 1 reply; 2+ messages in thread
From: Josiah Schwab @ 2013-12-07  5:52 UTC (permalink / raw)
  To: emacs-org list

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

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

end of thread, other threads:[~2013-12-17  0:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-07  5:52 Changing capture frame/window behavior depending on source Josiah Schwab
2013-12-17  0:56 ` Josiah Schwab

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