From mboxrd@z Thu Jan  1 00:00:00 1970
From: Bastien <bzg@gnu.org>
Subject: Re: Agenda restrict to buffer
Date: Thu, 12 Jul 2012 10:15:32 +0200
Message-ID: <87bojl1jkr.fsf@gnu.org>
References: <CAF_E5JbMwWC4qV0TcnUJfYRodXGo4r=m5GzuEmeGOJJXNP-DpQ@mail.gmail.com>
Mime-Version: 1.0
Content-Type: text/plain
Return-path: <emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org>
Received: from eggs.gnu.org ([208.118.235.92]:35026)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <bastienguerry@googlemail.com>) id 1SpEY9-0007Mg-Q8
	for emacs-orgmode@gnu.org; Thu, 12 Jul 2012 04:15:07 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <bastienguerry@googlemail.com>) id 1SpEY3-0007qH-2b
	for emacs-orgmode@gnu.org; Thu, 12 Jul 2012 04:15:01 -0400
Received: from mail-we0-f169.google.com ([74.125.82.169]:34818)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <bastienguerry@googlemail.com>) id 1SpEY2-0007qB-Rr
	for emacs-orgmode@gnu.org; Thu, 12 Jul 2012 04:14:55 -0400
Received: by weys10 with SMTP id s10so388981wey.0
	for <emacs-orgmode@gnu.org>; Thu, 12 Jul 2012 01:14:54 -0700 (PDT)
In-Reply-To: <CAF_E5JbMwWC4qV0TcnUJfYRodXGo4r=m5GzuEmeGOJJXNP-DpQ@mail.gmail.com>
	(andrea crotti's message of "Wed, 11 Jul 2012 11:23:21 +0100")
List-Id: "General discussions about Org-mode." <emacs-orgmode.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/emacs-orgmode>,
	<mailto:emacs-orgmode-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/emacs-orgmode>
List-Post: <mailto:emacs-orgmode@gnu.org>
List-Help: <mailto:emacs-orgmode-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/emacs-orgmode>,
	<mailto:emacs-orgmode-request@gnu.org?subject=subscribe>
Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org
Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org
To: andrea crotti <andrea.crotti.0@gmail.com>
Cc: emacs-orgmode@gnu.org

Hi Andrea,

andrea crotti <andrea.crotti.0@gmail.com> writes:

> I never quite understood how to pass arguments to org-agenda without
> using it interactively..
> I want a simple thing, a command that shows the agenda with the TODO
> entries from a given file
>
> So supposing the buffer "projects.org" is open I tried this:
>
> (defun my-org-agenda ()
>   (interactive)
>    (switch-to-buffer (get-buffer "projects.org"))
>    (org-agenda :arg 'agenda :restriction '<))

(The `org-agenda' arguments are not lispy keywords arguments, 
which are currently discouraged in Emacs Lisp.)

> which complains for
> Wrong number of arguments: (lambda (&optional arg keys restriction)
> "Dispatch agenda commands to collect entries to the agenda buffer.
>
> Any suggestions?

(defun my-org-agenda-command ()
  (interactive)
  (org-agenda-set-restriction-lock 'file)
  (org-agenda nil "%"))

Note that you need to be in your .org file for this to work, so this
isn't really suited for a global keybinding, only for org-mode-map.

HTH,

-- 
 Bastien