emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [O] New feature: loop over siblings for some commands


From: David Maus
Subject: Re: [O] New feature: loop over siblings for some commands
Date: Tue, 19 Jul 2011 20:27:26 +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)

At Mon, 18 Jul 2011 10:32:11 +0200,
Bastien wrote:
>
> Dear all,
>
> from latest git repo:
>
>   (setq org-loop-over-siblings-within-active-region-p t)
>
> will allow you to run some commands on several siblings in
> the active region.
>
> For example:
>
> <start active region>
> * Item 1
> * Item 2
> * Item 3
> <end active region>
>
> Then `C-c C-s' (org-schedule) will ask for a schedule date
> for each of the item in the active region.  See the commit
> log for more details:
>
>   
> http://orgmode.org/w/?p=org-mode.git;a=commit;h=366254217ac6faea20a5d43fae065bd028806eab
>
> I'm interested in allowing this for org-todo as well, but I
> would first like some feedback on the current feature and its
> scope wrt actual needs.

The macro suffers from leaking: It let-binds symbols like beg, end
etc. that might be present in ,@body. The let-bound symbols will
shadow body's.

Minimal example:

,----
| (defmacro leak-it-baby (&rest body)
|   `(let ((foobar 0))
|      (while (< foobar 10)
|        (setq foobar (1+ foobar))
|        ,@body)))
|
| (let ((foobar 9))
|   (leak-it-baby
|    (setq foobar 11)
|    (print foobar)))
|
| ELISP> (macroexpand '(leak-it-baby (setq foobar 11)))
| (let
|     ((foobar 0))
|   (while
|       (< foobar 10)
|     (setq foobar
|         (1+ foobar))
|     (setq foobar 11)))
|
| ELISP>
`----

The whole problem of leaking macros is discussed in Peter Seibel's
"Practical Common Lisp", Chapter 8

http://www.gigamonkeys.com/book/macros-defining-your-own.html

The solution is a heavy use of C-h f gensym RET for all symboles
needed in the macro to create fresh, unique und uninterned symbols.

If no one jumps on a fix for this I will provide one till next
sunday. Always wanted to do some lecker macro programming :)

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

Attachment: pgpjnoPBrs_Go.pgp
Description: PGP signature


reply via email to

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