Remove 'org-category text property cache

* lisp/org.el (org-get-category): Update useing
`org-entry-get-with-inheritance'.
(org-agenda-ignore-properties): Update docstring.
(org-refresh-category-properties):
(org-check-agenda-file): Do not call
`org-refresh-category-properties'.
* lisp/org-compat.el (org-refresh-category-properties): Obsolete.
* doc/org-manual.org (Speeding Up Your Agendas): Update the manual.
* testing/lisp/test-org.el (test-org/get-category): Update tests, not
calling the obsolete function.
This commit is contained in:
Ihor Radchenko 2023-05-29 12:41:09 +03:00
parent 771074ba5e
commit eb0a293a02
No known key found for this signature in database
GPG Key ID: 6470762A7DA11D8B
5 changed files with 33 additions and 49 deletions

View File

@ -21768,12 +21768,12 @@ number. Here are tips to speed up:
- Disable parsing of some drawer properties: - Disable parsing of some drawer properties:
#+begin_src emacs-lisp #+begin_src emacs-lisp
(setq org-agenda-ignore-properties '(effort appt stats category)) (setq org-agenda-ignore-properties '(effort appt stats))
#+end_src #+end_src
The drawer properties you can disable in the agenda are effort The drawer properties you can disable in the agenda are effort
estimates (~effort~), appointments (~appt~), statistics (~stats~) estimates (~effort~), appointments (~appt~), and statistics
and subtree-local categories (~category~). (~stats~).
These options can be applied to selected agenda views. For more These options can be applied to selected agenda views. For more
details about generation of agenda views, see the docstrings for the details about generation of agenda views, see the docstrings for the

View File

@ -5664,7 +5664,7 @@ and the timestamp type relevant for the sorting strategy in
(throw :skip nil))) (throw :skip nil)))
(goto-char (match-beginning 2)) (goto-char (match-beginning 2))
(setq marker (org-agenda-new-marker (match-beginning 0)) (setq marker (org-agenda-new-marker (match-beginning 0))
category (org-get-category) category (save-match-data (org-get-category))
effort (save-match-data (or (get-text-property (point) 'effort) effort (save-match-data (or (get-text-property (point) 'effort)
(org-entry-get (point) org-effort-property))) (org-entry-get (point) org-effort-property)))
effort-minutes (when effort (save-match-data (org-duration-to-minutes effort))) effort-minutes (when effort (save-match-data (org-duration-to-minutes effort)))

View File

