From: Nicolas Goaziou <mail@nicolasgoaziou.fr>
To: "Gustav Wikström" <gustav.erik@gmail.com>
Cc: Org Mode List <emacs-orgmode@gnu.org>
Subject: Re: [RFC] [PATCH] Changes to Tag groups - allow nesting and regexps
Date: Sat, 07 Mar 2015 22:51:41 +0100 [thread overview]
Message-ID: <87zj7o5vde.fsf@nicolasgoaziou.fr> (raw)
In-Reply-To: <CA+SyOP9gtibQoq_N2b+vWzwRQ=vPSUyOb6ULP_LoTmNz7GGEag@mail.gmail.com> ("Gustav \=\?utf-8\?Q\?Wikstr\=C3\=B6m\=22's\?\= message of "Thu, 5 Mar 2015 02:08:27 +0100")
Gustav Wikström <gustav.erik@gmail.com> writes:
> I've fixed the issues raised (IMO), and new patches are attached. I've
> added a patch for documentation also.
Thank you.
> I'd say it's an unnecessary limitation if group tags have to be
> exclusive on a headline. The more general case should be allowed and I
> can see use-cases for it.
>
> If you, for example, want to create a taxonomy of your tags and a part
> of your taxonomy is this:
>
> #+TAGS: [ CS : DB OS Software Versioning Programming BI ]
>
> What reason is there for Org mode to limit me to only choosing one of
> the above? Lets say I find an article on the web and want to create a
> node in my org-mode repository about it. Maybe linking the article and
> adding a few thoughts. The fictive article may be called "the
> importance of good database-design in Business intelligence". It seems
> two tags of the above would fit just fine; DB & BI.
Fair enough.
> + (taggroups (if downcased (mapcar (lambda (tg) (mapcar #'downcase tg))
> + taggroups) taggroups))
Nitpick: indentation
(taggroups (if downcased
(mapcar (lambda (tg) (mapcar #'downcase tg)) taggroups)
taggroups))
> + (delq nil (mapcar (lambda (x)
> + (if (stringp x)
> + (and (equal "{" (substring x 0 1))
> + (equal "}" (substring x -1))
> + x)
> + x)) tags-in-group))
Same here. TAGS-IN-GROUP should be at the same level as (lambda (x) ...)
> + regexp-in-group
> + (mapcar (lambda (x)
> + (substring x 1 -1)) regexp-in-group-escaped)
Ditto.
> + tags-in-group
> + (delq nil (mapcar (lambda (x)
> + (if (stringp x)
> + (and (not (equal "{" (substring x 0 1)))
> + (not (equal "}" (substring x -1)))
> + x)
> + x)) tags-in-group)))
Ditto.
> + ; If single-as-list, do no more in the while-loop...
> + (if (not single-as-list)
> + (progn
> + (if regexp-in-group
> + (setq regexp-in-group (concat "\\|" (mapconcat 'identity regexp-in-group "\\|"))))
> + (setq tags-in-group (concat dir "{\\<" (regexp-opt tags-in-group) regexp-in-group "\\>}"))
You need to keep lines within 80 columns.
> + (when (member tg g)
> + (mapc (lambda (x)
> + (setq current (delete x current)))
> + g)))
While you're at it:
(when (member tg g) (dolist (x g) (setq current (delete x current))))
> +(defun org-agenda-filter-by-tag (arg &optional char exclude)
> "Keep only those lines in the agenda buffer that have a specific tag.
> The tag is selected with its fast selection letter, as configured.
> -With prefix argument STRIP, remove all lines that do have the tag.
> -A lisp caller can specify CHAR. NARROW means that the new tag should be
> -used to narrow the search - the interactive user can also press `-' or `+'
> -to switch to narrowing."
> +With a single `C-u' prefix ARG, exclude the agenda search. With a
> +double `C-u' prefix ARG, filter the literal tag. I.e. don't filter on
^^^
missing space
Also, instead of hard-coding `C-u', you could use \\[universal-argument]
within the doc string. See, for example, `org-tree-to-indirect-buffer'.
> + (exclude (if exclude exclude (equal arg '(4))))
(exclude (or exclude (equal arg '(4))))
> + (while (not (memq char (append '(?\t ?\r ?/ ?. ?\ ?q)
> + (string-to-list tag-chars))))
For clarity, use ?\s instead of ?\
Also, I suggest to move the consing before the while loop.
> + ((eq char ?. )
Spurious space.
> + ((or (eq char ?\ )
See above.
> + (save-match-data
> + (let (tags-expanded)
> + (dolist (x (cdr tags-in-group))
> + (if (and (member x taggroups-keys)
> + (not (member x work-already-expanded)))
> + (setq tags-expanded (delete-dups
> + (append (org-tags-expand x t downcased work-already-expanded)
> + tags-expanded)))
> + (setq tags-expanded (append (list x) tags-expanded)))
> + (setq work-already-expanded (delete-dups (append tags-expanded work-already-expanded))))
> + (setq tags-in-group (delete-dups (cons (car tags-in-group)
> +
> tags-expanded)))))
Lines too wide.
> +Tags can be defined in hierarchies. A tag can be defined as a @emph{group
^^^
missing space
> +#+TAGS: [ Persp : Vision Goal AOF Project ]
> +#+TAGS: [ Control : Context Task ]
> @end example
>
> -In this example, @samp{@@read} is a @emph{group tag} for a set of three
> -tags: @samp{@@read}, @samp{@@read_book} and @samp{@@read_ebook}.
> +That can conceptually be seen as a hierarchy of tags:
>
> -You can also use the @code{:grouptags} keyword directly when setting
> -@code{org-tag-alist}:
> +@example
> +- GTD
> + - Persp
> + - Vision
> + - Goal
> + - AOF
> + - Project
> + - Control
> + - Context
> + - Task
> +@end example
> +
> +You can use the @code{:startgrouptag}, @code{:grouptags} and
> +@code{:endgrouptag} keyword directly when setting @code{org-tag-alist}
> +directly:
>
> @lisp
> -(setq org-tag-alist '((:startgroup . nil)
> +(setq org-tag-alist '((:startgrouptag . nil)
> ("@@read" . nil)
> (:grouptags . nil)
> ("@@read_book" . nil)
> ("@@read_ebook" . nil)
> - (:endgroup . nil)))
> + (:endgrouptag . nil)))
> @end lisp
The following is clearer
@lisp
(setq org-tag-alist '((:startgrouptag)
("@@read")
(:grouptags)
("@@read_book")
("@@read_ebook")
(:endgrouptag)))
@end lisp
However, shouldn't this example apply to the one above? (e.g.., with
Control : Context Task tag line)?
> +Searching for the tag Project will now list all tags also including regular
> +expression matches for P@@.+. Similar for tag-searches on Vision, Goal and
> +AOF. This can be good for example if tags for a certain project is tagged
> +with a common project-identifier, i.e. P@@2014_OrgTags.
@samp{Project} @samp{Vision}... @samp{P@@2014_OrgTags}.
This all looks very nice. As a final step, would you mind adding tests
for this?
As a starter `test-org/set-regexps-and-options' in "test-org.el" could
be extended to test parsing of square brackets tags.
Since you're touching some hairy part of Org, the more tests the better.
Regards,
next prev parent reply other threads:[~2015-03-07 21:50 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-25 11:07 [RFC] [PATCH] Changes to Tag groups - allow nesting and regexps Gustav Wikström
2015-01-31 8:41 ` Nicolas Goaziou
2015-02-19 20:00 ` Gustav Wikström
2015-02-24 16:43 ` Nicolas Goaziou
2015-03-05 1:08 ` Gustav Wikström
2015-03-07 21:51 ` Nicolas Goaziou [this message]
2015-03-15 10:17 ` Gustav Wikström
2015-03-16 20:38 ` Gustav Wikström
2015-03-16 21:30 ` Nicolas Goaziou
2015-03-19 21:07 ` Gustav Wikström
2015-03-19 22:43 ` Nicolas Goaziou
-- strict thread matches above, loose matches on Subject: below --
2015-11-25 7:50 sgeorgii .
2015-11-25 10:26 ` Gustav Wikström
2015-11-25 11:05 ` sgeorgii .
2015-11-25 12:20 ` Gustav Wikström
2015-11-25 12:58 ` Nicolas Goaziou
2015-11-25 14:44 ` Gustav Wikström
2015-11-25 14:52 ` Nicolas Goaziou
2015-11-25 15:39 ` Gustav Wikström
2015-11-26 7:30 ` sgeorgii .
2015-11-26 8:21 ` Nicolas Goaziou
2015-11-26 10:01 ` Gustav Wikström
2015-11-26 10:21 ` Nicolas Goaziou
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=87zj7o5vde.fsf@nicolasgoaziou.fr \
--to=mail@nicolasgoaziou.fr \
--cc=emacs-orgmode@gnu.org \
--cc=gustav.erik@gmail.com \
/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).