Commit 0b504d64 authored by Jay Belanger's avatar Jay Belanger
Browse files

(calcAlg-edit, calcAlg-enter): Remove reference to calc-previous-alg-entry.

(calcAlg-previous): Use previous-history-element instead of
calc-previous-alg-entry.
(calc-do-alg-entry): Add history to reading from minibuffer.
Change keybinding for calcAlg-plus-minus, add keybindings for
previous-history-element and next-history-element.
(calc-alg-entry-history, calc-quick-calc-history): New variables.
(calc-do-quick-calc): Use calc-quick-calc-history.
Remove reference to calc-previous-alg-entry.
(calc-alg-entry): Use calc-alg-entry-history.
parent 8190210b
......@@ -32,7 +32,11 @@
(require 'calc)
(require 'calc-macs)
(defvar calc-quick-calc-history nil
"The history list for quick-calc.")
(defun calc-do-quick-calc ()
(require 'calc-ext)
(calc-check-defines)
(if (eq major-mode 'calc-mode)
(calc-algebraic-entry t)
......@@ -45,23 +49,12 @@
(enable-recursive-minibuffers t)
(calc-language (if (memq calc-language '(nil big))
'flat calc-language))
(entry (calc-do-alg-entry "" "Quick calc: " t))
(alg-exp (mapcar (function
(lambda (x)
(if (and (not (featurep 'calc-ext))
calc-previous-alg-entry
(string-match
"\\`[-0-9._+*/^() ]+\\'"
calc-previous-alg-entry))
(calc-normalize x)
(require 'calc-ext)
(math-evaluate-expr x))))
entry)))
(entry (calc-do-alg-entry "" "Quick calc: " t 'calc-quick-calc-history))
(alg-exp (mapcar 'math-evaluate-expr entry)))
(when (and (= (length alg-exp) 1)
(eq (car-safe (car alg-exp)) 'calcFunc-assign)
(= (length (car alg-exp)) 3)
(eq (car-safe (nth 1 (car alg-exp))) 'var))
(require 'calc-ext)
(set (nth 2 (nth 1 (car alg-exp))) (nth 2 (car alg-exp)))
(calc-refresh-evaltos (nth 2 (nth 1 (car alg-exp))))
(setq alg-exp (list (nth 2 (car alg-exp)))))
......@@ -264,13 +257,16 @@ T means abort and give an error message.")
(math-expr-opers (if prefix math-standard-opers math-expr-opers)))
(calc-alg-entry (and auto (char-to-string last-command-char))))))
(defvar calc-alg-entry-history nil
"History for algebraic entry.")
(defun calc-alg-entry (&optional initial prompt)
(let* ((sel-mode nil)
(calc-dollar-values (mapcar 'calc-get-stack-element
(nthcdr calc-stack-top calc-stack)))
(calc-dollar-used 0)
(calc-plain-entry t)
(alg-exp (calc-do-alg-entry initial prompt t)))
(alg-exp (calc-do-alg-entry initial prompt t 'calc-alg-entry-history)))
(if (stringp alg-exp)
(progn
(require 'calc-ext)
......@@ -301,7 +297,7 @@ T means abort and give an error message.")
(defvar calc-alg-exp)
(defun calc-do-alg-entry (&optional initial prompt no-normalize)
(defun calc-do-alg-entry (&optional initial prompt no-normalize history)
(let* ((calc-buffer (current-buffer))
(blink-paren-function 'calcAlg-blink-matching-open)
(calc-alg-exp 'error))
......@@ -319,15 +315,17 @@ T means abort and give an error message.")
(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)
(define-key calc-alg-ent-map "\ep" 'calcAlg-plus-minus)
(define-key calc-alg-ent-map "\e+" 'calcAlg-plus-minus)
(define-key calc-alg-ent-map "\em" 'calcAlg-mod)
(define-key calc-alg-ent-map "\e=" 'calcAlg-equals)
(define-key calc-alg-ent-map "\e\r" 'calcAlg-equals)
(define-key calc-alg-ent-map "\ep" 'previous-history-element)
(define-key calc-alg-ent-map "\en" 'next-history-element)
(define-key calc-alg-ent-map "\e%" 'self-insert-command))
(setq calc-aborted-prefix nil)
(let ((buf (read-from-minibuffer (or prompt "Algebraic: ")
(or initial "")
calc-alg-ent-map nil)))
calc-alg-ent-map nil history)))
(when (eq calc-alg-exp 'error)
(when (eq (car-safe (setq calc-alg-exp (math-read-exprs buf))) 'error)
(setq calc-alg-exp nil)))
......@@ -355,9 +353,7 @@ T means abort and give an error message.")
(defun calcAlg-previous ()
(interactive)
(if (calc-minibuffer-contains "\\'")
(if calc-previous-alg-entry
(insert calc-previous-alg-entry)
(beep))
(previous-history-element 1)
(insert "'")))
(defun calcAlg-equals ()
......@@ -384,7 +380,6 @@ T means abort and give an error message.")
"\\`\\([^\"]*\"[^\"]*\"\\)*[^\"]*\"[^\"]*\\'"))
(insert "`")
(setq calc-alg-exp (minibuffer-contents))
(and (> (length calc-alg-exp) 0) (setq calc-previous-alg-entry calc-alg-exp))
(exit-minibuffer)))
(defvar calc-buffer)
......@@ -407,7 +402,6 @@ T means abort and give an error message.")
(setq calc-alg-exp (if (calc-minibuffer-contains "\\` *\\[ *\\'")
'((incomplete vec))
exp))
(and (> (length str) 0) (setq calc-previous-alg-entry str))
(exit-minibuffer))))
(defun calcAlg-blink-matching-open ()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment