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:10:08 +0200 Message-ID: References: <871smeoalc.fsf@gnu.org> <87fuatmw71.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000fcb38d05a5cb31a7" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="128591"; 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:11:09 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 1ja51P-000XNK-Jp for ged-emacs-devel@m.gmane-mx.org; Sun, 17 May 2020 00:11:07 +0200 Original-Received: from localhost ([::1]:57572 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ja51O-0003Mn-Jo for ged-emacs-devel@m.gmane-mx.org; Sat, 16 May 2020 18:11:06 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:45532) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ja50f-0002Zx-Fv for emacs-devel@gnu.org; Sat, 16 May 2020 18:10:21 -0400 Original-Received: from mail-ua1-x933.google.com ([2607:f8b0:4864:20::933]:41023) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ja50e-0000R1-JY for emacs-devel@gnu.org; Sat, 16 May 2020 18:10:21 -0400 Original-Received: by mail-ua1-x933.google.com with SMTP id k3so2122165ual.8 for ; Sat, 16 May 2020 15:10:19 -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=pUtU/+AcSeE2uATIJnZp2mCTVfbfobcl0fZogvwd5Bg=; b=gy4KhEdB6n6uztQk1unvBuuVWvjwqqgThinI/f1yfXoUJ578aBbb0vzt5bVvFY9dlk 2eb3PRhQJwbdXpiQWQlPz/0KJWpjfwAuSdcYBME654KYBqQ2bmEmx4f7yU5Y8Zdquz0z 3/Eun6Y2jNwnbM9dUNnRZllD258FoKjY8OBBjydjey9reclyNdDdNO3Qatz1lN4qNCfl lJO6TyGi3Z1K1UXMk0rn30vL7InruofmrbLRkO2UKGgO2RRSgAx1NqULcs7xiuN148Hq Hnlc1JlRhGm83N/4zJHkMkgpCj8cHbJtIzGbUebLnEKdwblCyX9KxF4Q1i8aE1nTIZNm bNEQ== 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=pUtU/+AcSeE2uATIJnZp2mCTVfbfobcl0fZogvwd5Bg=; b=um1CjErMKTmZYk6JJITRRygx98DofgA6Oljpyt1KmHdKjyMmRgHTYNAIxAB1DourAf etoz9cm40qz7mMFA4D1pBiEyTTTX2NIlPeSSy+iITIGSe4o4MZvaWfM74hsbzlE8tgun Qk8v6WsczxhvO5sqriaByO3XYNJbuEARiOhAaMRGoeSOkNe+TJ2fBer7w//OJKc+yjhj 9G3O0acu7q7Z4CQBPL9uRiYQjtUEqWnVPJd2WwkmBFDbiP3jrWnpUq660HGZbGkpQ3sH 1RTFv9JHECdVwgoQH6jvom9oHaf4MpWNSW2ga5hdtYj+rLiG8vE2veyZY20BrZYcF1cj ci3w== X-Gm-Message-State: AOAM531CGnPEvzpWMv3uWh8i63uU/HxX9QLTAT8POGcXPgOvkFC49r5o RQfAg1GpzyYjTM6VNlQvajUlXL9bftaIrGIslAfWcftcx28= X-Google-Smtp-Source: ABdhPJyE6FivcNbXLDA3a1xHQZ86Yy3si0fj+kGM34hNW9ZbTsIJcmPcTAAJWLtR/voUIWSkcWY2QSvcIwsIG/CNWpk= X-Received: by 2002:ab0:700f:: with SMTP id k15mr7401359ual.75.1589667019140; Sat, 16 May 2020 15:10:19 -0700 (PDT) In-Reply-To: Received-SPF: pass client-ip=2607:f8b0:4864:20::933; envelope-from=mathias.dahl@gmail.com; helo=mail-ua1-x933.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:250531 Archived-At: --000000000000fcb38d05a5cb31a7 Content-Type: text/plain; charset="UTF-8" > > >> 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 --000000000000fcb38d05a5cb31a7 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
>> I think you'd be better served defining a d= olist-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))

Thanks!

<= div class=3D"gmail_quote">/Mathias

--000000000000fcb38d05a5cb31a7--