From: Ryan Thompson <rct@thompsonclan.org>
To: Org-Mode List <emacs-orgmode@gnu.org>
Subject: Utility functions for setting/clearing categories
Date: Fri, 29 Jan 2010 09:15:18 -0800 [thread overview]
Message-ID: <2a4ba2fd1001290915k1cd7dasfb5bf0ba2b49efb6@mail.gmail.com> (raw)
[-- Attachment #1.1: Type: text/plain, Size: 1733 bytes --]
Hi all,
If anyone out there makes heavy use of categories and is sick of going
through org-sort-property and org-delete-property to handle them, here's a
pair of conveience functions for directly manipulating categories. It's a
pity that emacs doesn't seem to support partially applying an interactive
function and then having it interactively prompt for the remaining
arguments. That would make org-set-category as short as org-delete-category.
Moset of the code is copied from org-set-property's interactive definition,
and then modified.
-Ryan
(defun org-set-category (property value)
"In the current entry, set category to VALUE.
When called interactively, this will prompt for a value, offering
completion either on allowed values (via an inherited xxx_ALL
property) or on existing values in other instances of this
property in the current file."
(interactive
(let* ((completion-ignore-case t)
(prop "CATEGORY")
(cur (org-entry-get nil prop))
(allowed (org-property-get-allowed-values nil prop 'table))
(existing (mapcar 'list (org-property-values prop)))
(val (if allowed
(org-completing-read "Value: " allowed nil 'req-match)
(let (org-completion-use-ido org-completion-use-iswitchb)
(org-completing-read
(concat "Value " (if (and cur (string-match "\\S-" cur))
(concat "[" cur "]") "")
": ")
existing nil nil "" nil cur)))))
(list prop (if (equal val "") cur val))))
(unless (equal (org-entry-get nil property) value)
(org-entry-put nil property value)))
(defun org-delete-category ()
"Delete the category of the current item."
(interactive)
(org-delete-property "CATEGORY"))
[-- Attachment #1.2: Type: text/html, Size: 2019 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
reply other threads:[~2010-01-29 17:15 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=2a4ba2fd1001290915k1cd7dasfb5bf0ba2b49efb6@mail.gmail.com \
--to=rct@thompsonclan.org \
--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).