emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [Orgmode] [PATCH] org-capture - using `file' as template


From: David Maus
Subject: Re: [Orgmode] [PATCH] org-capture - using `file' as template
Date: Wed, 14 Jul 2010 09:08:36 +0200
User-agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (Gojō) APEL/10.8 Emacs/23.2 (i486-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO)

Johan Friis wrote:

>Setting up capture to use templates from file in the latest git seemed
>to cause some errors. I looked into it and wrote this small patch. It
>could probably use some love, seeing as I am quite new to org-mode,
>elisp and emacs in general.

Welcome aboard!

>The error I was getting was related to testing (string-match ...) on
>a list. The fix is to check if txt is a list before doing the test. In
>addition I updated the customize interface to use `file' instead of
>`file-contents'. This seems to be the current way of doing things.

Yep, I can reproduce the error.

Some comments on the proposed fix:

Using (not (listp txt)) works but is not exactly what we want to
check.  To avoid string-match failing txt must be a string.  Obviously
a string is not a list but "not a list" is not necessarily a string.

(when (or (not txt) (stringp txt))
 (when (or (not txt) (not (string-match "\\S-" txt))))
 ...)

If we need to make sure txt is a string before calling string-match,
we can put the check in front of string-match.

(when (or (not txt) (and (stringp txt) (not (string-match "\\S-" txt))))
 ...)

We can do this because the Lisp interpreter leaves the `and' as soon
as one of it's arguments is nil.  I.e. (not (string-match "\\S-" txt))
is not evaluated if (stringp txt) returns nil.

>Please note: This is my first time posting here. Please let me know if
>there are some rules to follow that I missed. And thanks for a great
>piece of software :)

Current rules are documented here:

http://orgmode.org/worg/org-contribute.php

HTH,
  -- David
--
OpenPGP... 0x99ADB83B5A4478E6
Jabber.... address@hidden
Email..... address@hidden

Attachment: pgpLXj4Qt3pe6.pgp
Description: PGP signature


reply via email to

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