[Top][All Lists]

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

Possible to conditionally bind variable?

From: Tory S. Anderson
Subject: Possible to conditionally bind variable?
Date: Thu, 11 Sep 2014 07:11:41 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)

I have several redundancies in the following code: 

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

I'd like to do something like the following, to chop out much of the 
switch-to-[other-]-buffer cruft:

(defun go-or-make-agenda (&optional new-frame)
  (interactive "P")
  (let ((buffer "\*Org Agenda\*")
        (some-other-buffer "*scratch*")
        (my-switch-function (if new-frame ;; is there some way to do this?
    (if (get-buffer buffer)
        (my-switch-function buffer)
        (my-switch-function some-other-buffer))))) 

 I'm not sure this is possible (short of the rather daunting,
 but I have trust that in the awesomeness of Lisp it just might be.

- Tory 

reply via email to

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