unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Emanuel Berg <embe8573@student.uu.se>
To: help-gnu-emacs@gnu.org
Subject: Re: If arg, open in new frame
Date: Wed, 10 Sep 2014 00:44:20 +0200	[thread overview]
Message-ID: <87sik0wh17.fsf@debian.uxu> (raw)
In-Reply-To: mailman.8567.1410299333.1147.help-gnu-emacs@gnu.org

torys.anderson@gmail.com (Tory S. Anderson) writes:

> I have a function that checks for a buffer and either
> switches to it or creates it. I want it to optionally
> take an arg, and if an arg is supplied, open/find
> said buffer in a new frame. My elisp-fu is still
> young; can you help?
>
> Function:
>
> (defun go-or-make-agenda () (interactive)
>   (if (get-buffer "\*Org Agenda\*")
>       (switch-to-buffer "\*Org Agenda\*")
>     (org-agenda-list)))

Hint: As the data "\*Org Agenda\*" appears twice, put
that in a `let' and have it appear once, then use the
`let' binding all you want.

As for your question, I think you can solve the frame
stuff (I didn't exactly understand your motive but it
doesn't matter), but take a look below for an optional
(prefix) argument. Then just put it together.

(defun go-or-make-agenda (&optional new-frame)
  (interactive "P")
  (if new-frame (message "frame")
    (message "no frame") ))

;; from Elisp
(go-or-make-agenda)       ; no frame
(go-or-make-agenda nil)   ; no frame
(go-or-make-agenda t)     ; frame

;; interactively
M-x go-or-make-agenda RET     ; no frame
C-u M-x go-or-make-agenda RET ; frame

-- 
underground experts united


       reply	other threads:[~2014-09-09 22:44 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.8567.1410299333.1147.help-gnu-emacs@gnu.org>
2014-09-09 22:44 ` Emanuel Berg [this message]
     [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
2014-09-10 12:02 Tory S. Anderson
  -- 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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=87sik0wh17.fsf@debian.uxu \
    --to=embe8573@student.uu.se \
    --cc=help-gnu-emacs@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.
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).