]> code.delx.au - gnu-emacs/blobdiff - lisp/calc/calccomp.el
Merge from emacs-23
[gnu-emacs] / lisp / calc / calccomp.el
index 5a7d5d7590706d5bd52982737426f1fe2f63e307..c083b6605f071c3237bcd85dabdd7fb6a9f496a6 100644 (file)
 ;;;
 ;;;    (tag X C)             Composition C corresponds to sub-expression X
 
-;; math-comp-just and math-comp-comma-spc are local to 
-;; math-compose-expr, but are used by math-compose-matrix, which is 
+;; math-comp-just and math-comp-comma-spc are local to
+;; math-compose-expr, but are used by math-compose-matrix, which is
 ;; called by math-compose-expr
 (defvar math-comp-just)
 (defvar math-comp-comma-spc)
 
-;; math-comp-vector-prec is local to math-compose-expr, but is used by 
-;; math-compose-matrix and math-compose-rows, which are called by 
+;; math-comp-vector-prec is local to math-compose-expr, but is used by
+;; math-compose-matrix and math-compose-rows, which are called by
 ;; math-compose-expr.
 (defvar math-comp-vector-prec)
 
-;; math-comp-left-bracket, math-comp-right-bracket and math-comp-comma are 
-;; local to math-compose-expr, but are used by math-compose-rows, which is 
+;; math-comp-left-bracket, math-comp-right-bracket and math-comp-comma are
+;; local to math-compose-expr, but are used by math-compose-rows, which is
 ;; called by math-compose-expr.
 (defvar math-comp-left-bracket)
 (defvar math-comp-right-bracket)
        (list 'tag a (math-compose-expr a prec))))
      ((and (not (consp a)) (not (integerp a)))
       (concat "'" (prin1-to-string a)))
-     ((setq spfn (assq (car-safe a) 
+     ((setq spfn (assq (car-safe a)
                        (get calc-language 'math-special-function-table)))
       (setq spfn (cdr spfn))
       (if (consp spfn)
              (and (nth 1 calc-frac-format) (Math-integerp a)))
          (if (and
                calc-language
-               (not (memq calc-language 
+               (not (memq calc-language
                           '(flat big unform))))
              (let ((aa (math-adjust-fraction a))
                    (calc-frac-format nil))
                (math-compose-expr (list '/
-                                        (if (memq calc-language 
+                                        (if (memq calc-language
                                                    calc-lang-slash-idiv)
                                             (math-float (nth 1 aa))
                                           (nth 1 aa))
                                            (cdr a)
                                            (if full rows 3) t)))))
              (if (or calc-full-vectors (< (length a) 7))
-                  (if (and 
+                  (if (and
                        (setq spfn (get calc-language 'math-matrix-formatter))
                        (math-matrixp a))
                       (funcall spfn a)
                     (list 'horiz
                           math-comp-left-bracket
-                          (math-compose-vector (cdr a) 
+                          (math-compose-vector (cdr a)
                                                (concat math-comp-comma " ")
                                                math-comp-vector-prec)
                           math-comp-right-bracket))
                (list 'horiz
                      math-comp-left-bracket
                      (math-compose-vector (list (nth 1 a) (nth 2 a) (nth 3 a))
-                                          (concat math-comp-comma " ") 
+                                          (concat math-comp-comma " ")
                                            math-comp-vector-prec)
-                     math-comp-comma 
+                     math-comp-comma
                       (if (setq spfn (get calc-language 'math-dots))
                           (concat " " spfn)
                         " ...")
                              (and prevc nextc
                                   (or (and (>= nextc ?a) (<= nextc ?z))
                                       (and (>= nextc ?A) (<= nextc ?Z))
+                                      (and (>= nextc ?α) (<= nextc ?ω))
+                                      (and (>= nextc ?Α) (<= nextc ?Ω))
                                       (and (>= nextc ?0) (<= nextc ?9))
                                       (memq nextc '(?. ?_ ?#
                                                        ?\( ?\[ ?\{))
                                (not (math-tex-expr-is-flat (nth 1 a))))))
                   (list 'horiz
                         (if lr "\\left" "")
-                        (if (string-match "\\`u\\([^a-zA-Z]\\)\\'" (car op))
+                        (if (string-match "\\`u\\([^a-zA-Zα-ωΑ-Ω]\\)\\'" (car op))
                             (substring (car op) 1)
                           (car op))
                         (if (or lr (> (length (car op)) 2)) " " "")
                (t
                 (let ((rhs (math-compose-expr (nth 1 a) (nth 3 op))))
                   (list 'horiz
-                        (let ((ops (if (string-match "\\`u\\([^a-zA-Z]\\)\\'"
+                        (let ((ops (if (string-match "\\`u\\([^a-zA-Zα-ωΑ-Ω]\\)\\'"
                                                      (car op))
                                        (substring (car op) 1)
                                      (car op))))
                     (setq func (car func2)))
                 (setq func (math-remove-dashes
                             (if (string-match
-                                 "\\`calcFunc-\\([a-zA-Z0-9']+\\)\\'"
+                                 "\\`calcFunc-\\([a-zA-Zα-ωΑ-Ω0-9']+\\)\\'"
                                  (symbol-name func))
                                 (math-match-substring (symbol-name func) 1)
                               (symbol-name func))))
                                                    math-comp-vector-prec)
                                                   (if (= col cols)
                                                       ""
-                                                    (concat 
+                                                    (concat
                                                       math-comp-comma-spc " ")))))
                                          a)))
                      res)))
       (if (<= count 0)
          (if (< count 0)
              (math-compose-rows (cdr a) -1 nil)
-           (cons (concat 
+           (cons (concat
                    (let ((mdots (get calc-language 'math-dots)))
                      (if mdots
                          (concat " " mdots)
               (if (memq prec '(196 201)) ")" "")))))
 
 ;; The variables math-svo-c, math-svo-wid and math-svo-off are local
-;; to math-stack-value-offset in calc.el, but are used by 
+;; to math-stack-value-offset in calc.el, but are used by
 ;; math-stack-value-offset-fancy, which is called by math-stack-value-offset..
 (defvar math-svo-c)
 (defvar math-svo-wid)
 ;;; of the formula.
 
 ;; The variables math-comp-full-width, math-comp-highlight, math-comp-word,
-;; math-comp-level, math-comp-margin and math-comp-buf are local to 
-;; math-comp-to-string-flat, but are used by math-comp-to-string-flat-term, 
+;; math-comp-level, math-comp-margin and math-comp-buf are local to
+;; math-comp-to-string-flat, but are used by math-comp-to-string-flat-term,
 ;; which is called by math-comp-to-string-flat.
-;; math-comp-highlight and math-comp-buf are also local to 
-;; math-comp-simplify-term and math-comp-simplify respectively, but are used 
+;; math-comp-highlight and math-comp-buf are also local to
+;; math-comp-simplify-term and math-comp-simplify respectively, but are used
 ;; by math-comp-add-string.
 (defvar math-comp-full-width)
 (defvar math-comp-highlight)
   (cond ((not (consp c))
         (if math-comp-highlight
             (setq c (math-comp-highlight-string c)))
-        (setq math-comp-word (if (= (length math-comp-word) 0) c 
+        (setq math-comp-word (if (= (length math-comp-word) 0) c
                                 (concat math-comp-word c))
               math-comp-pos (+ math-comp-pos (length c))))
 
 
 (defun math-comp-highlight-string (s)
   (setq s (copy-sequence s))
-  (let ((i (length s)))
-    (while (>= (setq i (1- i)) 0)
-      (or (memq (aref s i) '(32 ?\n))
-         (aset s i (if calc-show-selections ?\. ?\#)))))
-  s)
-
+  (if calc-highlight-selections-with-faces
+      (if (not calc-show-selections)
+          (propertize s 'face 'calc-selected-face)
+        (propertize s 'face 'calc-nonselected-face))
+    (let ((i (length s)))
+      (while (>= (setq i (1- i)) 0)
+        (or (memq (aref s i) '(32 ?\n))
+            (aset s i (if calc-show-selections ?\. ?\#)))))
+    s))
 
 ;; The variable math-comp-sel-tag is local to calc-find-selected-part
-;; in calc-sel.el, but is used by math-comp-sel-flat-term and 
-;; math-comp-add-string-sel, which are called (indirectly) by 
+;; in calc-sel.el, but is used by math-comp-sel-flat-term and
+;; math-comp-add-string-sel, which are called (indirectly) by
 ;; calc-find-selected-part.
 (defvar math-comp-sel-tag)
 
 
 (provide 'calccomp)
 
+;; Local variables:
+;; coding: utf-8
+;; End:
+
 ;; arch-tag: 7c45d10a-a286-4dab-af49-7ae8989fbf78
 ;;; calccomp.el ends here