From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: zv Newsgroups: gmane.emacs.devel Subject: Re: [PATCH] Complete temperature units in calc-convert-temperature Date: Fri, 19 Feb 2016 15:41:37 -0800 Message-ID: References: <20160219174232.GA11806@holos> Reply-To: zv@nxvr.org NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1455925338 18288 80.91.229.3 (19 Feb 2016 23:42:18 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 19 Feb 2016 23:42:18 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Feb 20 00:42:05 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 1aWugV-0001PM-DV for ged-emacs-devel@m.gmane.org; Sat, 20 Feb 2016 00:42:03 +0100 Original-Received: from localhost ([::1]:56296 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aWugU-0004Vq-NY for ged-emacs-devel@m.gmane.org; Fri, 19 Feb 2016 18:42:02 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:59768) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aWugI-0004Vg-CT for emacs-devel@gnu.org; Fri, 19 Feb 2016 18:41:51 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aWugF-0000gN-6V for emacs-devel@gnu.org; Fri, 19 Feb 2016 18:41:50 -0500 Original-Received: from plane.gmane.org ([80.91.229.3]:46922) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aWugE-0000fs-Vm for emacs-devel@gnu.org; Fri, 19 Feb 2016 18:41:47 -0500 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1aWugD-0001AM-5n for emacs-devel@gnu.org; Sat, 20 Feb 2016 00:41:45 +0100 Original-Received: from c-73-15-212-83.hsd1.ca.comcast.net ([73.15.212.83]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 20 Feb 2016 00:41:45 +0100 Original-Received: from zv by c-73-15-212-83.hsd1.ca.comcast.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 20 Feb 2016 00:41:45 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 57 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: c-73-15-212-83.hsd1.ca.comcast.net User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.0 In-Reply-To: <20160219174232.GA11806@holos> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 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:200251 Archived-At: On 02/19/2016 09:42 AM, Mark Oteiza wrote: > --- > 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))) > > Synchronicity! Too weird, I was just working on a patch for this.