emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: David Maus <dmaus@ictsoc.de>
To: Bastien <bzg@altern.org>
Cc: emacs-orgmode@gnu.org
Subject: Re: New feature: loop over siblings for some commands
Date: Tue, 19 Jul 2011 20:27:26 +0200	[thread overview]
Message-ID: <87zkkayvld.wl%dmaus@ictsoc.de> (raw)
In-Reply-To: <87aacchtv8.fsf@gnu.org>

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

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

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

  reply	other threads:[~2011-07-19 18:27 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-18  8:32 New feature: loop over siblings for some commands Bastien
2011-07-19 18:27 ` David Maus [this message]
2011-07-20 19:46   ` David Maus
2011-07-27 15:28     ` Bastien
2011-07-27 18:47       ` David Maus
2011-07-28  8:54         ` Bastien
2011-08-10  8:34           ` David Maus
2011-08-12  7:58             ` David Maus
2011-08-16 16:36               ` Bastien
2011-08-25  4:25                 ` [PATCH 0/5] loop over headlines in active region David Maus
2011-08-25  6:13                   ` Carsten Dominik
2011-08-28 13:58                     ` David Maus
2011-08-29  9:29                       ` Carsten Dominik
2011-08-30  4:36                         ` David Maus
2011-08-25 10:08                   ` Štěpán Němec
2011-08-28 13:57                     ` David Maus
2011-09-07 19:34                       ` Štěpán Němec
2011-09-09  4:06                         ` David Maus
2011-09-09 10:26                           ` Štěpán Němec
2011-09-09 10:41                             ` Bastien
2011-09-09 10:46                               ` Štěpán Němec
2011-09-09 15:10                             ` David Maus
2011-09-09 15:26                               ` Štěpán Němec
2011-09-09 15:52                                 ` David Maus
2011-10-06  8:35                   ` Carsten Dominik
2011-10-08 18:59                     ` David Maus
2011-10-08 20:11                       ` Carsten Dominik
2011-10-08 20:55                         ` David Maus
2011-08-25  4:25                 ` [PATCH 1/5] Extend scope 'region to include body of last headline " David Maus
2011-08-25  5:40                   ` Carsten Dominik
2011-08-30  4:33                     ` David Maus
2011-08-25  4:25                 ` [PATCH 2/5] Immediately return if scope is region but no region is active David Maus
2011-08-25  5:43                   ` Carsten Dominik
2011-08-28 14:00                     ` David Maus
2011-08-29  9:31                       ` Carsten Dominik
2011-08-30  4:40                   ` David Maus
2011-08-25  4:25                 ` [PATCH 3/5] New customization variable: Loop over headlines in active region David Maus
2011-08-25  4:25                 ` [PATCH 4/5] Skip invisible headlines when mapping " David Maus
2011-08-25  4:25                 ` [PATCH 5/5] Avoid conflict between bulk command and loop-over-headlines David Maus
2011-10-22 14:23                   ` Bastien
2011-07-27 15:23   ` New feature: loop over siblings for some commands Bastien

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=87zkkayvld.wl%dmaus@ictsoc.de \
    --to=dmaus@ictsoc.de \
    --cc=bzg@altern.org \
    --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).