emacs-devel
[Top][All Lists]
Advanced

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

Re: Abbrev suggestions - feedback appreciated


From: Mathias Dahl
Subject: Re: Abbrev suggestions - feedback appreciated
Date: Sun, 17 May 2020 00:10:08 +0200

>> I think you'd be better served defining a dolist-style macro or
>> a mapc-style function to loop over all abbrevs without creating an
>> intermediate list.
> Sorry, I don't understand what you are suggesting, and why (performance, or
> saving memory?).

The idea is to avoid the memory allocation, yes.  It should improve
performance and reduce the frequency of GC pauses.

I think I don't understand the alternatives here. Firstly, I think I need to use
mapatoms to look for the abbrev names and values. That then, needs to run
in some kind of loop, for all the active abbrev tables. As I find non-nil entries
in the table, I need to collect those in some "list" of some kind, which I return in 
the end. This intermediate list you mention, is that hidden in the dolist macro,
or what is your thinking? And, if so, is the idea to make something similar to dolist
that does "the mapatoms thing" as well?

Here is the function again, for convenience:

 (defun abbrev-get-active-expansions ()
  "Return a list of all the active abbrev expansions.
Includes expansions from parent abbrev tables."
  (let (expansions)
    (dolist (table (abbrev--active-tables-including-parents))
      (mapatoms (lambda (e)
                  (let ((value (symbol-value (abbrev--symbol e table))))
                    (when value
                      (push (cons value (symbol-name e)) expansions))))
                table))
    expansions))

Thanks!

/Mathias


reply via email to

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