emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] /srv/bzr/emacs/trunk r111714: * doc/misc/calc.texi (Basic


From: Jay Belanger
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r111714: * doc/misc/calc.texi (Basic Operations on Units):
Date: Sat, 09 Feb 2013 17:17:05 -0600
User-agent: Bazaar (2.5.0)

------------------------------------------------------------
revno: 111714
committer: Jay Belanger <address@hidden>
branch nick: trunk
timestamp: Sat 2013-02-09 17:17:05 -0600
message:
  * doc/misc/calc.texi (Basic Operations on Units):
    (Customizing Calc): Mention the variable `calc-allow-units-as-numbers'.
  
  * lisp/calc/calc.el (calc-allow-units-as-numbers): New variable.
  * lisp/calc/calc-units.el (calc-convert-units): Use new variable.
modified:
  doc/misc/ChangeLog
  doc/misc/calc.texi
  lisp/ChangeLog
  lisp/calc/calc-units.el
  lisp/calc/calc.el
=== modified file 'doc/misc/ChangeLog'
--- a/doc/misc/ChangeLog        2013-02-08 17:23:24 +0000
+++ b/doc/misc/ChangeLog        2013-02-09 23:17:05 +0000
@@ -1,3 +1,8 @@
+2013-02-09  Jay Belanger  <address@hidden>
+
+       * calc.texi (Basic Operations on Units):
+       (Customizing Calc): Mention the variable `calc-allow-units-as-numbers'.
+
 2013-02-08  Aidan Gauland  <address@hidden>
 
        * eshell.texi: Fill most of the missing sections.

=== modified file 'doc/misc/calc.texi'
--- a/doc/misc/calc.texi        2013-02-01 03:58:50 +0000
+++ b/doc/misc/calc.texi        2013-02-09 23:17:05 +0000
@@ -27866,11 +27866,6 @@
 ``fundamental'' units like @samp{m} and @samp{s}, regardless of the
 input units.
 
-If you want to disallow using inconsistent units, you can set the customizable 
variable
address@hidden to @code{t} (@pxref{Customizing Calc}).  In this case,
-if you request units which are inconsistent with the original units, you will 
be warned about
-it and no conversion will occur.
-
 One special exception is that if you specify a single unit name, and
 a compatible unit appears somewhere in the units expression, then
 that compatible unit will be converted to the new unit and the
@@ -27880,6 +27875,12 @@
 The ``remainder unit'' @samp{cm} is left alone rather than being
 changed to the base unit @samp{m}.
 
+If you want to disallow using inconsistent units, you can set the
+customizable variable @code{calc-ensure-consistent-units} to @code{t}
+(@pxref{Customizing Calc}).  In this case, if you request units which
+are inconsistent with the original units, you will be warned about it
+and no conversion will occur.
+
 You can use explicit unit conversion instead of the @kbd{u s} command
 to gain more control over the units of the result of an expression.
 For example, given @samp{5 m + 23 mm}, you can type @kbd{u c m} or
@@ -27912,10 +27913,16 @@
 
 If the value on the stack does not contain any units, @kbd{u c} will
 prompt first for the old units which this value should be considered
-to have, then for the new units.  Assuming the old and new units you
-give are consistent with each other, the result also will not contain
-any units.  For example, @address@hidden c} cm @key{RET} in @key{RET}}
-converts the number 2 on the stack to 5.08.
+to have, then for the new units.  (If the value on the stack can be
+simplified so that it doesn't contain any units, like @samp{ft/in} can
+be simplified to 12, then @kbd{u c} will still prompt for both old
+units and new units. You can ignore the prompt for old units with
address@hidden, or turn off the prompt by setting the customizable variable
address@hidden to @code{nil}. 
address@hidden Calc})  Assuming the old and new units you give are
+consistent with each other, the result also will not contain any
+units.  For example, @address@hidden c} cm @key{RET} in @key{RET}} converts
+the number 2 on the stack to 5.08.
 
 @kindex u b
 @pindex calc-base-units
@@ -35694,6 +35701,17 @@
 is @code{nil}.
 @end defvar
 
address@hidden calc-allow-units-as-numbers
+When converting units, the variable @code{calc-allow-units-as-numbers}
+determines whether or not values which can be simplified so that
+they don't contain units (such as @samp{ft/in} can be simplified to 12)
+can be regarded as not containing units.  If 
address@hidden is address@hidden, then @kbd{u c}
+will prompt for both old units and new units when converting an expression
+like @samp{ft/in}, otherwise @kbd{u c} will only prompt for the new units.
+The default value of @code{calc-allow-units-as-numbers} is @code{t}.
address@hidden defvar
+
 @defvar calc-undo-length
 The variable @code{calc-undo-length} determines the number of undo
 steps that Calc will keep track of when @code{calc-quit} is called.

=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2013-02-09 16:20:29 +0000
+++ b/lisp/ChangeLog    2013-02-09 23:17:05 +0000
@@ -1,3 +1,9 @@
+2013-02-09  Jay Belanger  <address@hidden>
+
+       * calc/calc.el (calc-allow-units-as-numbers): New variable.
+       * calc/calc-units.el (calc-convert-units): Use new variable.
+
+
 2013-02-09  Eli Zaretskii  <address@hidden>
 
        * subr.el (buffer-file-type, default-buffer-file-type): Remove.

=== modified file 'lisp/calc/calc-units.el'
--- a/lisp/calc/calc-units.el   2013-01-30 14:14:27 +0000
+++ b/lisp/calc/calc-units.el   2013-02-09 23:17:05 +0000
@@ -437,17 +437,22 @@
                  (list new-units (car default-units))
                  math-default-units-table))))))
 
+(defvar calc-allow-units-as-numbers)
+
 (defun calc-convert-units (&optional old-units new-units)
   (interactive)
   (calc-slow-wrapper
    (let ((expr (calc-top-n 1))
         (uoldname nil)
          (unitscancel nil)
+         (nouold nil)
         unew
          units
          defunits)
      (if (or (not (math-units-in-expr-p expr t))
-             (setq unitscancel (eq (math-get-standard-units expr) 1)))
+             (setq unitscancel (and
+                                calc-allow-units-as-numbers
+                                (eq (math-get-standard-units expr) 1))))
        (let ((uold (or old-units
                       (progn
                         (setq uoldname 
@@ -457,6 +462,7 @@
                                  (read-string "Old units: ")))
                         (if (equal uoldname "")
                             (progn
+                               (setq nouold unitscancel)
                               (setq uoldname "1")
                               1)
                           (if (string-match "\\` */" uoldname)
@@ -469,7 +475,7 @@
      (unless new-units
        (setq new-units
              (read-string (concat
-                           (if uoldname
+                           (if (and uoldname (not nouold))
                                (concat "Old units: "
                                        uoldname
                                        ", new units")

=== modified file 'lisp/calc/calc.el'
--- a/lisp/calc/calc.el 2013-01-11 23:08:55 +0000
+++ b/lisp/calc/calc.el 2013-02-09 23:17:05 +0000
@@ -426,6 +426,14 @@
   :version "24.3"
   :type 'boolean)
 
+(defcustom calc-allow-units-as-numbers
+  t
+  "If non-nil, allow unit expressions to be treated like numbers 
+when converting units, if the expression can be simplified to be unitless."
+  :group 'calc
+  :version "24.4"
+  :type 'boolean)
+
 (defcustom calc-undo-length
   100
   "The number of undo steps that will be preserved when Calc is quit."


reply via email to

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