comparison lisp/calc/calccomp.el @ 109033:d150a25a0eb9

Add some utf-8 coding cookies. * lisp/calc/calc-aent.el, lisp/calc/calc-ext.el, lisp/calc/calc-lang.el: * lisp/calc/calc-store.el, lisp/calc/calc-units.el, lisp/calc/calc.el: * lisp/calc/calccomp.el: Add explicit utf-8 coding cookies to files with utf-8 characters. Also delete trailing whitespace.
author Glenn Morris <rgm@gnu.org>
date Tue, 22 Jun 2010 00:41:10 -0700
parents c84578d13e42
children bc0b9af387a7
comparison
equal deleted inserted replaced
109032:d8720405694a 109033:d150a25a0eb9
1 ;;; calccomp.el --- composition functions for Calc 1 ;;; calccomp.el --- composition functions for Calc
2 2
3 ;; Copyright (C) 1990, 1991, 1992, 1993, 2001, 2002, 2003, 2004, 3 ;; Copyright (C) 1990, 1991, 1992, 1993, 2001, 2002, 2003, 2004, 2005,
4 ;; 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. 4 ;; 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
5 5
6 ;; Author: David Gillespie <daveg@synaptics.com> 6 ;; Author: David Gillespie <daveg@synaptics.com>
7 ;; Maintainer: Jay Belanger <jay.p.belanger@gmail.com> 7 ;; Maintainer: Jay Belanger <jay.p.belanger@gmail.com>
8 8
9 ;; This file is part of GNU Emacs. 9 ;; This file is part of GNU Emacs.
48 ;;; (subscr C1 C2) Composition C1 with subscript C2 48 ;;; (subscr C1 C2) Composition C1 with subscript C2
49 ;;; (rule X) Horizontal line of X, full width of enclosing comp 49 ;;; (rule X) Horizontal line of X, full width of enclosing comp
50 ;;; 50 ;;;
51 ;;; (tag X C) Composition C corresponds to sub-expression X 51 ;;; (tag X C) Composition C corresponds to sub-expression X
52 52
53 ;; math-comp-just and math-comp-comma-spc are local to 53 ;; math-comp-just and math-comp-comma-spc are local to
54 ;; math-compose-expr, but are used by math-compose-matrix, which is 54 ;; math-compose-expr, but are used by math-compose-matrix, which is
55 ;; called by math-compose-expr 55 ;; called by math-compose-expr
56 (defvar math-comp-just) 56 (defvar math-comp-just)
57 (defvar math-comp-comma-spc) 57 (defvar math-comp-comma-spc)
58 58
59 ;; math-comp-vector-prec is local to math-compose-expr, but is used by 59 ;; math-comp-vector-prec is local to math-compose-expr, but is used by
60 ;; math-compose-matrix and math-compose-rows, which are called by 60 ;; math-compose-matrix and math-compose-rows, which are called by
61 ;; math-compose-expr. 61 ;; math-compose-expr.
62 (defvar math-comp-vector-prec) 62 (defvar math-comp-vector-prec)
63 63
64 ;; math-comp-left-bracket, math-comp-right-bracket and math-comp-comma are 64 ;; math-comp-left-bracket, math-comp-right-bracket and math-comp-comma are
65 ;; local to math-compose-expr, but are used by math-compose-rows, which is 65 ;; local to math-compose-expr, but are used by math-compose-rows, which is
66 ;; called by math-compose-expr. 66 ;; called by math-compose-expr.
67 (defvar math-comp-left-bracket) 67 (defvar math-comp-left-bracket)
68 (defvar math-comp-right-bracket) 68 (defvar math-comp-right-bracket)
69 (defvar math-comp-comma) 69 (defvar math-comp-comma)
70 70
98 (let ((math-comp-selected nil)) 98 (let ((math-comp-selected nil))
99 (and math-comp-tagged (setq math-comp-tagged a)) 99 (and math-comp-tagged (setq math-comp-tagged a))
100 (list 'tag a (math-compose-expr a prec)))) 100 (list 'tag a (math-compose-expr a prec))))
101 ((and (not (consp a)) (not (integerp a))) 101 ((and (not (consp a)) (not (integerp a)))
102 (concat "'" (prin1-to-string a))) 102 (concat "'" (prin1-to-string a)))
103 ((setq spfn (assq (car-safe a) 103 ((setq spfn (assq (car-safe a)
104 (get calc-language 'math-special-function-table))) 104 (get calc-language 'math-special-function-table)))
105 (setq spfn (cdr spfn)) 105 (setq spfn (cdr spfn))
106 (if (consp spfn) 106 (if (consp spfn)
107 (funcall (car spfn) a spfn) 107 (funcall (car spfn) a spfn)
108 (funcall spfn a))) 108 (funcall spfn a)))
109 ((math-scalarp a) 109 ((math-scalarp a)
110 (if (or (eq (car-safe a) 'frac) 110 (if (or (eq (car-safe a) 'frac)
111 (and (nth 1 calc-frac-format) (Math-integerp a))) 111 (and (nth 1 calc-frac-format) (Math-integerp a)))
112 (if (and 112 (if (and
113 calc-language 113 calc-language
114 (not (memq calc-language 114 (not (memq calc-language
115 '(flat big unform)))) 115 '(flat big unform))))
116 (let ((aa (math-adjust-fraction a)) 116 (let ((aa (math-adjust-fraction a))
117 (calc-frac-format nil)) 117 (calc-frac-format nil))
118 (math-compose-expr (list '/ 118 (math-compose-expr (list '/
119 (if (memq calc-language 119 (if (memq calc-language
120 calc-lang-slash-idiv) 120 calc-lang-slash-idiv)
121 (math-float (nth 1 aa)) 121 (math-float (nth 1 aa))
122 (nth 1 aa)) 122 (nth 1 aa))
123 (nth 2 aa)) prec)) 123 (nth 2 aa)) prec))
124 (if (and (eq calc-language 'big) 124 (if (and (eq calc-language 'big)
279 (cons 'vleft (cons base 279 (cons 'vleft (cons base
280 (math-compose-rows 280 (math-compose-rows
281 (cdr a) 281 (cdr a)
282 (if full rows 3) t))))) 282 (if full rows 3) t)))))
283 (if (or calc-full-vectors (< (length a) 7)) 283 (if (or calc-full-vectors (< (length a) 7))
284 (if (and 284 (if (and
285 (setq spfn (get calc-language 'math-matrix-formatter)) 285 (setq spfn (get calc-language 'math-matrix-formatter))
286 (math-matrixp a)) 286 (math-matrixp a))
287 (funcall spfn a) 287 (funcall spfn a)
288 (list 'horiz 288 (list 'horiz
289 math-comp-left-bracket 289 math-comp-left-bracket
290 (math-compose-vector (cdr a) 290 (math-compose-vector (cdr a)
291 (concat math-comp-comma " ") 291 (concat math-comp-comma " ")
292 math-comp-vector-prec) 292 math-comp-vector-prec)
293 math-comp-right-bracket)) 293 math-comp-right-bracket))
294 (list 'horiz 294 (list 'horiz
295 math-comp-left-bracket 295 math-comp-left-bracket
296 (math-compose-vector (list (nth 1 a) (nth 2 a) (nth 3 a)) 296 (math-compose-vector (list (nth 1 a) (nth 2 a) (nth 3 a))
297 (concat math-comp-comma " ") 297 (concat math-comp-comma " ")
298 math-comp-vector-prec) 298 math-comp-vector-prec)
299 math-comp-comma 299 math-comp-comma
300 (if (setq spfn (get calc-language 'math-dots)) 300 (if (setq spfn (get calc-language 'math-dots))
301 (concat " " spfn) 301 (concat " " spfn)
302 " ...") 302 " ...")
303 math-comp-comma " " 303 math-comp-comma " "
304 (list 'break math-compose-level) 304 (list 'break math-compose-level)
867 (math-compose-expr 867 (math-compose-expr
868 (nth col r) 868 (nth col r)
869 math-comp-vector-prec) 869 math-comp-vector-prec)
870 (if (= col cols) 870 (if (= col cols)
871 "" 871 ""
872 (concat 872 (concat
873 math-comp-comma-spc " "))))) 873 math-comp-comma-spc " ")))))
874 a))) 874 a)))
875 res))) 875 res)))
876 (nreverse res))) 876 (nreverse res)))
877 877
878 (defun math-compose-rows (a count first) 878 (defun math-compose-rows (a count first)
879 (if (cdr a) 879 (if (cdr a)
880 (if (<= count 0) 880 (if (<= count 0)
881 (if (< count 0) 881 (if (< count 0)
882 (math-compose-rows (cdr a) -1 nil) 882 (math-compose-rows (cdr a) -1 nil)
883 (cons (concat 883 (cons (concat
884 (let ((mdots (get calc-language 'math-dots))) 884 (let ((mdots (get calc-language 'math-dots)))
885 (if mdots 885 (if mdots
886 (concat " " mdots) 886 (concat " " mdots)
887 " ...")) 887 " ..."))
888 math-comp-comma) 888 math-comp-comma)
1117 " " "") 1117 " " "")
1118 expr 1118 expr
1119 (if (memq prec '(196 201)) ")" ""))))) 1119 (if (memq prec '(196 201)) ")" "")))))
1120 1120
1121 ;; The variables math-svo-c, math-svo-wid and math-svo-off are local 1121 ;; The variables math-svo-c, math-svo-wid and math-svo-off are local
1122 ;; to math-stack-value-offset in calc.el, but are used by 1122 ;; to math-stack-value-offset in calc.el, but are used by
1123 ;; math-stack-value-offset-fancy, which is called by math-stack-value-offset.. 1123 ;; math-stack-value-offset-fancy, which is called by math-stack-value-offset..
1124 (defvar math-svo-c) 1124 (defvar math-svo-c)
1125 (defvar math-svo-wid) 1125 (defvar math-svo-wid)
1126 (defvar math-svo-off) 1126 (defvar math-svo-off)
1127 1127
1193 ;;; Convert a one-line composition to a string. Break into multiple 1193 ;;; Convert a one-line composition to a string. Break into multiple
1194 ;;; lines if necessary, choosing break points according to the structure 1194 ;;; lines if necessary, choosing break points according to the structure
1195 ;;; of the formula. 1195 ;;; of the formula.
1196 1196
1197 ;; The variables math-comp-full-width, math-comp-highlight, math-comp-word, 1197 ;; The variables math-comp-full-width, math-comp-highlight, math-comp-word,
1198 ;; math-comp-level, math-comp-margin and math-comp-buf are local to 1198 ;; math-comp-level, math-comp-margin and math-comp-buf are local to
1199 ;; math-comp-to-string-flat, but are used by math-comp-to-string-flat-term, 1199 ;; math-comp-to-string-flat, but are used by math-comp-to-string-flat-term,
1200 ;; which is called by math-comp-to-string-flat. 1200 ;; which is called by math-comp-to-string-flat.
1201 ;; math-comp-highlight and math-comp-buf are also local to 1201 ;; math-comp-highlight and math-comp-buf are also local to
1202 ;; math-comp-simplify-term and math-comp-simplify respectively, but are used 1202 ;; math-comp-simplify-term and math-comp-simplify respectively, but are used
1203 ;; by math-comp-add-string. 1203 ;; by math-comp-add-string.
1204 (defvar math-comp-full-width) 1204 (defvar math-comp-full-width)
1205 (defvar math-comp-highlight) 1205 (defvar math-comp-highlight)
1206 (defvar math-comp-word) 1206 (defvar math-comp-word)
1207 (defvar math-comp-level) 1207 (defvar math-comp-level)
1242 1242
1243 (defun math-comp-to-string-flat-term (c) 1243 (defun math-comp-to-string-flat-term (c)
1244 (cond ((not (consp c)) 1244 (cond ((not (consp c))
1245 (if math-comp-highlight 1245 (if math-comp-highlight
1246 (setq c (math-comp-highlight-string c))) 1246 (setq c (math-comp-highlight-string c)))
1247 (setq math-comp-word (if (= (length math-comp-word) 0) c 1247 (setq math-comp-word (if (= (length math-comp-word) 0) c
1248 (concat math-comp-word c)) 1248 (concat math-comp-word c))
1249 math-comp-pos (+ math-comp-pos (length c)))) 1249 math-comp-pos (+ math-comp-pos (length c))))
1250 1250
1251 ((eq (car c) 'horiz) 1251 ((eq (car c) 'horiz)
1252 (while (setq c (cdr c)) 1252 (while (setq c (cdr c))
1345 (aset s i (if calc-show-selections ?\. ?\#))))) 1345 (aset s i (if calc-show-selections ?\. ?\#)))))
1346 s) 1346 s)
1347 1347
1348 1348
1349 ;; The variable math-comp-sel-tag is local to calc-find-selected-part 1349 ;; The variable math-comp-sel-tag is local to calc-find-selected-part
1350 ;; in calc-sel.el, but is used by math-comp-sel-flat-term and 1350 ;; in calc-sel.el, but is used by math-comp-sel-flat-term and
1351 ;; math-comp-add-string-sel, which are called (indirectly) by 1351 ;; math-comp-add-string-sel, which are called (indirectly) by
1352 ;; calc-find-selected-part. 1352 ;; calc-find-selected-part.
1353 (defvar math-comp-sel-tag) 1353 (defvar math-comp-sel-tag)
1354 1354
1355 (defun math-comp-sel-flat-term (c) 1355 (defun math-comp-sel-flat-term (c)
1356 (cond ((not (consp c)) 1356 (cond ((not (consp c))
1666 (math-comp-to-string-raw-step (cdr cl) indent)) 1666 (math-comp-to-string-raw-step (cdr cl) indent))
1667 "")) 1667 ""))
1668 1668
1669 (provide 'calccomp) 1669 (provide 'calccomp)
1670 1670
1671 ;; Local variables:
1672 ;; coding: utf-8
1673 ;; End:
1674
1671 ;; arch-tag: 7c45d10a-a286-4dab-af49-7ae8989fbf78 1675 ;; arch-tag: 7c45d10a-a286-4dab-af49-7ae8989fbf78
1672 ;;; calccomp.el ends here 1676 ;;; calccomp.el ends here