From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Mark Oteiza Newsgroups: gmane.emacs.devel Subject: [PATCH] Complete temperature units in calc-convert-temperature Date: Fri, 19 Feb 2016 12:42:32 -0500 Message-ID: <20160219174232.GA11806@holos> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1455904093 31786 80.91.229.3 (19 Feb 2016 17:48:13 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 19 Feb 2016 17:48:13 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Feb 19 18:48:07 2016 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1aWp9u-0008Ay-VH for ged-emacs-devel@m.gmane.org; Fri, 19 Feb 2016 18:48:03 +0100 Original-Received: from localhost ([::1]:54238 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aWp9u-0001WB-CV for ged-emacs-devel@m.gmane.org; Fri, 19 Feb 2016 12:48:02 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:44977) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aWp4i-0000Nu-Vc for emacs-devel@gnu.org; Fri, 19 Feb 2016 12:42:41 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aWp4f-0007cv-PH for emacs-devel@gnu.org; Fri, 19 Feb 2016 12:42:40 -0500 Original-Received: from mail-qg0-x22e.google.com ([2607:f8b0:400d:c04::22e]:33918) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aWp4f-0007cU-Ib for emacs-devel@gnu.org; Fri, 19 Feb 2016 12:42:37 -0500 Original-Received: by mail-qg0-x22e.google.com with SMTP id b67so67067319qgb.1 for ; Fri, 19 Feb 2016 09:42:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=udel-edu.20150623.gappssmtp.com; s=20150623; h=date:from:to:subject:message-id:mime-version:content-type :content-disposition:user-agent; bh=eyEEbYhJRa8f/k17hiCaczD0H7UXmn12p3onUk4AZO0=; b=0Dw3Gx0DcpXWV35IpK4MUL0bDuXdQHUymjOQi2vbOwPwQwZrTxT8M4WUURisEbKxEP S36qiVpkDkW5jPx3k/jS2EVtvgS9DF2/f9RKTsRasoaAN2B+9mzprw2911AGNXruDSQj +y8LYYww0s02fn20n0nLvrsRTHi58Ex+jFSuVRZlh+AHsZ5HWGh/+uJBXSOV3pxOFqI0 5MPVI5ONcUTe2ITOKV9e81tQw4Zj5AV3AGsGPEKWATJBQF7sCmthbO2y22iWqNcqUu8R t3A7ZcH8Bu5LHMJ1KKrMu5vF2bqdImXn02OqIwv3YoEL0qJsANW6f7mmqMiOQScU1sV0 FPlQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:subject:message-id:mime-version :content-type:content-disposition:user-agent; bh=eyEEbYhJRa8f/k17hiCaczD0H7UXmn12p3onUk4AZO0=; b=OyO1wrbF+srMX33L6b7drTL5MHbnz2JZOzeG4HaFbIgikj32VFC62PnJIlocILx+T+ zYgCQuOD+GAc+avLeBEaqQ7PkVjdpli6KRSx9PEDvgL5+xRG93aQMhWe8eVRglATOuAH +VR/SahBarFSgCofeANYeYrjKQwKuwdGGYbnD7zNEXQr2G6GmpOXmucdOrrUAYmvk9GN tDLYZ6Y9fOjiaKEXXnofP4yyg/u5IA8u0frTFcL2hmb2iZQ6HA1YoLDxWvW+ZWTf9/Db 2I+Q3wHJIjF965U8SspW7zacxUjG7MRTR9XqaBLueXnZNOpS2+XY5MbF+iPFOMD3uEsK 8T2w== X-Gm-Message-State: AG10YORIAGcVScTTJlmkY6j7zu7DXOBuwojoPr2IETZ6mmygaO0haR5OmqhJYMuvLi+l9i2K X-Received: by 10.140.92.181 with SMTP id b50mr17690304qge.44.1455903756685; Fri, 19 Feb 2016 09:42:36 -0800 (PST) Original-Received: from holos.localdomain (wifi-roaming-128-4-119-157.host.udel.edu. [128.4.119.157]) by smtp.gmail.com with ESMTPSA id v84sm200257qkl.15.2016.02.19.09.42.34 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 19 Feb 2016 09:42:34 -0800 (PST) Original-Received: by holos.localdomain (Postfix, from userid 1000) id A18B0685D5; Fri, 19 Feb 2016 12:42:32 -0500 (EST) Content-Disposition: inline User-Agent: Mutt/1.5.24+59 (b55c6a64a07b) (2015-08-30) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:400d:c04::22e X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 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-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:200226 Archived-At: --- IIUC, user defined units cannot be temperatures, so deriving a collection of temperature units from math-standard-units as opposed to the generated math-units-tables should be fine. diff --git a/lisp/calc/calc-units.el b/lisp/calc/calc-units.el index 07d9ac9..525e3e2 100644 --- a/lisp/calc/calc-units.el +++ b/lisp/calc/calc-units.el @@ -565,7 +565,12 @@ If COMP or STD is non-nil, put that in the units table instead." (defun calc-convert-temperature (&optional old-units new-units) (interactive) (calc-slow-wrapper - (let ((expr (calc-top-n 1)) + (let ((tempunits (delq nil + (mapcar + (lambda (x) + (if (nth 3 x) (car x))) + math-standard-units))) + (expr (calc-top-n 1)) (uold nil) (uoldname nil) unew @@ -580,15 +585,16 @@ If COMP or STD is non-nil, put that in the units table instead." (car units))))) (error "Not a pure temperature expression")) (math-read-expr - (setq uoldname (read-string - "Old temperature units: "))))))) + (setq uoldname (completing-read + "Old temperature units: " + tempunits))))))) (when (eq (car-safe uold) 'error) (error "Bad format in units expression: %s" (nth 2 uold))) (or (math-units-in-expr-p expr nil) (setq expr (math-mul expr uold))) (setq defunits (math-get-default-units expr)) (setq unew (or new-units - (read-string + (completing-read (concat (if uoldname (concat "Old temperature units: " @@ -599,7 +605,8 @@ If COMP or STD is non-nil, put that in the units table instead." (concat " (default " defunits "): ") - ": "))))) + ": ")) + tempunits))) (setq unew (math-read-expr (if (string= unew "") defunits unew))) (when (eq (car-safe unew) 'error) (error "Bad format in units expression: %s" (nth 2 unew)))