From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?utf-8?Q?=C3=93scar_Fuentes?= Subject: Re: Restricting admisible tags depending on header Date: Sat, 04 Jun 2016 23:26:46 +0200 Message-ID: <87eg8cbq7d.fsf@wanadoo.es> References: <87inxpbplv.fsf@wanadoo.es> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:43745) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b9J68-0003kR-LX for emacs-orgmode@gnu.org; Sat, 04 Jun 2016 17:27:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b9J62-0003gE-Lr for emacs-orgmode@gnu.org; Sat, 04 Jun 2016 17:27:11 -0400 Received: from plane.gmane.org ([80.91.229.3]:45179) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b9J62-0003fu-F4 for emacs-orgmode@gnu.org; Sat, 04 Jun 2016 17:27:06 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1b9J60-0002ng-NK for emacs-orgmode@gnu.org; Sat, 04 Jun 2016 23:27:04 +0200 Received: from 141.red-217-125-182.dynamicip.rima-tde.net ([217.125.182.141]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 04 Jun 2016 23:27:04 +0200 Received: from ofv by 141.red-217-125-182.dynamicip.rima-tde.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 04 Jun 2016 23:27:04 +0200 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: emacs-orgmode@gnu.org Ó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. 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)