]> code.delx.au - gnu-emacs/blobdiff - lisp/calc/calc-sel.el
* view.el (view-recenter): Allow recenter to compute window height
[gnu-emacs] / lisp / calc / calc-sel.el
index bb69db6f3ed9193d95a6cba17765baf37755b1ac..42d64475447e53145213ea7c61e97c6ba5bf466f 100644 (file)
@@ -1,7 +1,7 @@
 ;;; calc-sel.el --- data selection functions for Calc
 
 ;; Copyright (C) 1990, 1991, 1992, 1993, 2001, 2002, 2003, 2004,
-;;   2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+;;   2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
 
 ;; Author: David Gillespie <daveg@synaptics.com>
 ;; Maintainer: Jay Belanger <jay.p.belanger@gmail.com>
 
 (defun calc-select-part (num)
   (interactive "P")
-  (or num (setq num (- last-command-char ?0)))
+  (or num (setq num (- last-command-event ?0)))
   (calc-wrapper
    (calc-prepare-selection)
    (let ((sel (calc-find-nth-part (or (nth 2 calc-selection-cache-entry)
                                     (list (and calc-sel-reselect val))))))
      (calc-handle-whys))))
 
-(defun calc-sel-mult-both-sides (no-simp &optional divide)
+(defun calc-sel-mult-both-sides (arg &optional divide)
   (interactive "P")
   (calc-wrapper
    (calc-preserve-point)
-   (let* ((num (max 1 (calc-locate-cursor-element (point))))
+   (let* ((no-simp (consp arg))
+          (num (max 1 (calc-locate-cursor-element (point))))
          (calc-sel-reselect calc-keep-selection)
          (entry (calc-top num 'entry))
          (expr (car entry))
                              rhs (math-simplify rhs))
                        (and (eq func '/)
                             (or (Math-equal (nth 1 sel) 1)
-                                (Math-equal (nth 1 sel) -1)
-                                (and (memq (car-safe (nth 2 sel)) '(+ -))
-                                     (memq (car-safe alg) '(+ -))))
-                            (setq rhs (math-expand-term rhs)))))
+                                (Math-equal (nth 1 sel) -1))
+;                               (and (memq (car-safe (nth 2 sel)) '(+ -))
+;                                    (memq (car-safe alg) '(+ -))))
+                             (unless arg
+                               (setq rhs (math-expand-term rhs))))))
+                  (if (and arg (not no-simp))
+                      (setq rhs (math-simplify
+                                 (calcFunc-expand rhs (unless (= arg 0) arg)))))
                  (setq alg (calc-encase-atoms
                             (calc-normalize (list func lhs rhs)))))
              (setq rhs (list (if divide '* '/) sel alg))