Hello Clément,

On 2018-04-12 22:52, Clément Pit-Claudel <[email protected]> writes:

> Can you try adding the following to your .emacs?
>
> (package-initialize)
> (require 'ledger-mode)
>
> (defun ledger-accounts-deduplicate-sorted (l)
>   "Remove duplicates from a sorted list of strings L."
>   (let ((current l))
>     (while (consp current)
>       (if (string= (car current) (cadr current))
>           (setcdr current (cddr current))
>         (pop current)))
>     l))
>
> (defun ledger-accounts-list-in-buffer ()
>   "Return a list of all known account names in the current buffer as strings.
> Considers both accounts listed in postings and those declared with 
> \"account\" directives."
>   (save-excursion
>     (goto-char (point-min))
>     (let (results)
>       (while (re-search-forward ledger-account-name-or-directive-regex nil t)
>         (setq results (cons (match-string-no-properties 2) results)))
>       (ledger-accounts-deduplicate-sorted
>        (sort results #'ledger-string-greaterp)))))
>
> This patches ledger-accounts-list-in-buffer to use a linear-time
> deduplication (rather than quadratic).

Thanks a lot! Completion is now as fast as before.

Best,

Alan

-- 
OpenPGP Key ID : 040D0A3B4ED2E5C7
Monthly Athmospheric CO₂, Mauna Loa Obs. 2018-03: 409.46, 2017-03: 407.18

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"Ledger" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Attachment: signature.asc
Description: PGP signature

Reply via email to