From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nick Dokos Subject: Re: Automatic noexport tag based on rules? (and a possible bug) Date: Wed, 09 Feb 2011 04:36:57 -0500 Message-ID: <2378.1297244217@gamaville.dokosmarshall.org> References: Reply-To: nicholas.dokos@hp.com Return-path: Received: from [140.186.70.92] (port=38243 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Pn6U6-0004cK-8A for emacs-orgmode@gnu.org; Wed, 09 Feb 2011 04:37:15 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Pn6U3-0003Hn-PL for emacs-orgmode@gnu.org; Wed, 09 Feb 2011 04:37:14 -0500 Received: from vms173019pub.verizon.net ([206.46.173.19]:35077) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Pn6U3-0003H0-M1 for emacs-orgmode@gnu.org; Wed, 09 Feb 2011 04:37:11 -0500 Received: from gamaville.dokosmarshall.org ([unknown] [173.76.32.106]) by vms173019.mailsrvcs.net (Sun Java(tm) System Messaging Server 7u2-7.02 32bit (built Apr 16 2009)) with ESMTPA id <0LGC00A5OG1L6900@vms173019.mailsrvcs.net> for emacs-orgmode@gnu.org; Wed, 09 Feb 2011 03:36:59 -0600 (CST) In-reply-to: Message from John Hendy of "Tue, 08 Feb 2011 20:39:54 CST." List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: John Hendy Cc: Jeff Horn , emacs-orgmode , nicholas.dokos@hp.com John Hendy 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.