From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Daniel Brooks Newsgroups: gmane.emacs.bugs Subject: bug#66944: 30.0.50; [PATCH] make calc parse fractions written using U+2044 FRACTION SLASH Date: Sat, 27 Jan 2024 05:11:33 -0800 Message-ID: <87bk96apkq.fsf@db48x.net> References: <87o7g8r4t8.fsf@db48x.net> <87wmsdnrgw.fsf@db48x.net> <861qa39m8g.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="16070"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 66944@debbugs.gnu.org, stefankangas@gmail.com To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Jan 27 14:12:12 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1rTiTi-0003vr-DC for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 27 Jan 2024 14:12:11 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rTiTW-0002vP-0h; Sat, 27 Jan 2024 08:11:58 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rTiTT-0002v1-Or for bug-gnu-emacs@gnu.org; Sat, 27 Jan 2024 08:11:55 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rTiTT-0002xD-Gr for bug-gnu-emacs@gnu.org; Sat, 27 Jan 2024 08:11:55 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rTiTa-0007dD-HX for bug-gnu-emacs@gnu.org; Sat, 27 Jan 2024 08:12:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Daniel Brooks Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 27 Jan 2024 13:12:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 66944 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 66944-submit@debbugs.gnu.org id=B66944.170636111429316 (code B ref 66944); Sat, 27 Jan 2024 13:12:02 +0000 Original-Received: (at 66944) by debbugs.gnu.org; 27 Jan 2024 13:11:54 +0000 Original-Received: from localhost ([127.0.0.1]:53631 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rTiTS-0007cj-6d for submit@debbugs.gnu.org; Sat, 27 Jan 2024 08:11:54 -0500 Original-Received: from out4-smtp.messagingengine.com ([66.111.4.28]:46835) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rTiTM-0007cH-Vi for 66944@debbugs.gnu.org; Sat, 27 Jan 2024 08:11:52 -0500 Original-Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id A4B5D5C0179; Sat, 27 Jan 2024 08:11:36 -0500 (EST) Original-Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Sat, 27 Jan 2024 08:11:36 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=db48x.net; h=cc :cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm1; t=1706361096; x=1706447496; bh=4RoNeyjYIv iZ6usnrFGLzwQmgfzaNV0ATT7m4byd0Lc=; b=S5ljsb0tSenJIjLQz32TgmOInD nN+P9o+6WkZVtrmFlx+dmLHdTpq7knhfHbKQaJUVSit+hI408DYO4uAXj65i5tsj QHRN5qirrQF4w+rIIcynnekBaYFGH1Ln18/M+/ZcKGn/VI7TpbCa7JVSHAIZUG7T crkkoa9S9Zp3wmjpsqASdOZaY5BVMWBJM7DNEt1UMaXdGBjmiGkPdU4O5rOFqHcR S4vuXk5xL6/MrHxG7Ac+vDwLqBgbGRY1zn1jDERtPR/UJcGekLO1HIIyGonJZgdt xB6dsClMoL2hrACZi7sgXV+Zvs3EkFNfiWC9V5yZH6g4us/cEnkaimBOq3QA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; t=1706361096; x=1706447496; bh=4RoNeyjYIviZ6usnrFGLzwQmgfza NV0ATT7m4byd0Lc=; b=CgCCnR+9hKkfiuv6Yd4Vyu459/IuYH0M9V8iVqa5hUBv 9DZrTZaKdq7EoEOlzkdG5+mm8zK31eLiFoAo9mM5gbbgxP+syMtqAOhVQ/0aec6R CXlWbI8EVyJWYlJII/t11jwokiIJA4ylKGUYdioOfYKOlAO8nj/0iqxrkPOdPS06 8pR/GIIvzHuVAikE1H++4XxtXrhKAWreClt6wwfmgczMwgaI2po7Eo3WCta+R0BM pvDg8y5/hj3zL3YnsE36gIff7NuQaMYrHcPOeQCx0Mz44Gm7Twrb3WjLduXJXq5y zo0A8J/YybPBVpBp+aPCqFH428mrxR/j0jjq8tTaGg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrvdelledggeelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefujghffffkfgggtgesmhdtreertderjeenucfhrhhomhepffgrnhhi vghluceurhhoohhkshcuoegusgegkeigsegusgegkeigrdhnvghtqeenucggtffrrghtth gvrhhnpeefgfevgeetheejgeegveetkedugedugfeuvddugfegvdetkeehtdekvefgfefh geenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegusg egkeigsegusgegkeigrdhnvght X-ME-Proxy: Feedback-ID: ie0194691:Fastmail Original-Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sat, 27 Jan 2024 08:11:35 -0500 (EST) In-Reply-To: <861qa39m8g.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 27 Jan 2024 11:09:03 +0200") Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAABGdBTUEAALGOfPtRkwAAABJQ TFRFpKfbdou67PD6JjJgAwUWXGSeIcyLHgAAAkZJREFUOI1VU8Fy6yAMxLi+Q13fCZ3cnQL3dqTc 7RD+/1feStDXVnXHDuvVSivZTMba2GPdw3gyCGcMAFxTyrTd9dwGoxHiZX9PmRFUHYAQlGGtXY+F Uk0SJOxgJiUEnH1qkitT9D+pQub7qGAmUbR6bu3CvI96Yv6QqkBBMrsyfZccr1/RDXGDTLf4P7ZY glVxe2V+/ACXWO1gvDO9/gDRpFFVmPluvLcmBjd5H6d8DEte+Pbk4rcY/Fa5tLKLOtCZsuQKYhpa LOkYDT7hESya7/WIET3lfQBqX0pwFtbI832Is0ayMUR9B+12xjgPCQ089cfwkCkX6L5TPmRelJTh zMS0Sz1PyjLAMCUWjcmgQLWQMds+e3aaauZDf9dU9A2/8kPVF2odCUoMKHkfjJR+mbgC+DRiycw5 3XSqGe6HmhN/AWjHypkAXOAFW5EiuA1ge2GiZuMb0s1fSEXcATeLUfbyEY2L8yPOmdSsdghQXx3K pz2eoeXuYvMCINVFDrCdNfVUp4eJ6cSEbjbgFjBEvonGGTrgv9cHjAc8aVgSAPoxaONbzfwhDIhR at7IIS7fAGiDSwIA9alhhTBzfA7YM2FY6eMwayrIGK8FDFmshmUA43WqhFtpvoqG9HHaJ7fqtgTz 8EWVkgZgtsylFliHDgk0MB7KAEC45C/rgnGvanNLXyzOeTzcT2nw/N44gfrtYXRQLoz9Q3TgmJRx 2Mx/Q51qzpm+l3m8z2SWBqC5+PZXAtNYlGFf/gKfHfjFkDT4x7od7R+w3Ls+ZdQBuQAAAABJRU5E rkJggg== X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:279000 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Eli Zaretskii writes: >> Cc: 66944@debbugs.gnu.org >> From: Daniel Brooks >> Date: Sat, 13 Jan 2024 08:11:27 -0800 >>=20 >> Fractions written as `2:3', `2=C3=B73', and `=E2=85=94' are all parsed a= s rational >> fractions; `2=E2=81=843' ought to do the same. > > Thanks, and apologies for a delay in reviewing the patch. You=E2=80=99re welcome. No need to apologize; this one=E2=80=99s nothing cr= itical. > I have some minor comments below, but I also see that we have no > copyright assignment from you, and without that we will be unable to > accept contributions from you after this one. Would you like to start > the paperwork of assigning the copyright to the FSF at this time, so > we could accept contributions from you in the future? I=E2=80=99ll remember to do it next time, if my next contribution is more t= han two sentences :) > Please try rewriting these to avoid non-ASCII characters in Texinfo > source files, since processing those with TeX could cause problems. > Where possible, please use the special Texinfo commands described in > the "Insertions" chapter of the Texinfo manual and its sections. If > some character cannot be written using ASCII characters as described > in that section, please just name it, as in "U+2044 FRACTION SLASH", > but don't include it verbatim. Thanks, I hadn=E2=80=99t read that. Done. > Also, our conventions are to leave two spaces between sentences in > documentation and comments (this is relevant to the NEWS entry as > well). Done. > This entry should be marked with "+++", as the necessary manual > changes were made. Also, this doesn't mention the precomposed > fractions; I think it should. Fair enough; done. Thank you Eli. --=-=-= Content-Type: text/x-patch; charset=utf-8 Content-Disposition: attachment; filename=0001-Calc-parses-fractions-written-using-U-2044-FRACTION-.patch Content-Transfer-Encoding: quoted-printable Content-Description: second revision of patch >From d3f08757f6570b70ec72951743b5bd41c1a10a54 Mon Sep 17 00:00:00 2001 From: Daniel Brooks Date: Sun, 5 Nov 2023 01:03:37 -0700 Subject: [PATCH] Calc parses fractions written using U+2044 FRACTION SLASH MIME-Version: 1.0 Content-Type: text/plain; charset=3DUTF-8 Content-Transfer-Encoding: 8bit Fractions of the form 123=E2=81=84456 are handled as if written 123:456. No= te in particular the difference in behavior from U+2215 DIVISION SLASH and U+002F SOLIDUS, which result in division rather than a rational fraction. * lisp/calc/calc-aent.el (math-read-replacement-list): Substitute a colon for any fraction slash. * test/lisp/calc/calc-tests.el (calc-frac-input): Test various fraction types. * doc/misc/calc.texi (Fractions): Mention fraction slash, precomposed fractions. Copyright-paperwork-exempt: yes --- doc/misc/calc.texi | 7 +++++++ etc/NEWS | 11 ++++++++++- lisp/calc/calc-aent.el | 1 + test/lisp/calc/calc-tests.el | 25 +++++++++++++++++++++++++ 4 files changed, 43 insertions(+), 1 deletion(-) diff --git a/doc/misc/calc.texi b/doc/misc/calc.texi index c651b007173..2ea97207edc 100644 --- a/doc/misc/calc.texi +++ b/doc/misc/calc.texi @@ -10571,6 +10571,13 @@ Fractions @samp{@var{radix}#@var{num}:@var{denom}} (or in the analogous three-part form). The numerator and denominator always use the same radix. =20 +Fractions may also be entered with @kbd{@U{2044}} (U+2044 FRACTION +SLASH) in place of any @kbd{:}. Precomposed fraction characters from +@kbd{@U{00BD}} (U+00BD VULGAR FRACTION ONE HALF) through +@kbd{@U{215E}} (U+215E VULGAR FRACTION SEVEN EIGHTHS) as supported as +well. Thus @samp{2:3}, @samp{2@U{2044}3}, and @samp{@U{2154}} are all +equivalent. + @node Floats @section Floats =20 diff --git a/etc/NEWS b/etc/NEWS index e29a787a0cc..2b3741fb5dc 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -983,7 +983,16 @@ URIs are now prefixed with "https://" instead. +++ *** New command 'customize-dirlocals'. This command pops up a buffer to edit the settings in ".dir-locals.el". - +** Calc ++++ +*** Calc parses fractions written using U+2044 FRACTION SLASH +Fractions of the form 123=E2=81=84456 are handled as if written 123:456. = Note +in particular the difference in behavior from U+2215 DIVISION SLASH +and U+002F SOLIDUS, which result in division rather than a rational +fraction. You may also be interested to know that precomposed +fraction characters, such as =C2=BD (U+00BD VULGAR FRACTION ONE HALF), are +also recognized as rational fractions. They have been since 2004, but +it looks like it was never mentioned in the NEWS, or even the manual. * New Modes and Packages in Emacs 30.1 =20 diff --git a/lisp/calc/calc-aent.el b/lisp/calc/calc-aent.el index 66ede3295ae..1dcb9ad1c85 100644 --- a/lisp/calc/calc-aent.el +++ b/lisp/calc/calc-aent.el @@ -505,6 +505,7 @@ math-read-replacement-list ("=E2=85=9D" "(5:8)") ; 5/8 ("=E2=85=9E" "(7:8)") ; 7/8 ("=E2=85=9F" "1:") ; 1/... + ("=E2=81=84" ":") ; arbitrary fractions of the form 123=E2=81=84456 ;; superscripts ("=E2=81=B0" "0") ; 0 ("=C2=B9" "1") ; 1 diff --git a/test/lisp/calc/calc-tests.el b/test/lisp/calc/calc-tests.el index 5b11dd950ba..e724295e8e0 100644 --- a/test/lisp/calc/calc-tests.el +++ b/test/lisp/calc/calc-tests.el @@ -734,6 +734,31 @@ calc-latex-input (var c var-c)))))) (calc-set-language nil))) =20 +(ert-deftest calc-frac-input () + ;; precomposed fraction + (should (equal (math-read-expr "=C2=BD") + '(frac 1 2))) + ;; ascii solidus + (should (equal (math-read-expr "123/456") + '(/ 123 456))) + (should (equal (math-read-expr "a/b") + '(/ (var a var-a) (var b var-b)))) + ;; fraction slash + (should (equal (math-read-expr "123=E2=81=84456") + '(frac 41 152))) + (should (equal (math-read-expr "a=E2=81=84b") + '(error 1 "Syntax error"))) + ;; division slash + (should (equal (math-read-expr "123=E2=88=95456") + '(/ 123 456))) + (should (equal (math-read-expr "a=E2=88=95b") + '(/ (var a var-a) (var b var-b)))) + ;; division sign + (should (equal (math-read-expr "123=C3=B7456") + '(frac 41 152))) + (should (equal (math-read-expr "a=C3=B7b") ; I think this one is wrong + '(error 1 "Syntax error")))) + (defvar var-g) =20 ;; Test `let'. --=20 2.43.0 --=-=-=--