help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: If arg, open in new frame


From: Emanuel Berg
Subject: Re: If arg, open in new frame
Date: Wed, 10 Sep 2014 00:44:20 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)

address@hidden (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 via email to

[Prev in Thread] Current Thread [Next in Thread]