all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: torys.anderson@gmail.com (Tory S. Anderson)
To: Rusi <rustompmody@gmail.com>
Cc: help-gnu-emacs@gnu.org
Subject: Re: If arg, open in new frame
Date: Thu, 11 Sep 2014 06:58:51 -0400	[thread overview]
Message-ID: <87ppf28luc.fsf@gmail.com> (raw)
In-Reply-To: <de791977-885e-46ba-9719-2db2460c53dd@googlegroups.com> (Rusi's message of "Wed, 10 Sep 2014 20:28:09 -0700 (PDT)")

Almost perfect! Thanks! One case is missed in your code: if buffer does not yet exist, it cannot be opened in a new frame. I tried this to no avail: 

(defun go-or-make-agenda (&optional new-frame)
  (interactive "P")
  (let ((buffer "\*Org Agenda\*"))
    (if (get-buffer buffer)
	(if new-frame
	    (switch-to-buffer-other-frame buffer)
	  (switch-to-buffer buffer))
      (if new-frame
	  (switch-to-buffer-other-frame org-agenda-list) ;; not a buffer
	(org-agenda-list)))))

With all this switch-to-buffer redundancy, what I'd REALLY like to do is conditionally bind the function to a variable based on (if new-frame) but I'll make that a new thread. 

So now,  How can I run org-agenda-list in a new frame if buffer does not exist? 

Thanks


Rusi <rustompmody@gmail.com> writes:

> On Wednesday, September 10, 2014 5:32:30 PM UTC+5:30, Tory S. Anderson wrote:
>> So, that half answered my question: thanks for showing me how to use optional args. My function is now:
>
>> (defun go-or-make-agenda (&optional new-frame) (interactive "P")
>>   (let ((buffer "\*Org Agenda\*"))
>>     (if (get-buffer buffer)
>> 	(switch-to-buffer buffer)
>>       (org-agenda-list))))
>
> Does this help?
>
> (defun go-or-make-agenda (&optional new-frame)
>   (interactive "P")
>   (let ((buffer "\*Org Agenda\*"))
>     (if (get-buffer buffer)
> 	(if new-frame
> 	    (switch-to-buffer-other-frame buffer)
> 	  (switch-to-buffer buffer))
>       (org-agenda-list))))



  reply	other threads:[~2014-09-11 10:58 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.8608.1410350561.1147.help-gnu-emacs@gnu.org>
2014-09-10 22:09 ` If arg, open in new frame Emanuel Berg
2014-09-11  3:28 ` Rusi
2014-09-11 10:58   ` Tory S. Anderson [this message]
2014-09-10 12:02 Tory S. Anderson
     [not found] <mailman.8567.1410299333.1147.help-gnu-emacs@gnu.org>
2014-09-09 22:44 ` Emanuel Berg
  -- strict thread matches above, loose matches on Subject: below --
2014-09-09 21:48 Tory S. Anderson

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

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

  git send-email \
    --in-reply-to=87ppf28luc.fsf@gmail.com \
    --to=torys.anderson@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    --cc=rustompmody@gmail.com \
    /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 external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.