helm-apropos
is indeed pretty slow. I think it comes from joining 5
very large lists:
helm-apropos-function-list
;; =>
;; (helm-def-source--emacs-commands
;; helm-def-source--emacs-functions
;; helm-def-source--eieio-classes
;; helm-def-source--eieio-generic
;; helm-def-source--emacs-variables
;; helm-def-source--emacs-faces
;; helm-def-source--helm-attributes)
You can speed it up by generating one huge list right off the bat:
(defun helm-fast-apropos ()
(interactive)
(helm :sources
'((name . "apropos: ")
(candidates .
(lambda ()
(all-completions "" obarray
(lambda (x)
(or
;; commands
(commandp x)
;; functions
(fboundp x)
;; EIEIO class
(class-p x)
;; EIEIO generic
(generic-p x)
;; variable
(and (boundp x) (not (keywordp x))))))))
(action . (lambda (x)
(setq x (intern x))
(cond ((boundp x)
(describe-variable x))
((fboundp x)
(describe-function x))))))))
I also just had a quick look at the ivy equivalent of the above,
I think it's around 0.2s faster:
(defun ivy-apropos ()
(interactive)
(ivy-read "apropos: "
(all-completions "" obarray
(lambda (x)
(or
;; commands
(commandp x)
;; functions
(fboundp x)
;; EIEIO class
(class-p x)
;; EIEIO generic
(generic-p x)
;; variable
(and (boundp x) (not (keywordp x))))))
:keymap counsel-describe-map
:preselect (counsel-symbol-at-point)
:action (lambda (x)
(setq x (intern x))
(cond ((boundp x)
(describe-variable x))
((fboundp x)
(describe-function x))))))
Edit: typical approach for caching
Very simple: store the whole collection into a variable, and hope that it doesn't need to be recomputed;
recompute manually when needed (usually, when new packages are loaded):
(defvar helm-fast-apropos-cache nil)
(defun helm-update-apropos-cache ()
(interactive)
(setq helm-fast-apropos-cache
(all-completions "" obarray
(lambda (x)
(or
;; commands
(commandp x)
;; functions
(fboundp x)
;; EIEIO class
(class-p x)
;; EIEIO generic
(generic-p x)
;; variable
(and (boundp x) (not (keywordp x))))))))
(defun helm-fast-apropos ()
(interactive)
(helm :sources
(quote ((name . "apropos: ")
(candidates .
(lambda ()
(or helm-fast-apropos-cache
(helm-update-apropos-cache))))
(action . (lambda (x)
(setq x (intern x))
(cond ((boundp x)
(describe-variable x))
((fboundp x)
(describe-function x)))))))))
This approach saves only fraction of a second in this case, so it might not be worth it.
org-agenda-files
to only the ones you really need to query, or put everything in just one master file. Think of it like this: goto to the top of each file, then go to the first heading, then go to the time-stamp, then maybe skip, push data, then go to the next heading and repeat, push data, repeat until end of file, then move on to next file and . .org-agenda-list
will repeat the above-process for every day within the span --(while (setq d (pop day-numbers)) . . .
-- e.g., 31 days equals 31 loops through eachorg-agenda-file
--(while (setq file (pop files)) (catch 'nextfile . . .
-- with the same dance of headline/time-stamp/skip-maybe. If you were to create your own custom function, you may wish to consider gathering all of the data in one fell swoop, and programmatically manipulate/sort all of the data rather than sweeping through the buffer multiple times.org-agenda-list
and goes straight toorg-agenda-get-day-entries
to gather data: emacs.stackexchange.com/a/12563/2287 If you choose to write your own function to programmatically manipulate/sort all the data rather than sweep through the buffer multiple times, then you'll need to modify the functions used byorg-agenda-get-day-entries
-- e.g.,org-agenda-get-todos
;org-agenda-get-blocks
;org-agenda-get-timestamps
;org-agenda-get-sexps
;org-agenda-get-scheduled
;org-agenda-get-progress
;org-agenda-get-deadlines
.