;;; calc-aent.el --- algebraic entry functions for Calc
-;; Copyright (C) 1990, 1991, 1992, 1993, 2001, 2002, 2003, 2004,
-;; 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+;; Copyright (C) 1990, 1991, 1992, 1993, 2001, 2002, 2003, 2004, 2005,
+;; 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
;; Author: Dave Gillespie <daveg@synaptics.com>
;; Maintainer: Jay Belanger <jay.p.belanger@gmail.com>
(setq buf long))))
(calc-handle-whys)
(message "Result: %s" buf)))
- (if (eq last-command-char 10)
+ (if (eq last-command-event 10)
(insert shortbuf)
(kill-new shortbuf)))))
(calc-matrix-mode nil)
(calc-angle-mode 'deg)
(calc-number-radix 10)
+ (calc-twos-complement-mode nil)
(calc-leading-zeros nil)
(calc-group-digits nil)
(calc-point-char ".")
(calc-wrapper
(let ((calc-language (if prefix nil calc-language))
(math-expr-opers (if prefix (math-standard-ops) (math-expr-ops))))
- (calc-alg-entry (and auto (char-to-string last-command-char))))))
+ (calc-alg-entry (and auto (char-to-string last-command-event))))))
(defvar calc-alg-entry-history nil
"History for algebraic entry.")
(progn
(require 'calc-ext)
(calc-alg-edit alg-exp))
- (let* ((calc-simplify-mode (if (eq last-command-char ?\C-j)
+ (let* ((calc-simplify-mode (if (eq last-command-event ?\C-j)
'none
calc-simplify-mode))
(nvals (mapcar 'calc-normalize alg-exp)))
calc-dollar-used 0)))
(calc-handle-whys))))
-(defvar calc-alg-ent-map nil
+(defvar calc-alg-ent-map
+ (let ((map (make-sparse-keymap)))
+ (set-keymap-parent map minibuffer-local-map)
+ (define-key map "'" 'calcAlg-previous)
+ (define-key map "`" 'calcAlg-edit)
+ (define-key map "\C-m" 'calcAlg-enter)
+ (define-key map "\C-j" 'calcAlg-enter)
+ map)
"The keymap used for algebraic entry.")
-(defvar calc-alg-ent-esc-map nil
+(defvar calc-alg-ent-esc-map
+ (let ((map (make-keymap))
+ (i 33))
+ (set-keymap-parent map esc-map)
+ (while (< i 127)
+ (define-key map (vector i) 'calcAlg-escape)
+ (setq i (1+ i)))
+ map)
"The keymap used for escapes in algebraic entry.")
(defvar calc-alg-exp)
;;;###autoload
(defun calc-do-alg-entry (&optional initial prompt no-normalize history)
(let* ((calc-buffer (current-buffer))
- (blink-paren-function 'calcAlg-blink-matching-open)
+ (blink-matching-check-function 'calcAlg-blink-matching-check)
(calc-alg-exp 'error))
- (unless calc-alg-ent-map
- (setq calc-alg-ent-map (copy-keymap minibuffer-local-map))
- (define-key calc-alg-ent-map "'" 'calcAlg-previous)
- (define-key calc-alg-ent-map "`" 'calcAlg-edit)
- (define-key calc-alg-ent-map "\C-m" 'calcAlg-enter)
- (define-key calc-alg-ent-map "\C-j" 'calcAlg-enter)
- (let ((i 33))
- (setq calc-alg-ent-esc-map (copy-keymap esc-map))
- (while (< i 127)
- (aset (nth 1 calc-alg-ent-esc-map) i 'calcAlg-escape)
- (setq i (1+ i)))))
(define-key calc-alg-ent-map "\e" nil)
(if (eq calc-algebraic-mode 'total)
(define-key calc-alg-ent-map "\e" calc-alg-ent-esc-map)
(interactive)
(let* ((str (minibuffer-contents))
(exp (and (> (length str) 0)
- (save-excursion
- (set-buffer calc-buffer)
+ (with-current-buffer calc-buffer
(math-read-exprs str)))))
(if (eq (car-safe exp) 'error)
(progn
exp))
(exit-minibuffer))))
-(defun calcAlg-blink-matching-open ()
- (let ((rightpt (point))
- (leftpt nil)
- (rightchar (preceding-char))
- leftchar
- rightsyntax
- leftsyntax)
- (save-excursion
- (condition-case ()
- (setq leftpt (scan-sexps rightpt -1)
- leftchar (char-after leftpt))
- (error nil)))
+(defun calcAlg-blink-matching-check (leftpt rightpt)
+ (let ((rightchar (char-before rightpt))
+ (leftchar (if leftpt (char-after leftpt))))
(if (and leftpt
(or (and (= rightchar ?\))
(= leftchar ?\[))
(save-excursion
(goto-char leftpt)
(looking-at ".+\\(\\.\\.\\|\\\\dots\\|\\\\ldots\\)")))
- (let ((leftsaved (aref (syntax-table) leftchar))
- (rightsaved (aref (syntax-table) rightchar)))
- (unwind-protect
- (progn
- (cond ((= leftchar ?\[)
- (aset (syntax-table) leftchar (cons 4 ?\)))
- (aset (syntax-table) rightchar (cons 5 ?\[)))
- (t
- (aset (syntax-table) leftchar (cons 4 ?\]))
- (aset (syntax-table) rightchar (cons 5 ?\())))
- (blink-matching-open))
- (aset (syntax-table) leftchar leftsaved)
- (aset (syntax-table) rightchar rightsaved)))
- (blink-matching-open))))
+ ;; [2..5) perfectly valid!
+ nil
+ (blink-matching-check-mismatch leftpt rightpt))))
;;;###autoload
(defun calc-alg-digit-entry ()
(calc-alg-entry
- (cond ((eq last-command-char ?e)
+ (cond ((eq last-command-event ?e)
(if (> calc-number-radix 14) (format "%d.^" calc-number-radix) "1e"))
- ((eq last-command-char ?#) (format "%d#" calc-number-radix))
- ((eq last-command-char ?_) "-")
- ((eq last-command-char ?@) "0@ ")
- (t (char-to-string last-command-char)))))
+ ((eq last-command-event ?#) (format "%d#" calc-number-radix))
+ ((eq last-command-event ?_) "-")
+ ((eq last-command-event ?@) "0@ ")
+ (t (char-to-string last-command-event)))))
;; The variable calc-digit-value is initially declared in calc.el,
;; but can be set by calcDigit-algebraic and calcDigit-edit.
("≥" ">=")
("≦" "<=")
("≧" ">=")
+ ("µ" "μ")
;; fractions
("¼" "(1:4)") ; 1/4
("½" "(1:2)") ; 1/2
(setq math-exp-str (math-remove-percentsigns math-exp-str)))
(if calc-language-input-filter
(setq math-exp-str (funcall calc-language-input-filter math-exp-str)))
- (while (setq math-exp-token
+ (while (setq math-exp-token
(string-match "\\.\\.\\([^.]\\|.[^.]\\)" math-exp-str))
- (setq math-exp-str
+ (setq math-exp-str
(concat (substring math-exp-str 0 math-exp-token) "\\dots"
(substring math-exp-str (+ math-exp-token 2)))))
(math-build-parse-table)
(cond ((and (stringp (car p))
(or (> (length (car p)) 1) (equal (car p) "$")
(equal (car p) "\""))
- (string-match "[^a-zA-Z0-9]" (car p)))
+ (string-match "[^a-zA-Zα-ωΑ-Ω0-9]" (car p)))
(let ((s (regexp-quote (car p))))
- (if (string-match "\\`[a-zA-Z0-9]" s)
+ (if (string-match "\\`[a-zA-Zα-ωΑ-Ω0-9]" s)
(setq s (concat "\\<" s)))
- (if (string-match "[a-zA-Z0-9]\\'" s)
+ (if (string-match "[a-zA-Zα-ωΑ-Ω0-9]\\'" s)
(setq s (concat s "\\>")))
(or (assoc s math-toks)
(progn
(math-read-token)))
((and (memq ch calc-user-token-chars)
(let ((case-fold-search nil))
- (eq (string-match
+ (eq (string-match
calc-user-tokens math-exp-str math-exp-pos)
math-exp-pos)))
(setq math-exp-token 'punc
math-expr-data (math-match-substring math-exp-str 0)
math-exp-pos (match-end 0)))
((or (and (>= ch ?a) (<= ch ?z))
- (and (>= ch ?A) (<= ch ?Z)))
- (string-match
+ (and (>= ch ?A) (<= ch ?Z))
+ (and (>= ch ?α) (<= ch ?ω))
+ (and (>= ch ?Α) (<= ch ?Ω)))
+ (string-match
(cond
((and (memq calc-language calc-lang-allow-underscores)
(memq calc-language calc-lang-allow-percentsigns))
- "[a-zA-Z0-9_'#]*")
+ "[a-zA-Zα-ωΑ-Ω0-9_'#]*")
((memq calc-language calc-lang-allow-underscores)
- "[a-zA-Z0-9_#]*")
- (t "[a-zA-Z0-9'#]*"))
+ "[a-zA-Zα-ωΑ-Ω0-9_#]*")
+ (t "[a-zA-Zα-ωΑ-Ω0-9'#]*"))
math-exp-str math-exp-pos)
(setq math-exp-token 'symbol
math-exp-pos (match-end 0)
(eq (string-match "_\\.?[0-9]" math-exp-str math-exp-pos)
math-exp-pos)
(or (eq math-exp-pos 0)
- (and (not (memq calc-language
+ (and (not (memq calc-language
calc-lang-allow-underscores))
- (eq (string-match "[^])}\"a-zA-Z0-9'$]_"
+ (eq (string-match "[^])}\"a-zA-Zα-ωΑ-Ω0-9'$]_"
math-exp-str (1- math-exp-pos))
(1- math-exp-pos))))))
(or (and (memq calc-language calc-lang-c-type-hex)
(string-match "0[xX][0-9a-fA-F]+" math-exp-str math-exp-pos))
- (string-match "_?\\([0-9]+.?0*@ *\\)?\\([0-9]+.?0*' *\\)?\\(0*\\([2-9]\\|1[0-4]\\)\\(#\\|\\^\\^\\)[0-9a-dA-D.]+[eE][-+_]?[0-9]+\\|0*\\([2-9]\\|[0-2][0-9]\\|3[0-6]\\)\\(#\\|\\^\\^\\)[0-9a-zA-Z:.]+\\|[0-9]+:[0-9:]+\\|[0-9.]+\\([eE][-+_]?[0-9]+\\)?\"?\\)?"
+ (string-match "_?\\([0-9]+.?0*@ *\\)?\\([0-9]+.?0*' *\\)?\\(0*\\([2-9]\\|1[0-4]\\)\\(#[#]?\\|\\^\\^\\)[0-9a-dA-D.]+[eE][-+_]?[0-9]+\\|0*\\([2-9]\\|[0-2][0-9]\\|3[0-6]\\)\\(#[#]?\\|\\^\\^\\)[0-9a-zA-Zα-ωΑ-Ω:.]+\\|[0-9]+:[0-9:]+\\|[0-9.]+\\([eE][-+_]?[0-9]+\\)?\"?\\)?"
math-exp-str math-exp-pos))
(setq math-exp-token 'number
math-expr-data (math-match-substring math-exp-str 0)
math-exp-pos (match-end 0)))
- ((and (setq adfn
+ ((and (setq adfn
(assq ch (get calc-language 'math-lang-read-symbol)))
(eval (nth 1 adfn)))
(eval (nth 2 adfn)))
(defun math-read-expr-level (exp-prec &optional exp-term)
(let* ((math-expr-opers (math-expr-ops))
- (x (math-read-factor))
- (first t)
+ (x (math-read-factor))
+ (first t)
op op2)
(while (and (or (and calc-user-parse-table
(setq op (calc-check-user-syntax x exp-prec))
(memq math-exp-token '(symbol number dollar hash))
(equal math-expr-data "(")
(and (equal math-expr-data "[")
- (not (equal
- (get calc-language
+ (not (equal
+ (get calc-language
'math-function-open) "["))
(not (and math-exp-keep-spaces
(eq (car-safe x) 'vec)))))
(eq math-exp-token 'end)))
(throw 'syntax "Expected `)'"))
(math-read-token)
- (if (and (memq calc-language
- calc-lang-parens-are-subscripts)
+ (if (and (memq calc-language
+ calc-lang-parens-are-subscripts)
args
(require 'calc-ext)
(let ((calc-matrix-mode 'scalar))
(substring (symbol-name (cdr v))
4))
(cdr v))))))
- (while (and (memq calc-language
+ (while (and (memq calc-language
calc-lang-brackets-are-subscripts)
(equal math-expr-data "["))
(math-read-token)
(provide 'calc-aent)
;; Local variables:
+;; coding: utf-8
;; generated-autoload-file: "calc-loaddefs.el"
;; End:
-;; arch-tag: 5599e45d-e51e-44bb-9a20-9f4ed8c96c32
;;; calc-aent.el ends here