Morgan Smith <morgan.j.sm...@outlook.com> writes:

>> What happens when tags are completely equal, according to every function
>> in `org-tags-sort-function'?
>
> Then no sorting would occur.  In the test suite we test for this by using the
> 'ignore function.

I was rather worried about the return value. `org-tags-sort' cannot
return "nothing happens" :) Implicitly, it returns nil when `dolist'
finishes without catching return value. It is minor though.

>>> --- a/testing/lisp/test-org.el
>>> +++ b/testing/lisp/test-org.el
>>> @@ -8484,7 +8484,7 @@ test-org/toggle-tag
>>>    ;; Special case: Handle properly tag inheritance.  In particular, do
>>>    ;; not set inherited tags.
>>>    (should
>>> -   (equal "* H1 :tag:\n** H2 :tag2:tag:"
>>> +   (equal "* H1 :tag:\n** H2 :tag:tag2:"
>>>       (org-test-with-temp-text "* H1 :tag:\n** <point>H2 :tag2:"
>>>         (let ((org-use-tag-inheritance t)
>>>               (org-tags-column 1))
>>
>> Why did you have to change this test?
>
> I did not understand the intent of the conditional in `org-set-tags' and
> changed behavior I shouldn't have.  Sorry about that.  All fixed now.

To be fair, that test contradicts the comment above it. But we should
indeed not make changes we do not understand, which is why I asked for
clarification.

> +This can also be a list of functions.  If a function returns nil when
> +sorting two tags regardless of order (to indicate both tags are equal),

Normally, comparison functions in Elisp return t when first argument
(tag) is less than second, and nil otherwise (when >=). So, your
description is rather confusing.

> +*** New tags sorting function ~org-tags-sort-hierarchy~
> +
> +By setting ~org-tags-sort-function~ to ~org-tags-sort-hierarchy~, tags
> +are sorted taking their hierarchy into account.  See ~org-tag-alist~
> +for how to set up a tag hierarchy.

We should better refer to 6.3 Tag Hierarchy section in the manual.

> +(defun org-tags-sort-hierarchy (tag1 tag2)
> +  "Sort tags TAG1 and TAG2 by the tag hierarchy.
> +See `org-tag-alist' for how to set up a tag hierarchy.  This function is
> +intended to be a value of `org-tags-sort-function'."

Same here.

> +        ;; value< was added in Emacs 30 and does not allow us to use
> +        ;; `org-tags-sort-function'.
> +        ;; (value< tag1-path tag2-path)

Please mark it FIXME, so that we can use value< after the next Emacs
release.

-- 
Ihor Radchenko // yantar92,
Org mode maintainer,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>

Reply via email to