emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Restricting admisible tags depending on header
@ 2016-06-04  3:27 Óscar Fuentes
  2016-06-04 11:31 ` John Kitchin
  2016-06-04 21:26 ` Óscar Fuentes
  0 siblings, 2 replies; 3+ messages in thread
From: Óscar Fuentes @ 2016-06-04  3:27 UTC (permalink / raw)
  To: emacs-orgmode

I'll like to offer only certain tags depending on the contents of the
current header. For instance, if the header is

* Status

I want to see only "open" and "closed" on the options shown by
org-fast-tag-selection.

Currently I define quite a lot of tags with #+TAGS:, most of them are
intended to be assigned to a specific header. Having so many tags
displayed by org-fast-tag-selection is confusing, error-prone and breaks
the selection method (org-fast-tag-selection runs out of letters).

I'm thinking on advising org-fast-tag-selection and prune the list of
acceptable tags before calling the real function, but maybe there is a
better method.

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

* Re: Restricting admisible tags depending on header
  2016-06-04  3:27 Restricting admisible tags depending on header Óscar Fuentes
@ 2016-06-04 11:31 ` John Kitchin
  2016-06-04 21:26 ` Óscar Fuentes
  1 sibling, 0 replies; 3+ messages in thread
From: John Kitchin @ 2016-06-04 11:31 UTC (permalink / raw)
  To: Óscar Fuentes; +Cc: emacs-orgmode

This looks more like TODO states to me.

You can do that on a file basis like this I think:

#+TODO: OPEN CLOSED

It is an interesting idea to make them heading specific though. I guess
you should store them in a property on the headline though.

Otherwise I would suggest using something like counsel-org-tag which
wouldn't have the same limitations.

Óscar Fuentes writes:

> I'll like to offer only certain tags depending on the contents of the
> current header. For instance, if the header is
>
> * Status
>
> I want to see only "open" and "closed" on the options shown by
> org-fast-tag-selection.
>
> Currently I define quite a lot of tags with #+TAGS:, most of them are
> intended to be assigned to a specific header. Having so many tags
> displayed by org-fast-tag-selection is confusing, error-prone and breaks
> the selection method (org-fast-tag-selection runs out of letters).
>
> I'm thinking on advising org-fast-tag-selection and prune the list of
> acceptable tags before calling the real function, but maybe there is a
> better method.


-- 
Professor John Kitchin
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
@johnkitchin
http://kitchingroup.cheme.cmu.edu

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

* Re: Restricting admisible tags depending on header
  2016-06-04  3:27 Restricting admisible tags depending on header Óscar Fuentes
  2016-06-04 11:31 ` John Kitchin
@ 2016-06-04 21:26 ` Óscar Fuentes
  1 sibling, 0 replies; 3+ messages in thread
From: Óscar Fuentes @ 2016-06-04 21:26 UTC (permalink / raw)
  To: emacs-orgmode

Óscar Fuentes <ofv@wanadoo.es> writes:

> I'll like to offer only certain tags depending on the contents of the
> current header. For instance, if the header is
>
> * Status
>
> I want to see only "open" and "closed" on the options shown by
> org-fast-tag-selection.
>
> Currently I define quite a lot of tags with #+TAGS:, most of them are
> intended to be assigned to a specific header. Having so many tags
> displayed by org-fast-tag-selection is confusing, error-prone and breaks
> the selection method (org-fast-tag-selection runs out of letters).
>
> I'm thinking on advising org-fast-tag-selection and prune the list of
> acceptable tags before calling the real function, but maybe there is a
> better method.

Thanks to all who responded, both off- and on-list.

At the end, I opted for advising org-fast-tag-selection. Now, for a
given heading, a tag group with the same name provides the admisible
tags:

#+TAGS: [ Status : { open closed }  ]
#+TAGS: [ Status : { done(d) postponed cancelled wontfix worksforme invalid } ]
#+TAGS: [ Type : { task defect enhancement feedback test } ]
#+TAGS: [ Severity : { critical major minor cosmetic } ]
#+TAGS: [ Priority : { top high medium low } ]

* Status
* Type
* Severity
* Priority


Code:

(defun ofv-issues-tags-for-heading (h)
  (setq h (org-no-properties h))
  (let (check-name-p collect-tags-p specific-tags)
    (dolist (tag org-tag-alist)
      (cond
       ((eq (car tag) ':endgrouptag)
	(setq collect-tags-p nil))
       ((eq (car tag) ':startgrouptag)
	(setq check-name-p t))
       (collect-tags-p
	(push tag specific-tags))
       (check-name-p
	(setq collect-tags-p (equal (car tag) h))
	(setq check-name-p nil))))
    specific-tags))

(defun ofv-issues-org-fast-tag-selection (args)
  ;; The `table' parameter of `org-fast-tag-selection' contains a
  ;; uniquified list, which removes duplicated group tag names.
  ;; `ofv-issues-tags-for-heading' uses the contents of
  ;; `org-tag-alist'.
  (let ((specific-tags (ofv-issues-tags-for-heading (org-get-heading t t))))
    (when specific-tags
      (setcar (nthcdr 2 args) (nreverse specific-tags))))
  args)

(advice-add 'org-fast-tag-selection :filter-args
	    'ofv-issues-org-fast-tag-selection)

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

end of thread, other threads:[~2016-06-04 21:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-04  3:27 Restricting admisible tags depending on header Óscar Fuentes
2016-06-04 11:31 ` John Kitchin
2016-06-04 21:26 ` Óscar Fuentes

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