emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] emacs-25 66d2717: Complete temperature units in calc-conve


From: Mark Oteiza
Subject: [Emacs-diffs] emacs-25 66d2717: Complete temperature units in calc-convert-temperature
Date: Thu, 03 Mar 2016 17:57:52 +0000

branch: emacs-25
commit 66d2717888f83d07067a131d9ef5c2b7a702bf82
Author: Mark Oteiza <address@hidden>
Commit: Mark Oteiza <address@hidden>

    Complete temperature units in calc-convert-temperature
    
    * lisp/calc/calc-units.el (calc-convert-temperature): Complete with
    temperature units in math-standard-units.
---
 lisp/calc/calc-units.el |   17 ++++++++++++-----
 1 files changed, 12 insertions(+), 5 deletions(-)

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)))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]