emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Exclude all TODO keywords from refile targets
@ 2012-11-15 16:15 Jason Dunsmore
  2012-11-24  7:22 ` Bernt Hansen
  0 siblings, 1 reply; 3+ messages in thread
From: Jason Dunsmore @ 2012-11-15 16:15 UTC (permalink / raw)
  To: emacs-orgmode

I found a bit of code to exclude DONE keywords from refile targets
here: http://orgmode.org/worg/org-hacks.html#sec-2-3

Since I try to keep all headings with keywords as end nodes, I wanted
to exclude all TODO (and DONE) keywords.  However, the member function
doesn't work on a sequence data type, so I couldn't use
org-todo-keywords the same way the org-hacks code used
org-done-keywords.  Furthermore, org-todo-keywords contains extraneous
characters in parenthesis that define "selection characters".  I ended
up creating a new variable, org-todo-keywords-list, and converting the
data from org-todo-keywords into a similar format as
org-done-keywords.

Perhaps a org-todo-keywords-list variable would be a useful addition
to org-mode.  Here's the code I'm using:


(setq org-todo-keywords '((sequence "TODO(t)" "DELEGATE(l)"
"STARTED(s@)" "WAITING(w@)" "|" "DONE(d)" "CANCELLED(c)"
"DELEGATED(e@)" "POSTPONED(p@)")))

;; define a new variable
(defvar org-todo-keywords-list nil
  "A list version of org-todo-keywords, without the selection characters
in parenthesis.")

;; create org-todo-keywords-list from org-todo-keywords-list, using a
;; similar format to org-done-keywords
(dolist (keyword (first org-todo-keywords))
  (when (and (stringp keyword)
             (not (equal keyword "|")))
    (add-to-list 'org-todo-keywords-list
                 (replace-regexp-in-string "(.*)" "" keyword))))

(defun jbd-verify-refile-target ()
  "Exclude todo keywords with a done state from refile targets"
  (not (member (nth 2 (org-heading-components)) org-todo-keywords-list)))

(setq org-refile-target-verify-function 'jbd-verify-refile-target)

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Exclude all TODO keywords from refile targets
  2012-11-15 16:15 Exclude all TODO keywords from refile targets Jason Dunsmore
@ 2012-11-24  7:22 ` Bernt Hansen
  2012-11-25  2:46   ` Jason Dunsmore
  0 siblings, 1 reply; 3+ messages in thread
From: Bernt Hansen @ 2012-11-24  7:22 UTC (permalink / raw)
  To: Jason Dunsmore; +Cc: emacs-orgmode

Jason Dunsmore <jasondunsmore@gmail.com> writes:

> I found a bit of code to exclude DONE keywords from refile targets
> here: http://orgmode.org/worg/org-hacks.html#sec-2-3
>
> Since I try to keep all headings with keywords as end nodes, I wanted
> to exclude all TODO (and DONE) keywords.  However, the member function
> doesn't work on a sequence data type, so I couldn't use
> org-todo-keywords the same way the org-hacks code used
> org-done-keywords.  Furthermore, org-todo-keywords contains extraneous
> characters in parenthesis that define "selection characters".  I ended
> up creating a new variable, org-todo-keywords-list, and converting the
> data from org-todo-keywords into a similar format as
> org-done-keywords.
>
> Perhaps a org-todo-keywords-list variable would be a useful addition
> to org-mode.  Here's the code I'm using:
>
> (setq org-todo-keywords '((sequence "TODO(t)" "DELEGATE(l)"
> "STARTED(s@)" "WAITING(w@)" "|" "DONE(d)" "CANCELLED(c)"
> "DELEGATED(e@)" "POSTPONED(p@)")))
>

You should be able to use org-todo-keywords-1 which contains a list of
todo keywords for the current org file.

HTH,
Bernt

> ;; define a new variable
> (defvar org-todo-keywords-list nil
>   "A list version of org-todo-keywords, without the selection characters
> in parenthesis.")
>
> ;; create org-todo-keywords-list from org-todo-keywords-list, using a
> ;; similar format to org-done-keywords
> (dolist (keyword (first org-todo-keywords))
>   (when (and (stringp keyword)
>              (not (equal keyword "|")))
>     (add-to-list 'org-todo-keywords-list
>                  (replace-regexp-in-string "(.*)" "" keyword))))
>
> (defun jbd-verify-refile-target ()
>   "Exclude todo keywords with a done state from refile targets"
>   (not (member (nth 2 (org-heading-components)) org-todo-keywords-list)))
>
> (setq org-refile-target-verify-function 'jbd-verify-refile-target)

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Exclude all TODO keywords from refile targets
  2012-11-24  7:22 ` Bernt Hansen
@ 2012-11-25  2:46   ` Jason Dunsmore
  0 siblings, 0 replies; 3+ messages in thread
From: Jason Dunsmore @ 2012-11-25  2:46 UTC (permalink / raw)
  To: Bernt Hansen; +Cc: emacs-orgmode

On Sat, Nov 24, 2012 at 1:22 AM, Bernt Hansen <bernt@norang.ca> wrote:
> Jason Dunsmore <jasondunsmore@gmail.com> writes:
>
>> I found a bit of code to exclude DONE keywords from refile targets
>> here: http://orgmode.org/worg/org-hacks.html#sec-2-3
>>
>> Since I try to keep all headings with keywords as end nodes, I wanted
>> to exclude all TODO (and DONE) keywords.  However, the member function
>> doesn't work on a sequence data type, so I couldn't use
>> org-todo-keywords the same way the org-hacks code used
>> org-done-keywords.  Furthermore, org-todo-keywords contains extraneous
>> characters in parenthesis that define "selection characters".  I ended
>> up creating a new variable, org-todo-keywords-list, and converting the
>> data from org-todo-keywords into a similar format as
>> org-done-keywords.
>>
>> Perhaps a org-todo-keywords-list variable would be a useful addition
>> to org-mode.  Here's the code I'm using:
>>
>> (setq org-todo-keywords '((sequence "TODO(t)" "DELEGATE(l)"
>> "STARTED(s@)" "WAITING(w@)" "|" "DONE(d)" "CANCELLED(c)"
>> "DELEGATED(e@)" "POSTPONED(p@)")))
>>
>
> You should be able to use org-todo-keywords-1 which contains a list of
> todo keywords for the current org file.

That works perfectly.  Thank you.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-11-25  2:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-15 16:15 Exclude all TODO keywords from refile targets Jason Dunsmore
2012-11-24  7:22 ` Bernt Hansen
2012-11-25  2:46   ` Jason Dunsmore

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).