@ -582,6 +582,8 @@ Counting starts at 1."
(define-obsolete-function-alias 'org--math-always-on (define-obsolete-function-alias 'org--math-always-on
'org--math-p "9.7") 'org--math-p "9.7")
(make-obsolete 'org-refresh-category-properties "no longer used" "9.7")
(defun org-compatible-face (inherits specs) (defun org-compatible-face (inherits specs)
"Make a compatible face specification. "Make a compatible face specification.
If INHERITS is an existing face and if the Emacs version supports If INHERITS is an existing face and if the Emacs version supports

View File

@ -7956,20 +7956,13 @@ call CMD."
(cl-progv vars vals (cl-progv vars vals
(call-interactively cmd)))) (call-interactively cmd))))
(defun org-get-category (&optional pos force-refresh) (defun org-get-category (&optional pos _)
"Get the category applying to position POS." "Get the category applying to position POS.
(save-match-data Return \"???\" when no category is set."
(when force-refresh (org-refresh-category-properties)) ;; Sync cache.
(let ((pos (or pos (point)))) (or (org-entry-get-with-inheritance
(if (org-element--cache-active-p) "CATEGORY" nil (or pos (point)))
;; Sync cache. "???"))
(org-with-point-at (org-element-begin (org-element-at-point pos))
(or (org-entry-get-with-inheritance "CATEGORY")
"???"))
(or (get-text-property pos 'org-category)
(progn
(org-refresh-category-properties)
(get-text-property pos 'org-category)))))))
;;; Refresh properties ;;; Refresh properties
@ -15246,12 +15239,11 @@ appointments, statistics and subtree-local categories.
If you don't use these in the agenda, you can add them to this If you don't use these in the agenda, you can add them to this
list and agenda building will be a bit faster. list and agenda building will be a bit faster.
The value is a list, with zero or more of the symbols `effort', `appt', The value is a list, with zero or more of the symbols `effort', `appt',
`stats' or `category'." or `stats'."
:type '(set :greedy t :type '(set :greedy t
(const effort) (const effort)
(const appt) (const appt)
(const stats) (const stats))
(const category))
:version "26.1" :version "26.1"
:package-version '(Org . "8.3") :package-version '(Org . "8.3")
:group 'org-agenda) :group 'org-agenda)
@ -15536,8 +15528,6 @@ When a buffer is unmodified, it is just killed. When modified, it is saved
(org-get-agenda-file-buffer file)) (org-get-agenda-file-buffer file))
(org-with-wide-buffer (org-with-wide-buffer
(org-set-regexps-and-options 'tags-only) (org-set-regexps-and-options 'tags-only)
(or (memq 'category org-agenda-ignore-properties)
(org-refresh-category-properties))
(or (memq 'stats org-agenda-ignore-properties) (or (memq 'stats org-agenda-ignore-properties)
(org-refresh-stats-properties)) (org-refresh-stats-properties))
(or (memq 'effort org-agenda-ignore-properties) (or (memq 'effort org-agenda-ignore-properties)

View File

@ -6911,47 +6911,39 @@ Paragraph<point>"
(org-refresh-properties "A" 'org-test)) (org-refresh-properties "A" 'org-test))
(get-text-property (point) 'org-test))))) (get-text-property (point) 'org-test)))))
(ert-deftest test-org/refresh-category-properties () (ert-deftest test-org/get-category ()
"Test `org-refresh-category-properties' specifications" "Test `org-get-category' specifications."
(should (should
(equal "cat1" (equal "cat1"
(org-test-with-temp-text (org-test-with-temp-text
":PROPERTIES:\n:CATEGORY: cat1\n:END:" ":PROPERTIES:\n:CATEGORY: cat1\n:END:"
(org-refresh-category-properties) (org-get-category))))
(org-get-category))))
(should (should
(equal "cat1" (equal "cat1"
(org-test-with-temp-text (org-test-with-temp-text
"* H\n:PROPERTIES:\n:CATEGORY: cat1\n:END:" "* H\n:PROPERTIES:\n:CATEGORY: cat1\n:END:"
(org-refresh-category-properties) (org-get-category))))
(org-get-category))))
;; Even though property-inheritance is deactivated, category ;; Even though property-inheritance is deactivated, category
;; property should be inherited. As described in ;; property should be inherited. As described in
;; `org-use-property-inheritance'. ;; `org-use-property-inheritance'.
(should (should
(equal "cat1" (equal "cat1"
(org-test-with-temp-text (let ((org-use-property-inheritance nil))
":PROPERTIES:\n:CATEGORY: cat1\n:END:\n<point>* H" (org-test-with-temp-text
(org-mode-restart) ":PROPERTIES:\n:CATEGORY: cat1\n:END:\n<point>* H"
(let ((org-use-property-inheritance nil)) (org-get-category)))))
(org-refresh-category-properties))
(org-get-category))))
(should (should
(equal "cat1" (equal "cat1"
(org-test-with-temp-text (let ((org-use-property-inheritance t))
":PROPERTIES:\n:CATEGORY: cat1\n:END:\n<point>* H" (org-test-with-temp-text
(org-mode-restart) ":PROPERTIES:\n:CATEGORY: cat1\n:END:\n<point>* H"
(let ((org-use-property-inheritance t)) (org-get-category)))))
(org-refresh-category-properties))
(org-get-category))))
(should (should
(equal "cat2" (equal "cat2"
(org-test-with-temp-text (let ((org-use-property-inheritance t))
":PROPERTIES:\n:CATEGORY: cat1\n:END:\n<point>* H\n:PROPERTIES:\n:CATEGORY: cat2\n:END:\n" (org-test-with-temp-text
(org-mode-restart) ":PROPERTIES:\n:CATEGORY: cat1\n:END:\n<point>* H\n:PROPERTIES:\n:CATEGORY: cat2\n:END:\n"
(let ((org-use-property-inheritance t)) (org-get-category))))))
(org-refresh-category-properties))
(org-get-category)))))
;;; Refile ;;; Refile