[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Orgmode] [Worg] Addition to org-hacks: Remove redundant tags
From: |
David Maus |
Subject: |
[Orgmode] [Worg] Addition to org-hacks: Remove redundant tags |
Date: |
Mon, 25 Jan 2010 20:23:38 +0100 |
User-agent: |
Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (Gojō) APEL/10.7 Emacs/23.1.91 (i486-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) |
Hello,
Attached patch adds a section to the org-hacks page of Worg with a
function that removes redundant tags, that is: tags that are inherited
by a parent headline or the #+FILETAGS headline and local to a
headline.
This function is useful for me as I generally use tags to denote a
todo's context (priv for private, work for work related etc.) and in
addition split my agenda files by context, too (work.org,
private.org). If I file new todo headlines using `org-remember' they
go in a central file (bucket.org) and I tag them so they show up on
tags searches. After refiling the context denoting tags are
duplicated -- hence I wrote this little function to remove them:
(defun dmj/org-remove-redundant-tags ()
"Remove redundant tags of headlines in current buffer.
A tag is considered redundant if it is local to a headline and
inherited by a parent headline."
(interactive)
(when (eq major-mode 'org-mode)
(save-excursion
(org-map-entries
'(lambda ()
(let ((alltags (split-string (org-entry-get (point) "ALLTAGS") ":"))
local inherited tag)
(dolist (tag alltags)
(if (get-text-property 0 'inherited tag)
(push tag inherited) (push tag local)))
(dolist (tag local)
(if (member tag inherited) (org-toggle-tag tag 'off)))))
t nil))))
Regards
-- David
--
OpenPGP... 0x99ADB83B5A4478E6
Jabber.... address@hidden
Email..... address@hidden
0001-org-hacks-Remove-redundant-tags-i.e.-tags-that-are-i.patch
Description: Binary data
pgpIIo3Yiet7j.pgp
Description: PGP signature
- [Orgmode] [Worg] Addition to org-hacks: Remove redundant tags,
David Maus <=