From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: torys.anderson@gmail.com (Tory S. Anderson) Newsgroups: gmane.emacs.help Subject: Re: If arg, open in new frame Date: Thu, 11 Sep 2014 06:58:51 -0400 Message-ID: <87ppf28luc.fsf@gmail.com> References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1410433182 6764 80.91.229.3 (11 Sep 2014 10:59:42 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 11 Sep 2014 10:59:42 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: Rusi Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Sep 11 12:59:36 2014 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1XS25m-0000Pf-L8 for geh-help-gnu-emacs@m.gmane.org; Thu, 11 Sep 2014 12:59:10 +0200 Original-Received: from localhost ([::1]:36089 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XS25m-0007yp-AS for geh-help-gnu-emacs@m.gmane.org; Thu, 11 Sep 2014 06:59:10 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:35359) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XS25a-0007yZ-TB for help-gnu-emacs@gnu.org; Thu, 11 Sep 2014 06:59:00 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XS25W-0006OE-S0 for help-gnu-emacs@gnu.org; Thu, 11 Sep 2014 06:58:58 -0400 Original-Received: from mail-yk0-x229.google.com ([2607:f8b0:4002:c07::229]:53674) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XS25W-0006O3-OS for help-gnu-emacs@gnu.org; Thu, 11 Sep 2014 06:58:54 -0400 Original-Received: by mail-yk0-f169.google.com with SMTP id 20so2500693yks.14 for ; Thu, 11 Sep 2014 03:58:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-type; bh=Qpfk3Hqxqb5Gd+EAlR5g0de8oEzYd+DR3QRDPnd+U5M=; b=IU3Aav6zmoCugC1J3QO4R7VNo5V7eIeWBaXFcHpyhfnYL3A0O/a/k53qEO64O3Oz1h 4Wbi9Er4bTj0Mdd96IlUdepZCLsEoYVzlK6MtLSGXiMnXJzq01Hrs4CnOubEpgRQPuAu ZSGPtFZ+gcHJJUyJPw28H+86PfR5oQeODrvgaXwxf8jKhhpg5OJMdp7kAVtwWIsGzVy0 Ys6+zaY7K29FqaZivsk6fh6xlpDMVVBzHX7NWL7+sDZ8qnI4K0Vn8FRD+ZKuncMkM9Id J/tcv4ucYlq/ReO1dLhzSdn4udu7BOv5XemkBw1E5KB4Tfv6mlOeQ41tMH6+WL8eN8WY ZacA== X-Received: by 10.236.73.42 with SMTP id u30mr134697yhd.168.1410433134014; Thu, 11 Sep 2014 03:58:54 -0700 (PDT) Original-Received: from localhost.localdomain ([2601:0:a000:4a1:ee55:f9ff:feb5:5589]) by mx.google.com with ESMTPSA id k67sm200379yhq.17.2014.09.11.03.58.52 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 11 Sep 2014 03:58:52 -0700 (PDT) In-Reply-To: (Rusi's message of "Wed, 10 Sep 2014 20:28:09 -0700 (PDT)") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:4002:c07::229 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:99805 Archived-At: 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 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))))