[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Orgmode] Automatic noexport tag based on rules? (and a possible bug
From: |
Nick Dokos |
Subject: |
Re: [Orgmode] Automatic noexport tag based on rules? (and a possible bug) |
Date: |
Wed, 09 Feb 2011 04:36:57 -0500 |
John Hendy <address@hidden> wrote:
> Yeah.. most of my todos aren't medium-sized projects, though. Many of them
> are more along the lines of one-liner action items I need to jot to myself
> so I don't forget as well as keeping them as a sort of rolling "next
> actions" queue. For that reason, I'd much rather keep them in their original
> context.
>
> This can't be too hard.
>
> ,---
> | sed '/[*]* TODO/ s/$/ :noexport:/g'
> `---
>
That's perfectly workable[fn:1].
> Or (facetious)
>
> ,---
> | setq (prefix-for-noexport-custom-variable)
> | setq (default-tags-for-no-export-variable)
> `---
>
This isn't ;-)
> I just don't know what the elegant, "right" elisp/org method is for
> something like this.
>
Eye of the beholder and all that. Here's my attempt which should work,
except I think there is a bug in org-change-tag-in-region (see below):
--8<---------------cut here---------------start------------->8---
(defun set-noexport ()
(org-change-tag-in-region (save-excursion (beginning-of-line) (point))
(save-excursion (end-of-line) (point)) "noexport" nil))
(defun jh-mark-todo-noexport ()
(org-map-entries 'set-noexport "/+TODO" 'file))
--8<---------------cut here---------------end--------------->8---
There might be a simpler way to set the tag, but if so, I didn't find it.
OTOH, mapping over the entries is as elegant as it gets.
Now for the (purported) bug: org-change-tag-in-region does the following
,----
| ...
| (goto-char end)
| (setq l2 (1- (org-current-line)))
| (goto-char beg)
| (setq l1 (org-current-line))
| (loop for l from l1 to l2 do
| ...
`----
so if the region is a single line (say line 3), l2 becomes 2, l1 becomes 3
and the loop is not executed at all, whereas methinks it should be executed
once.
Shouldn't l2 be set to (org-current-line)?
Thanks,
Nick
Footnotes:
[fn:1] ...except that you might not want to add the tag if it's there already -
I'm not sure whether that would cause a problem.
Re: [Orgmode] Automatic noexport tag based on rules?, Carsten Dominik, 2011/02/11
[Orgmode] Re: Automatic noexport tag based on rules?, John Hendy, 2011/02/25