summaryrefslogtreecommitdiff
path: root/lisp/calc
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/calc')
-rw-r--r--lisp/calc/calc-embed.el15
-rw-r--r--lisp/calc/calc-lang.el29
2 files changed, 30 insertions, 14 deletions
diff --git a/lisp/calc/calc-embed.el b/lisp/calc/calc-embed.el
index 4c6311c9a5b..e3b3b6b5b19 100644
--- a/lisp/calc/calc-embed.el
+++ b/lisp/calc/calc-embed.el
@@ -967,19 +967,24 @@ The command \\[yank] can retrieve it from there."
(calc-embedded-original-buffer t info)
(or (equal str (aref info 6))
(let ((delta (- (aref info 5) (aref info 3)))
+ (adjbot 0)
(buffer-read-only nil))
(goto-char (aref info 2))
(delete-region (point) (aref info 3))
(and (> (nth 1 entry) (1+ extra))
(aref info 7)
(progn
- (aset info 7 nil)
(delete-horizontal-space)
- (insert "\n\n")
- (delete-horizontal-space)
- (backward-char 1)))
+ (if (looking-at "\n")
+ ;; If there's a newline there, don't add one
+ (insert "\n")
+ (insert "\n\n")
+ (delete-horizontal-space)
+ (setq adjbot 1)
+; (setq delta (1+ delta))
+ (backward-char 1))))
(insert str)
- (set-marker (aref info 3) (point))
+ (set-marker (aref info 3) (+ (point) adjbot))
(set-marker (aref info 5) (+ (point) delta))
(aset info 6 str))))))
(if (eq (car-safe val) 'calcFunc-evalto)
diff --git a/lisp/calc/calc-lang.el b/lisp/calc/calc-lang.el
index d91d78fc461..63d24bb76d5 100644
--- a/lisp/calc/calc-lang.el
+++ b/lisp/calc/calc-lang.el
@@ -469,12 +469,12 @@
(put 'latex 'math-function-table
(append
(get 'tex 'math-function-table)
- '(( \\frac . (math-latex-parse-frac /))
- ( \\tfrac . (math-latex-parse-frac /))
- ( \\dfrac . (math-latex-parse-frac /))
- ( \\binom . (math-latex-parse-frac calcFunc-choose))
- ( \\tbinom . (math-latex-parse-frac calcFunc-choose))
- ( \\dbinom . (math-latex-parse-frac calcFunc-choose))
+ '(( \\frac . (math-latex-parse-frac))
+ ( \\tfrac . (math-latex-parse-frac))
+ ( \\dfrac . (math-latex-parse-frac))
+ ( \\binom . (math-latex-parse-two-args calcFunc-choose))
+ ( \\tbinom . (math-latex-parse-two-args calcFunc-choose))
+ ( \\dbinom . (math-latex-parse-two-args calcFunc-choose))
( \\phi . calcFunc-totient )
( \\mu . calcFunc-moebius ))))
@@ -487,12 +487,23 @@
(put 'latex 'math-complex-format 'i)
+
(defun math-latex-parse-frac (f val)
(let (numer denom)
- (setq args (math-read-expr-list))
+ (setq numer (car (math-read-expr-list)))
+ (math-read-token)
+ (setq denom (math-read-factor))
+ (if (and (Math-num-integerp numer)
+ (Math-num-integerp denom))
+ (list 'frac numer denom)
+ (list '/ numer denom))))
+
+(defun math-latex-parse-two-args (f val)
+ (let (first second)
+ (setq first (car (math-read-expr-list)))
(math-read-token)
- (setq margs (math-read-factor))
- (list (nth 2 f) (car args) margs)))
+ (setq second (math-read-factor))
+ (list (nth 2 f) first second)))
(defun math-latex-print-frac (a fn)
(list 'horiz (nth 1 fn) "{" (math-compose-expr (nth 1 a) -1)