From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.devel Subject: Re: Emacs i18n Date: Wed, 27 Mar 2019 23:22:07 +0200 Organization: LINKOV.NET Message-ID: <87d0mcui68.fsf@mail.linkov.net> References: <87o97aq6gz.fsf@jidanni.org> <87tvgoud56.fsf@mail.linkov.net> <83o96wk2mi.fsf@gnu.org> <87k1hjfvjd.fsf@mail.linkov.net> <871s3p0zdz.fsf@mail.linkov.net> <83h8ckezyt.fsf@gnu.org> <87h8cjspc0.fsf@mail.linkov.net> <29a53a39-fa50-1e94-9420-a3ea1250aa44@gmail.com> <87r2azq478.fsf@mail.linkov.net> <83o963s4gx.fsf@gnu.org> <87va09ckym.fsf@mail.linkov.net> <83sgvdndt0.fsf@gnu.org> <8736ncgcnm.fsf@mail.linkov.net> <87a7hir9xp.fsf@mail.linkov.net> <5417CC78-C70D-4AE2-869F-BA9FE1D40633@acm.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="12357"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (x86_64-pc-linux-gnu) Cc: Eli Zaretskii , emacs-devel@gnu.org, cpitclaudel@gmail.com, brandelune@gmail.com, rms@gnu.org To: Mattias =?iso-8859-1?Q?Engdeg=E5rd?= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Mar 27 22:47:50 2019 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h9GOj-00034e-Ik for ged-emacs-devel@m.gmane.org; Wed, 27 Mar 2019 22:47:50 +0100 Original-Received: from localhost ([127.0.0.1]:54231 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h9GOi-0001p3-KD for ged-emacs-devel@m.gmane.org; Wed, 27 Mar 2019 17:47:48 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:41074) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h9GOc-0001oy-Cf for emacs-devel@gnu.org; Wed, 27 Mar 2019 17:47:43 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h9GOb-0001LJ-9r for emacs-devel@gnu.org; Wed, 27 Mar 2019 17:47:42 -0400 Original-Received: from indri.birch.relay.mailchannels.net ([23.83.209.92]:4747) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h9GOZ-0001KC-A4; Wed, 27 Mar 2019 17:47:39 -0400 X-Sender-Id: dreamhost|x-authsender|jurta@jurta.org Original-Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id CF5DC3E4E53; Wed, 27 Mar 2019 21:47:35 +0000 (UTC) Original-Received: from pdx1-sub0-mail-a76.g.dreamhost.com (unknown [100.96.39.118]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id F11833E4E50; Wed, 27 Mar 2019 21:47:34 +0000 (UTC) X-Sender-Id: dreamhost|x-authsender|jurta@jurta.org Original-Received: from pdx1-sub0-mail-a76.g.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384) by 0.0.0.0:2500 (trex/5.17.2); Wed, 27 Mar 2019 21:47:35 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|jurta@jurta.org X-MailChannels-Auth-Id: dreamhost X-Print-Thread: 19e89ef36498d21f_1553723255391_4180749345 X-MC-Loop-Signature: 1553723255390:1245181345 X-MC-Ingress-Time: 1553723255390 Original-Received: from pdx1-sub0-mail-a76.g.dreamhost.com (localhost [127.0.0.1]) by pdx1-sub0-mail-a76.g.dreamhost.com (Postfix) with ESMTP id 41AFD8043E; Wed, 27 Mar 2019 14:47:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=linkov.net; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type:content-transfer-encoding; s=linkov.net; bh=p7Lbec Hyibvza5/FI0DXWGZ0bQk=; b=DkT5I5j0QmpI3RPcaDBdtwfLXLb72IfMOflGsZ S0C4+WFGNMnmUr1dPBSNVn64a/SJb4HY4HsMjiJs1oADgLbpGRlob2BcMYZmrCAK 3vA+eFZNTpmuUYeojBEjPIjzV4AMHLo7X6Hccff4mGkfEJN7vDCL7KnAvRJEbXOE g8EOM= Original-Received: from mail.jurta.org (m91-129-108-250.cust.tele2.ee [91.129.108.250]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: jurta@jurta.org) by pdx1-sub0-mail-a76.g.dreamhost.com (Postfix) with ESMTPSA id 20F8680952; Wed, 27 Mar 2019 14:47:29 -0700 (PDT) X-DH-BACKEND: pdx1-sub0-mail-a76 In-Reply-To: <5417CC78-C70D-4AE2-869F-BA9FE1D40633@acm.org> ("Mattias \=\?iso-8859-1\?Q\?Engdeg\=E5rd\=22's\?\= message of "Mon, 25 Mar 2019 23:05:03 +0100") X-VR-OUT-STATUS: OK X-VR-OUT-SCORE: -100 X-VR-OUT-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedutddrkeefgddtvdcutefuodetggdotefrodftvfcurfhrohhfihhlvgemucggtfgfnhhsuhgsshgtrhhisggvpdfftffgtefojffquffvnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvffuohhfffgjkfgfgggtgfesthekredttderjeenucfhrhhomheplfhurhhiucfnihhnkhhovhcuoehjuhhriheslhhinhhkohhvrdhnvghtqeenucfkphepledurdduvdelrddutdekrddvhedtnecurfgrrhgrmhepmhhouggvpehsmhhtphdphhgvlhhopehmrghilhdrjhhurhhtrgdrohhrghdpihhnvghtpeeluddruddvledruddtkedrvdehtddprhgvthhurhhnqdhprghthheplfhurhhiucfnihhnkhhovhcuoehjuhhriheslhhinhhkohhvrdhnvghtqedpmhgrihhlfhhrohhmpehjuhhriheslhhinhhkohhvrdhnvghtpdhnrhgtphhtthhopehmrghtthhirghsvgesrggtmhdrohhrghenucevlhhushhtvghrufhiiigvpedt X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 23.83.209.92 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 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.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:234794 Archived-At: >> Is it possible to generate a regexp from ngettext arguments? >> For example, given the same arguments and calling a hypothetical >> function =E2=80=98rx-ngettext=E2=80=99: >> >> (rx-ngettext "finished with %d match found\n" >> "finished with %d matches found\n") >> >> to generate a regexp like: >> >> "finished with \\(?:\\(\\(?:[0-9]+ \\)?match\\(?:es\\)? found\\)" > > Trivially so by generating an or-pattern: "singular text\\|plural text"= . > Anything better is a matter of optimisation, basically a diff algorithm > (or just prefix and suffix merging). > > Is it practical, though? For %s, we would need to generate a match-anyt= hing > subexpression, even though the argument is much more constrained in pra= ctice. I tried =E2=80=98regexp-opt=E2=80=99 and it generates a ready-to-use rege= xp: (replace-regexp-in-string "%d" "\\\\([0-9]+\\\\)" (regexp-opt '("finished with %d match found" "finished with %d matches found" "finished with no matches found"))) =E2=87=92 "\\(?:finished with \\(?:\\(?:\\([0-9]+\\) match\\(?:es\\)?\\= |no matches\\) found\\)\\)"