emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Josiah Schwab <jschwab@gmail.com>
To: emacs-org list <emacs-orgmode@gnu.org>
Subject: Changing capture frame/window behavior depending on source
Date: Fri, 06 Dec 2013 21:52:32 -0800	[thread overview]
Message-ID: <87wqjhus0v.fsf@gmail.com> (raw)

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

             reply	other threads:[~2013-12-07  5:52 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-07  5:52 Josiah Schwab [this message]
2013-12-17  0:56 ` Changing capture frame/window behavior depending on source Josiah Schwab

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87wqjhus0v.fsf@gmail.com \
    --to=jschwab@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).