remove(org)!: remove broken tag selection advice

This commit is contained in:
Kiana Sheibani 2024-07-22 12:53:54 -04:00
parent 9d45fde62b
commit 9b73e3037f
Signed by: toki
GPG key ID: 6CB106C25E86A9F7

View file

@ -3092,47 +3092,6 @@ I don't want to have to specify the =RESET_CHECK_BOXES= property for every TODO
** Bug Fixes and Tweaks
*** Improved Tag Selection
The facilities for selecting and adding tags do not play very nicely with complex tag hierarchies, especially fast tag selection. The main problems are:
- Fast tag selection interprets regex tags as actual tags
- Fast tag selection can assign multiple keys to the same tag
- Regular tag selection interprets special tag entries such as ~:startgroup~ as actual tags
To fix this, we'll need some liberal use of override advising.
#+begin_src emacs-lisp
(defadvice! ~/org-assign-fast-keys (alist)
:override #'org-assign-fast-keys
(let (new e (alt ?0))
(while (setq e (pop alist))
(if (or (memq (car e) '(:newline :grouptags :endgroup :startgroup :startgrouptag :endgrouptag))
(and (string-prefix-p "{" (car e)) (string-suffix-p "}" (car e)))
(cdr e)) ;; Key already assigned.
(push e new)
(let ((clist (string-to-list (downcase (car e))))
(used (append new alist)))
(when (= (car clist) ?@)
(pop clist))
(while (and clist (rassoc (car clist) used))
(pop clist))
(unless clist
(while (rassoc alt used)
(cl-incf alt)))
(push (cons (car e) (or (car clist) alt)) new))))
(nreverse new)))
#+end_src
The last problem is that Org automatically assigns keys alphabetically if not specified, which means keys can often be difficult to reach. To fix this, we can simply configure some variables.
#+begin_src emacs-lisp
(after! org
(setq org--fast-tag-selection-keys
(string-to-list "asdfghjklrueitywovnASDFGHJKLRUEITYWOVN")
org-fast-tag-selection-maximum-tags 40))
#+end_src
*** Export Directory
Org mode by default exports to the same directory the org-mode file is in. This is inconvenient for me, as I use a lot of subdirectories. To fix this, we can advise the function ~org-export-output-file-name~.