emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Carsten Dominik" <dominik@science.uva.nl>
To: Adam Spiers <orgmode@adamspiers.org>, emacs-orgmode@gnu.org
Subject: Re: inserting files within remember templates
Date: Sat, 24 Nov 2007 17:57:58 +0100	[thread overview]
Message-ID: <acf852aa0711240857i6968709btddbdae63f3c84549@mail.gmail.com> (raw)
In-Reply-To: <20071124145227.GB30662@atlantic.linksys.moosehall>


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

Nice!

Thanks you very much, Adam...

- Carsten

On 11/24/07, Adam Spiers <orgmode@adamspiers.org> wrote:
>
> On Wed, Nov 07, 2007 at 09:42:55AM +0100, Carsten Dominik wrote:
> > On 6 Nov 2007, at 11:39 PM, Adam Spiers wrote:
> > > On Tue, Nov 06, 2007 at 04:36:47PM +0000, Adam Spiers wrote:
> > > > This could easily be accomplished if remember templates allowed
> > > > syntax such as
> > > >
> > > > ,------
> > > > | * %T
> > > > | %(shell-command-to-string "grep 'last full'
> /proc/acpi/battery/BAT0/info")
> > > > `------
> > >
> > > OK, it turns out that this was easy to implement, and I think the
> > > patch is small enough that it could be accepted even though I haven't
> > > got around to sending back the copyright assignment form yet (sorry -
> > > this *will* happen at some point!)
> >
> > I'll take this patch, thanks.
>
> [snipped]
>
> > >There might need to be some debate about how to handle read errors in
> > >the case of invalid syntax.  Or perhaps some people already have
> > >`%(...)' within their remember templates for some really unusual
> > >reason, and don't want it interpreted?  Though in the latter case, one
> > >could argue that it might make sense to require `%' always to be
> > >escaped as `%%' if used literally, to be on the safe side.
>
> Here's a better version.  Differences:
>
>   - Supports insertion of the contents of another file via
> %[/path/to/file]
>
>   - Embeds any errors within the template, making it clearer that an
>     error occurred, and also exactly which bit of the template caused
>     it.  This also lets the user manually correct the error and finish
>     their remembering workflow before having to go back and fix the
>     template, which is much more in keeping with the "remember this
>     quick before I forget!" spirit of remember itself.
>
>   - Patches texinfo file.
>
>   - Respects Carsten's apparent preference for having indent-tabs-mode
>     set (though this may make the below patch's indentation look
>     strange due to the hard tabs).
>
> diff -r 09b1470ac170 org.el
> --- a/org.el    Wed Oct 31 09:46:35 2007 +0000
> +++ b/org.el    Sat Nov 24 14:39:51 2007 +0000
> @@ -12806,6 +12806,30 @@ to be run from that hook to fucntion pro
>           (replace-match
>            (or (eval (intern (concat "v-" (match-string 1)))) "")
>            t t))
> +       ;; %[] Insert contents of a file.
> +       (goto-char (point-min))
> +       (while (re-search-forward "%\\[\\(.+\\)\\]" nil t)
> +         (let ((start (match-beginning 0))
> +               (end (match-end 0))
> +               (filename (expand-file-name (match-string 1))))
> +           (goto-char start)
> +           (delete-region start end)
> +           (condition-case error
> +               (insert-file-contents filename)
> +             (error (insert (format "%%![Couldn't insert %s: %s]"
> +                                    filename error))))))
> +       ;; %() embedded elisp
> +       (goto-char (point-min))
> +       (while (re-search-forward "%\\((.+)\\)" nil t)
> +         (goto-char (match-beginning 0))
> +         (let ((template-start (point)))
> +           (forward-char 1)
> +           (let ((result
> +                  (condition-case error
> +                      (eval (read (current-buffer)))
> +                    (error (format "%%![Error: %s]" error)))))
> +             (delete-region template-start (point))
> +             (insert result))))
>         ;; From the property list
>         (when plist-p
>           (goto-char (point-min))
> diff -r 09b1470ac170 org.texi
> --- a/org.texi  Wed Oct 31 09:46:35 2007 +0000
> +++ b/org.texi  Sat Nov 24 14:39:51 2007 +0000
> @@ -4378,6 +4378,8 @@ insertion of content:
> %^g         @r{prompt for tags, with completion on tags in target file.}
> %^G         @r{prompt for tags, with completion all tags in all agenda
> files.}
> %:keyword   @r{specific information for certain link types, see below}
> +%[pathname] @r{insert the contents of the file given by @code{pathname}}
> +%(sexp)     @r{evaluate elisp @code{(sexp)} and replace with the result}
> @end example
>
> @noindent
>
>
> _______________________________________________
> Emacs-orgmode mailing list
> Remember: use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode
>

[-- Attachment #1.2: Type: text/html, Size: 7332 bytes --]

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

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

  reply	other threads:[~2007-11-24 16:58 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-05 18:17 inserting files within remember templates Adam Spiers
2007-11-05 18:27 ` Eddward DeVilla
2007-11-06  5:41 ` Carsten Dominik
2007-11-06 16:36   ` Adam Spiers
2007-11-06 22:39     ` Adam Spiers
2007-11-07  2:47       ` Bastien
2007-11-07  8:43         ` Carsten Dominik
2007-11-07  8:42       ` Carsten Dominik
2007-11-24 14:52         ` Adam Spiers
2007-11-24 16:57           ` Carsten Dominik [this message]
2007-12-09 12:19           ` Adam Spiers
2007-11-07  2:37     ` Bastien
2007-11-07  9:58       ` Adam Spiers
2007-11-07 12:46         ` Bastien
2007-11-07 12:50           ` Adam Spiers
2007-11-07 14:39             ` Bastien
2007-11-07 14:36               ` Adam Spiers
2007-11-08  4:03                 ` Bastien
  -- strict thread matches above, loose matches on Subject: below --
2007-10-13 14:52 Using org-remember to include stored link? Georg C. F. Greve
2007-10-14  2:33 ` Bastien
2007-10-14  5:11   ` Georg C. F. Greve
2007-10-14  6:14 ` Carsten Dominik
2007-10-14 12:05   ` Georg C. F. Greve
2007-10-14 14:03     ` Bastien
2007-10-14 13:48       ` Georg C. F. Greve
2007-10-14 15:33     ` Carsten Dominik
2007-11-08 11:32       ` Georg C. F. Greve
2007-11-08 13:09         ` Bastien
2007-12-08 20:08           ` inserting files within remember templates Adam Spiers

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=acf852aa0711240857i6968709btddbdae63f3c84549@mail.gmail.com \
    --to=dominik@science.uva.nl \
    --cc=emacs-orgmode@gnu.org \
    --cc=orgmode@adamspiers.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).