emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Christopher M. Miles" <numbchild@gmail.com>
To: Ihor Radchenko <yantar92@posteo.net>
Cc: "Christopher M. Miles" <numbchild@gmail.com>,
	Org-mode <emacs-orgmode@gnu.org>
Subject: [PATCH v4] Re: Improve the performance of `org-set-tags-command` on large `org-tag-alist`
Date: Tue, 16 May 2023 20:12:50 +0800	[thread overview]
Message-ID: <64637cc5.a70a0220.d2249.9f22@mx.google.com> (raw)
In-Reply-To: <87v8gs4o88.fsf@localhost>

[-- Attachment #1: Type: text/plain, Size: 7437 bytes --]


Ihor Radchenko <yantar92@posteo.net> writes:

> "Christopher M. Miles" <numbchild@gmail.com> writes:
>
>> Updated version which fix the `message` error in upper code:
>
> Thanks!
>
>> #+begin_src emacs-lisp
>> (setq tbl (let ((bound-tags (seq-filter 'cdr fulltable)))
>>                     (if (length< fulltable org-fast-tag-selection-maximum-tags)
>
> Because of (:startgroup) markers and similar things, this condition is
> not fully accurate. See `org-tag-alist' docstring.
>
> You may also need to consider special alist items in the rest of the code.
>
I added a let-binding to modify fulltable at first to filter out special tag markers.

>>                         fulltable
>>                       (if (length< bound-tags org-fast-tag-selection-maximum-tags)
>>                           (progn
>>                             (insert "Tags are limited displayed by `org-fast-tag-selection-maximum-tags'.\n")
>
> If you want to have proper Elisp symbol markup when using `...', use
> `format-message'.

Updated.

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

Using `append':

#+begin_example
Inherited:  video
Current:    

Tags are limited displayed by ‘org-fast-tag-selection-maximum-tags’.
  [d] drill                               [z] crypt                               [A] ARCHIVE                             
  [E] noexport                            [P] private                             [D] deprecated                          
  [O] outdated                            [t] translate                           [i] idea                                
  [h] book                                [b] bookmark                            [w] work                                
  [a] appointment                         [m] meeting                             [u] urgent                              
  [X] SEX                                 [k] wiki                                [C] code                                
  [e] Emacs                               [o] Org_mode                            [G] git                                 
  [L] Linux                               [M] macOS                               [W] Windows                             
  [l] LISP                                [c] Clojure                             [s] ClojureScript                       
  [J] Java                                [S] Shell                               [p] Python                              
  [r] Ruby                                [j] JavaScript                          [d] database                            
  [f] LOG                                 [g] @marks                              [n] on                                  
  [q] off                                 [v] star                                [x] like                                
  [y] favorite                            [{] suggested                           [|] heart                               
  [}] smile                               [~] brain                               [ ] check                               
  [ ] alert                               [ ] important                           [ ] flag                                
  [ ] error                               [ ] label                               
#+end_example

Using `org--tag-add-to-alist':

#+begin_example
Inherited:  video
Current:    

Tags are limited displayed by ‘org-fast-tag-selection-maximum-tags’.
  [d] drill                               [z] crypt                               [f] LOG                                 
  [A] ARCHIVE                             [E] noexport                            [P] private                             
  [D] deprecated                          [O] outdated                            [g] @marks                              
  [n] on                                  [q] off                                 [v] star                                
  [x] like                                [y] favorite                            [{] suggested                           
  [|] heart                               [}] smile                               [~] brain                               
  [ ] check                               [ ] alert                               [ ] important                           
  [ ] flag                                [ ] error                               [ ] label                               
  [ ] question                            [ ] info                                [ ] quote                               
  [ ] table                               [t] translate                           [ ] language                            
  [i] idea                                [ ] comment                             [ ] screenshot                          
  [ ] trash                               [ ] delete                              [ ] clear                               
  [ ] cancel                              [ ] lock                                [ ] unlock                              
  [ ] key                                 [ ] refresh                             [ ] repeat                              
  [ ] shuffle                             [h] book                                [b] bookmark                            
  [ ] note                                [ ] cheatsheet                          [ ] paperclip                           
  [ ] plot                                [ ] diagram                             
#+end_example

You can see the bound key tags are not fully displayed in buffer at second solution.

Here is the updated code:

#+begin_src emacs-lisp
(setq tbl (let* ((fulltable-accurate
                          (delq nil
                                (seq-filter
                                 (lambda (tag)
                                   (and (not (member tag '((:startgrouptag) (:grouptags) (:endgrouptag)))) tag))
                                 fulltable)))
                         (bound-tags (seq-filter 'cdr fulltable-accurate)))
                    (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"))
                            (seq-take (seq-uniq (append bound-tags fulltable-accurate)) ; TODO: consider to use `org--tag-add-to-alist'?
                                      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 #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]

  reply	other threads:[~2023-05-16 12:55 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-13  4:49 Improve the performance of `org-set-tags-command` on large `org-tag-alist` stardiviner
2023-05-13  7:43 ` Ihor Radchenko
2023-05-13  9:39   ` Christopher M. Miles
2023-05-13 11:13   ` stardiviner
2023-05-13 11:26     ` Ihor Radchenko
2023-05-13 14:24       ` [PATCH] " Christopher M. Miles
2023-05-13 18:43         ` Ihor Radchenko
2023-05-14  1:54           ` Christopher M. Miles
2023-05-14  8:09             ` Ihor Radchenko
2023-05-14 14:27               ` Christopher M. Miles
2023-05-14 14:58                 ` Ihor Radchenko
2023-05-14 16:27                   ` Christopher M. Miles
2023-05-14 17:38                     ` Ihor Radchenko
2023-05-14 18:14                       ` [PATCH v2] " Christopher M. Miles
2023-05-15 10:59                         ` Ihor Radchenko
2023-05-15 12:43                           ` Christopher M. Miles
2023-05-15 13:14                             ` Ihor Radchenko
2023-05-15 14:40                           ` [PATCH v3] " Christopher M. Miles
2023-05-15 16:12                             ` [PATCH v3.1] " Christopher M. Miles
2023-05-16  9:31                               ` Ihor Radchenko
2023-05-16 12:12                                 ` Christopher M. Miles [this message]
2023-05-16 12:12                                 ` [PATCH v4] " Christopher M. Miles
2023-05-16 18:53                                   ` Ihor Radchenko
2023-05-17  5:57                                     ` [PATCH v4.1] " Christopher M. Miles
2023-06-30 12:55                                       ` Ihor Radchenko
2023-07-01 10:31                                         ` [PATCH v5] " Christopher M. Miles
2023-07-01 11:34                                           ` Ihor Radchenko
2024-01-09 14:12                                             ` [PATCH v6] " Ihor Radchenko
2024-01-10  3:48                                               ` Christopher M. Miles
2024-01-12 12:00                                                 ` Ihor Radchenko

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=64637cc5.a70a0220.d2249.9f22@mx.google.com \
    --to=numbchild@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=yantar92@posteo.net \
    /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).