emacs-orgmode
[Top][All Lists]
Advanced

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

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


From: Christopher M. Miles
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
User-agent: mu4e 1.10.3; emacs 30.0.50

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: signature.asc
Description: PGP signature


reply via email to

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