emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v4.1] Re: Improve the performance of `org-set-tags-command` on la


From: Christopher M. Miles
Subject: [PATCH v4.1] Re: Improve the performance of `org-set-tags-command` on large `org-tag-alist`
Date: Wed, 17 May 2023 13:57:32 +0800
User-agent: mu4e 1.10.3; emacs 30.0.50

Ihor Radchenko <yantar92@posteo.net> writes:

> "Christopher M. Miles" <numbchild@gmail.com> writes:
>
>>>>                             (seq-take (seq-uniq (append bound-tags 
>>>> fulltable))
>>>>                                       org-fast-tag-selection-maximum-tags))
>>>
>>> This will behave awkwardly with tag groups. You may better use 
>>> `org--tag-add-to-alist'.
>>
>> I think here should use `append' instead of `org--tag-add-to-alist' to merge.
>
> Yeah. `org--tag-add-to-alist' does not tell it, but it actually prefers
> keeping duplicate tag copies from its second argument.
>
> Yet, however, tags with their binding assigned might occur inside a
> group. Your code will incorrectly pull them out.
>
> I think that the right approach to handle tag groups and explicitly
> bound tags is showing them all the time, even when the total number of
> tags exceeds the limit:
>
> 1. If a tag is bound explicitly (cdr non-nil) show it
> 2. If a tag is inside a group - show it
> 3. If there is still some room left, show up to the limit.
>
> My logic is that tag groups and bound tags can only be customized by the
> user. So, it makes sense to display them all the time - users likely
> expect such behaviour.
>
> WDYT?

I improved the code a little. Can't figure out how to implement upper logic.
Can you finish the last part? Thanks

#+begin_src emacs-lisp
(setq tbl (let* ((tags-grouped (org-tag-alist-to-groups fulltable))
                         (fulltable-accurate (flatten-list 
(org-tag-alist-to-groups fulltable)))
                         (bound-tags (seq-filter 'cdr fulltable)))
                    ;; TODO: consider tag groups.
                    ;; the right approach to handle tag groups and explicitly
                    ;; bound tags is showing them all the time, even when the 
total number of
                    ;; tags exceeds the limit
                    ;; 
                    ;; 1. If a tag is bound explicitly (cdr non-nil) show it
                    ;; 2. If a tag is inside a group - show it
                    ;; 3. If there is still some room left, show up to the 
limit.
                    (if (length< fulltable-accurate 
org-fast-tag-selection-maximum-tags)
                        fulltable
                      (if (length< bound-tags 
org-fast-tag-selection-maximum-tags)
                          (progn
                            (insert (format-message "Tags are limited displayed 
by `org-fast-tag-selection-maximum-tags'.\n"))
                            ;; TODO:
                            (seq-take (seq-uniq (org--tag-add-to-alist 
bound-tags fulltable))
                                      org-fast-tag-selection-maximum-tags))
                        (insert "Tags are limited displayed only has key 
bound.\n")
                        bound-tags)))
              char ?a cnt 0)
#+end_src

-- 

[ stardiviner ]
I try to make every word tell the meaning that I want to express without 
misunderstanding.

Blog: https://stardiviner.github.io/
IRC(libera.chat, freenode): stardiviner, Matrix: stardiviner
GPG: F09F650D7D674819892591401B5DF1C95AE89AC3

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]