emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Nick Dokos <nicholas.dokos@hp.com>
To: John Hendy <jw.hendy@gmail.com>
Cc: Jeff Horn <jrhorn424@gmail.com>,
	emacs-orgmode <emacs-orgmode@gnu.org>,
	nicholas.dokos@hp.com
Subject: Re: Automatic noexport tag based on rules? (and a possible bug)
Date: Wed, 09 Feb 2011 04:36:57 -0500	[thread overview]
Message-ID: <2378.1297244217@gamaville.dokosmarshall.org> (raw)
In-Reply-To: Message from John Hendy <jw.hendy@gmail.com> of "Tue, 08 Feb 2011 20:39:54 CST." <AANLkTinJ5nUpyFbO9JGby64Ycnr-O=rqrDTKpWCTjcDw@mail.gmail.com>

John Hendy <jw.hendy@gmail.com> 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.

  parent reply	other threads:[~2011-02-09  9:37 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-09  0:29 Automatic noexport tag based on rules? John Hendy
2011-02-09  1:58 ` Jeff Horn
2011-02-09  2:39   ` John Hendy
2011-02-09  2:53     ` Jeff Horn
2011-02-09  7:40     ` Eric S Fraga
2011-02-09 15:18       ` John Hendy
2011-02-09 16:58         ` John Hendy
2011-02-09 18:13       ` Nicolas Goaziou
2011-02-09 18:46         ` John Hendy
2011-02-09  9:36     ` Nick Dokos [this message]
2011-02-11  8:34 ` Carsten Dominik
2011-02-11 15:33   ` John Hendy
2011-02-25 22:37 ` John Hendy
2011-03-27 19:37   ` [Orgmode] " Samuel Wales
2011-03-27 20:10     ` John Hendy
2011-03-29 18:40       ` Matt Lundin
2011-03-29 21:05         ` Carsten Dominik
2011-03-29 21:15           ` Carsten Dominik
2011-03-29 21:48             ` John Hendy
2011-03-29 22:49               ` Carsten Dominik
2011-03-29 22:50                 ` John Hendy
2011-03-30  3:30                   ` 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=2378.1297244217@gamaville.dokosmarshall.org \
    --to=nicholas.dokos@hp.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=jrhorn424@gmail.com \
    --cc=jw.hendy@gmail.com \
    /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).