emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: David Maus <dmaus@ictsoc.de>
To: Johan Friis <mail@alterecco.net>
Cc: emacs-orgmode@gnu.org
Subject: Re: [PATCH] org-capture - using `file' as template
Date: Wed, 14 Jul 2010 09:08:36 +0200	[thread overview]
Message-ID: <87hbk27d6z.wl%dmaus@ictsoc.de> (raw)
In-Reply-To: <87bpaavlpo.fsf@alterecco.net>


[-- Attachment #1.1: Type: text/plain, Size: 1666 bytes --]

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.... dmjena@jabber.org
Email..... dmaus@ictsoc.de

[-- Attachment #1.2: Type: application/pgp-signature, Size: 230 bytes --]

[-- Attachment #2: Type: text/plain, Size: 201 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

  reply	other threads:[~2010-07-14  7:09 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-14  2:30 [PATCH] org-capture - using `file' as template Johan Friis
2010-07-14  7:08 ` David Maus [this message]
2010-07-14 13:54   ` Johan Friis
2010-07-14  9:04 ` Carsten Dominik
2010-07-14 18:58   ` Johan Friis
2010-07-14 20:01     ` Carsten Dominik

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=87hbk27d6z.wl%dmaus@ictsoc.de \
    --to=dmaus@ictsoc.de \
    --cc=emacs-orgmode@gnu.org \
    --cc=mail@alterecco.net \
    /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).