From: David Maus <maus.david@gmail.com>
To: Emacs Orgmode Mailinglist <emacs-orgmode@gnu.org>
Subject: [Worg] Addition to org-hacks: Remove redundant tags
Date: Mon, 25 Jan 2010 20:23:38 +0100 [thread overview]
Message-ID: <87636q56px.wl%maus.david@gmail.com> (raw)
[-- Attachment #1.1.1: Type: text/plain, Size: 1423 bytes --]
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.... dmjena@jabber.org
Email..... maus.david@gmail.com
[-- Attachment #1.1.2: 0001-org-hacks-Remove-redundant-tags-i.e.-tags-that-are-i.patch --]
[-- Type: application/octet-stream, Size: 1690 bytes --]
From 238f79b75373e86de1fc347fbb759b1456b438f6 Mon Sep 17 00:00:00 2001
From: David Maus <maus.david@gmail.com>
Date: Mon, 25 Jan 2010 19:24:44 +0100
Subject: [PATCH] org-hacks: Remove redundant tags (i.e. tags that are inherited and
local) of headlines
---
org-hacks.org | 28 ++++++++++++++++++++++++++++
1 files changed, 28 insertions(+), 0 deletions(-)
diff --git a/org-hacks.org b/org-hacks.org
index 2b8fa57..6d0c915 100644
--- a/org-hacks.org
+++ b/org-hacks.org
@@ -841,3 +841,31 @@ using ido):
To browse your org attachments using ido fuzzy matching and/or the
completion buffer, invoke ido-find-file as usual (=C-x C-f=) and then
press =C-;=.
+
+* Remove redundant tags of headlines
+ -- David Maus
+
+A small function that processes all headlines in current buffer and
+removes tags that are local to a headline and inherited by a parent
+headline or the #+FILETAGS: statement.
+
+#+BEGIN_SRC emacs-lisp
+ (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))))
+#+END_SRC
--
1.6.5
[-- Attachment #1.2: Type: application/pgp-signature, Size: 230 bytes --]
[-- Attachment #2: Type: text/plain, Size: 201 bytes --]
_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode
next reply other threads:[~2010-01-25 19:23 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-01-25 19:23 David Maus [this message]
2010-01-26 5:34 ` [Worg] Addition to org-hacks: Remove redundant tags Manish
2010-01-26 16:22 ` David Maus
2010-01-26 16:54 ` Manish
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=87636q56px.wl%maus.david@gmail.com \
--to=maus.david@gmail.com \
--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).