• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /macosx-10.10/emacs-93/emacs/lisp/calc/

Lines Matching defs:unit

1 ;;; calc-units.el --- unit conversion functions for Calc
257 (defvar math-unit-prefixes
312 (error "Bad unit number"))
375 "Adjusting target unit prefix automatically"
449 (let ((u (math-check-unit-name expr))
465 math-unit-prefixes))
532 (defun calc-define-unit (uname desc)
533 (interactive "SDefine unit name: \nsDescription: ")
536 (unit (assq uname math-additional-units)))
537 (or unit
539 (cons (setq unit (list uname nil nil))
542 (setcar (cdr unit) (and (not (and (eq (car-safe form) 'var)
546 (setcar (cdr (cdr unit)) (and (not (equal desc ""))
550 (defun calc-undefine-unit (uname)
551 (interactive "SUndefine unit name: ")
553 (let ((unit (assq uname math-additional-units)))
554 (or unit
556 (error "\"%s\" is a predefined unit name" uname)
558 (setq math-additional-units (delq unit math-additional-units)
574 (defun calc-get-unit-definition (uname)
575 (interactive "SGet definition for unit: ")
578 (let ((unit (assq uname math-units-table)))
579 (or unit
581 (let ((msg (nth 2 unit)))
586 (if (nth 1 unit)
588 (calc-enter-result 0 "ugdf" (nth 1 unit))
589 (message "Derived unit: %s" msg))
594 (message "Base unit: %s" msg))))))
638 ;; The variable math-cu-unit-list is local to math-build-units-table,
639 ;; but is used by math-compare-unit-names, which is called (indirectly)
641 ;; math-cu-unit-list is also local to math-convert-units, but is used
643 (defvar math-cu-unit-list)
649 (math-cu-unit-list (mapcar 'car combined-units))
683 (error "Circular definition involving unit %s" (car math-fbu-entry)))
689 (error "Dimensionless definition for unit %s" (car math-fbu-entry)))
697 (setq math-fbu-base (sort math-fbu-base 'math-compare-unit-names))
701 (defun math-compare-unit-names (a b)
702 (memq (car b) (cdr (memq (car a) math-cu-unit-list))))
705 (let ((u (math-check-unit-name expr)))
732 (error "Unknown name %s in defining expression for unit %s"
734 (t (error "Malformed defining expression for unit %s" (car math-fbu-entry))))))
740 (math-check-unit-name expr)
749 (math-check-unit-name expr)
760 (math-check-unit-name expr))
773 (defun math-check-unit-name (v)
778 (assq (aref name 0) math-unit-prefixes)
797 (let ((u (math-check-unit-name expr))
814 math-unit-prefixes))
848 (let ((u (math-check-unit-name units)))
857 qty unit)
859 (setq ulist (cons (math-decompose-unit-part (nth 2 utemp))
862 (setq ulist (cons (math-decompose-unit-part utemp) ulist)
876 (defun math-decompose-unit-part (unit)
877 (cons unit
879 unit nil))
882 ;; The variable math-fcu-u is local to math-find-compatible-unit,
884 ;; math-find-compatible-unit.
887 (defun math-find-compatible-unit (expr unit)
888 (let ((math-fcu-u (math-check-unit-name unit)))
890 (math-find-compatible-unit-rec expr 1))))
892 (defun math-find-compatible-unit-rec (expr pow)
894 (or (math-find-compatible-unit-rec (nth 1 expr) pow)
895 (math-find-compatible-unit-rec (nth 2 expr) pow)))
897 (or (math-find-compatible-unit-rec (nth 1 expr) pow)
898 (math-find-compatible-unit-rec (nth 2 expr) (- pow))))
901 (math-find-compatible-unit-rec (nth 1 expr) (* pow (nth 2 expr))))
903 (let ((u2 (math-check-unit-name expr)))
921 (math-find-compatible-unit expr math-cu-new-units)))
922 (math-cu-unit-list nil)
935 (when (setq math-cu-unit-list (math-decompose-units math-cu-new-units))
936 (setq math-cu-new-units (nth 2 (car math-cu-unit-list))))
943 math-cu-new-units math-cu-unit-list math-cu-pure))))))
949 math-cu-new-units math-cu-unit-list math-cu-pure)
960 (math-check-unit-name old)
963 (unew (math-check-unit-name new)))
965 (error "Not a valid temperature unit"))
1026 (unit (car unitp))
1029 (and (eq (car-safe unit) '*)
1030 (setq unitp (cdr unit)
1031 unit (car unitp)))
1032 (and (eq (car-safe unit) '^)
1033 (integerp (nth 2 unit))
1034 (setq pow (* pow (nth 2 unit))
1035 unitp (cdr unit)
1036 unit (car unitp)))
1037 (and (setq u (math-check-unit-name unit))
1043 (reverse math-unit-prefixes)
1044 math-unit-prefixes))
1047 (or (eq (car u) (nth 1 unit))
1051 (nth 1 unit)) 0)
1052 math-unit-prefixes))))))
1136 (let ((un (math-check-unit-name n))
1137 (ud (math-check-unit-name d)))
1206 (math-check-unit-name (nth 1 a))
1209 (let* ((u (math-check-unit-name a))
1303 (if (math-check-unit-name expr)
1314 (if (math-check-unit-name expr) expr 1)))
1372 (insert " (base unit)")))
1376 (setq uptr math-unit-prefixes)