From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Mathias Dahl Newsgroups: gmane.emacs.devel Subject: Re: Abbrev suggestions - feedback appreciated Date: Sun, 17 May 2020 00:22:39 +0200 Message-ID: References: <871smeoalc.fsf@gnu.org> <87fuatmw71.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000c84e3405a5cb5e6d" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="47027"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun May 17 00:23:23 2020 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ja5DG-000C9q-Nl for ged-emacs-devel@m.gmane-mx.org; Sun, 17 May 2020 00:23:22 +0200 Original-Received: from localhost ([::1]:35718 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ja5DF-0007T2-QN for ged-emacs-devel@m.gmane-mx.org; Sat, 16 May 2020 18:23:21 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:46744) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ja5Cm-000734-Jf for emacs-devel@gnu.org; Sat, 16 May 2020 18:22:52 -0400 Original-Received: from mail-vs1-xe33.google.com ([2607:f8b0:4864:20::e33]:41431) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ja5Cl-0003OH-Ph for emacs-devel@gnu.org; Sat, 16 May 2020 18:22:52 -0400 Original-Received: by mail-vs1-xe33.google.com with SMTP id y13so3398362vsk.8 for ; Sat, 16 May 2020 15:22:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ztCBaCmRdv9LV2Ah9aJMpqtcfRCB180TZonNuOMgk/A=; b=QLqhzS9zUA4nHxqP2xaB9vh/A3glY4GFT63K/aNFqfLwOZWyodHJpKQW0dKLHxJbo/ taHD47mpKsswguZfyDEidXtFXB+4b5vxldVG/U0QSI1XwqHWYoLbWfQvdFI8CKaepEzF YNOPC3xM3YJmMyMODMXDxjuM3WY6drl+/Pu9o4CD7f4sGFTuiauebQcuwwQY0fcdBSEr d670W75WABlj4xGxfqOeIkxfifX9fiKES6AcYw0yLS4Y7UlbuvXDDwiQpo7oKb9Hmh5q 49SFvpcnfTH0Bs5cQg2nPAA6wrsN86dPl/ir2JitnrTn/zI3WD2KBXchuJUEKago+MC/ SF1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ztCBaCmRdv9LV2Ah9aJMpqtcfRCB180TZonNuOMgk/A=; b=ARdTXumT83Ti98fYVlJyWBEtf33FqDcoTdFKSPDgQKbIGR2oo1CzSDnALtOeISG3YT nE4a8tZhk0b4bOJdstyv+cLbCZJtRkXmStU7Ur3OZFYpGjDXi8GchMMI5/JJYoRWlOtC Qml5Aenj7btiWqIUl0b0es/utFW6LIv3GQi4sP7cEL2yqH9AuP+dqryAotVTus0LEXMW ypnxRwGNV6/UEQNdHGdx4KDIKx/ysDEI9QYVHynckYe0z68JVxjAZX0UmXkgF44qB744 k+FSbhJf/uCWsyNJ/atyUnl20c6usXBjhLYWeQT9NZQPw+VmjTuQii/BLJPB746lRry3 DBNA== X-Gm-Message-State: AOAM530ygfTQ9l0pnVaHwQPSL9LrhY2JicSjZmUYDbQReAehuoVl5KMK fOsON07bZesDdmOm255AcIqugz/V0kx1coObyxqZ2XRZjwQ= X-Google-Smtp-Source: ABdhPJws0TVS3wHxyOU7GlFliM6Pr42R7vVhENu1P/jayb2kTpOCeFulCkIGkKV2QDeF3Z+VXipJU+3OW4oxherJdWw= X-Received: by 2002:a67:f356:: with SMTP id p22mr2914505vsm.130.1589667770681; Sat, 16 May 2020 15:22:50 -0700 (PDT) In-Reply-To: Received-SPF: pass client-ip=2607:f8b0:4864:20::e33; envelope-from=mathias.dahl@gmail.com; helo=mail-vs1-xe33.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:250532 Archived-At: --000000000000c84e3405a5cb5e6d Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Sun, May 17, 2020 at 12:10 AM Mathias Dahl wrote: > >> 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)) > I gave the mapc approach a na=C3=AFve try, but I am not sure if it is bette= r: (defun abbrev-get-active-expansions () "Return a list of all the active abbrev expansions. Includes expansions from parent abbrev tables." (let (expansions) (mapc (lambda (table) (mapatoms (lambda (e) (let ((value (symbol-value (abbrev--symbol e table)))) (when value (push (cons value (symbol-name e)) expansions)))) table)) (abbrev--active-tables-including-parents)) expansions)) --000000000000c84e3405a5cb5e6d Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


=
On Sun, May 17, 2020 at 12:10 AM Math= ias Dahl <mathias.dahl@gmail.c= om> wrote:
>> 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 (perfor= mance, or
> saving memory?).

The idea is to avoid the memory allocation, yes.=C2=A0 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 v= alues. 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 n= eed to collect those in some "list" of some kind, which I return = in=C2=A0
the end. This intermediate list you mention, is that hid= den 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 functio= n again, for convenience:

=C2=A0(defun abbrev-get-= active-expansions ()
=C2=A0 "Return a list of all the active abbr= ev expansions.
Includes expansions from parent abbrev tables."
= =C2=A0 (let (expansions)
=C2=A0 =C2=A0 (dolist (table (abbrev--active-ta= bles-including-parents))
=C2=A0 =C2=A0 =C2=A0 (mapatoms (lambda (e)
= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (let ((value= (symbol-value (abbrev--symbol e table))))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (when value
=C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (push (cons val= ue (symbol-name e)) expansions))))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 table))
=C2=A0 =C2=A0 expansions))
<= /blockquote>

I gave the mapc approach a na=C3=AFve try, = but I am not sure if it is better:

(defun abbrev-get-ac= tive-expansions ()
=C2=A0 "Return a list of all the active abbrev e= xpansions.
Includes expansions from parent abbrev tables."
=C2= =A0 (let (expansions)
=C2=A0 =C2=A0 (mapc (lambda (table)
=C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (mapatoms (lambda (e)
=C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (let ((v= alue (symbol-value (abbrev--symbol e table))))
=C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (when va= lue
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (push (cons value (symbol-name e)) expansio= ns))))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 table))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (abbrev--active= -tables-including-parents))
=C2=A0 =C2=A0 expansions))


<= /div>
=C2=A0
--000000000000c84e3405a5cb5e6d--