emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Mike McLean <mike.mclean@pobox.com>
To: org mode <emacs-orgmode@gnu.org>
Subject: User Defined Functions in Agenda Views
Date: Sat, 21 Sep 2013 14:18:47 -0400	[thread overview]
Message-ID: <6F30E9CD-36ED-4281-BD6F-0D3B623393B9@pobox.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1863 bytes --]

Hello

I looked at the doc string for ~org-agenda-custom-commands~ and noticed that the you can use a user-defined function as a valid command type. I did not find anything in the documentation that describes how that user-defined function should work, what it should do, or how to write one. I looked at the code for other agenda types, such as ~tags-todo~ and ~occur-tree~ and have guessed at how to form one of these.

I can write documentation and samples if anyone want it (either to add to Org documentation or as a page on Worg), but want to ensure that I understand completely and correctly, first.

With that said, can those with far more knowledegble about Org code comment on my thoughts below.

The user defined function for an agenda view:
The Org agenda dispatch function will call a user-defined function with one parameter representing the ``match'' component from the agenda definition. In other words, ~(udf-test "Hello")~ in ~org-agenda-custom-commands~ will result in a function call of ~udf-test~ with an argument of "Hello".
The ~org-agenda-custom-commands~ varible does not requred a parameter and therefore the dispatcher does not require one. Define an user-defined wiht an optional argument: ~(defun udf-test (&optional org-match) "documentation…" <<code>>)~
The user defined function should prepared a buffer to write the agenda information to using ~org-agenda-prepare~
The user defined function should handle setting a unique buffer name for the cases where ~org-agenda-sticky~ has a value of ~t~
Honor the setting of ~org-agenda-overriding-header~ and insert that text into the agenda buffer
Insert into the buffer the desired contents, accounting for also setting text properties (translation: “Magic happens here”)
Call ~org-agenda-finalize~ and ~(setq buffer-read-only t)~

Does this cover the basics?

Mike


[-- Attachment #2: Type: text/html, Size: 2311 bytes --]

             reply	other threads:[~2013-09-21 18:19 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-21 18:18 Mike McLean [this message]
2013-09-22  9:03 ` User Defined Functions in Agenda Views Suvayu Ali

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.orgmode.org/

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

  git send-email \
    --in-reply-to=6F30E9CD-36ED-4281-BD6F-0D3B623393B9@pobox.com \
    --to=mike.mclean@pobox.com \
    --cc=emacs-orgmode@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.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

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