34 |
;; The variable calc-keep-selection is declared and set in calc-sel.el. |
;; The variable calc-keep-selection is declared and set in calc-sel.el. |
35 |
(defvar calc-keep-selection) |
(defvar calc-keep-selection) |
36 |
|
|
37 |
|
;; The variable calc-sel-reselect is local to the methods below, |
38 |
|
;; but is used by some functions in calc-sel.el which are called |
39 |
|
;; by the functions below. |
40 |
|
|
41 |
(defun calc-commute-left (arg) |
(defun calc-commute-left (arg) |
42 |
(interactive "p") |
(interactive "p") |
43 |
(if (< arg 0) |
(if (< arg 0) |
45 |
(calc-wrapper |
(calc-wrapper |
46 |
(calc-preserve-point) |
(calc-preserve-point) |
47 |
(let ((num (max 1 (calc-locate-cursor-element (point)))) |
(let ((num (max 1 (calc-locate-cursor-element (point)))) |
48 |
(reselect calc-keep-selection)) |
(calc-sel-reselect calc-keep-selection)) |
49 |
(if (= arg 0) (setq arg nil)) |
(if (= arg 0) (setq arg nil)) |
50 |
(while (or (null arg) (>= (setq arg (1- arg)) 0)) |
(while (or (null arg) (>= (setq arg (1- arg)) 0)) |
51 |
(let* ((entry (calc-top num 'entry)) |
(let* ((entry (calc-top num 'entry)) |
110 |
(if (null new) |
(if (null new) |
111 |
(if arg |
(if arg |
112 |
(error "Term is already leftmost") |
(error "Term is already leftmost") |
113 |
(or reselect |
(or calc-sel-reselect |
114 |
(calc-pop-push-list 1 (list expr) num '(nil))) |
(calc-pop-push-list 1 (list expr) num '(nil))) |
115 |
(setq arg 0)) |
(setq arg 0)) |
116 |
(calc-pop-push-record-list |
(calc-pop-push-record-list |
117 |
1 "left" |
1 "left" |
118 |
(list (calc-replace-sub-formula expr parent new)) |
(list (calc-replace-sub-formula expr parent new)) |
119 |
num |
num |
120 |
(list (and (or (not (eq arg 0)) reselect) |
(list (and (or (not (eq arg 0)) calc-sel-reselect) |
121 |
sel)))))))))) |
sel)))))))))) |
122 |
|
|
123 |
(defun calc-commute-right (arg) |
(defun calc-commute-right (arg) |
127 |
(calc-wrapper |
(calc-wrapper |
128 |
(calc-preserve-point) |
(calc-preserve-point) |
129 |
(let ((num (max 1 (calc-locate-cursor-element (point)))) |
(let ((num (max 1 (calc-locate-cursor-element (point)))) |
130 |
(reselect calc-keep-selection)) |
(calc-sel-reselect calc-keep-selection)) |
131 |
(if (= arg 0) (setq arg nil)) |
(if (= arg 0) (setq arg nil)) |
132 |
(while (or (null arg) (>= (setq arg (1- arg)) 0)) |
(while (or (null arg) (>= (setq arg (1- arg)) 0)) |
133 |
(let* ((entry (calc-top num 'entry)) |
(let* ((entry (calc-top num 'entry)) |
193 |
(if (null new) |
(if (null new) |
194 |
(if arg |
(if arg |
195 |
(error "Term is already rightmost") |
(error "Term is already rightmost") |
196 |
(or reselect |
(or calc-sel-reselect |
197 |
(calc-pop-push-list 1 (list expr) num '(nil))) |
(calc-pop-push-list 1 (list expr) num '(nil))) |
198 |
(setq arg 0)) |
(setq arg 0)) |
199 |
(calc-pop-push-record-list |
(calc-pop-push-record-list |
200 |
1 "rght" |
1 "rght" |
201 |
(list (calc-replace-sub-formula expr parent new)) |
(list (calc-replace-sub-formula expr parent new)) |
202 |
num |
num |
203 |
(list (and (or (not (eq arg 0)) reselect) |
(list (and (or (not (eq arg 0)) calc-sel-reselect) |
204 |
sel)))))))))) |
sel)))))))))) |
205 |
|
|
206 |
(defun calc-build-assoc-term (op lhs rhs) |
(defun calc-build-assoc-term (op lhs rhs) |
229 |
(calc-wrapper |
(calc-wrapper |
230 |
(calc-preserve-point) |
(calc-preserve-point) |
231 |
(let* ((num (max 1 (calc-locate-cursor-element (point)))) |
(let* ((num (max 1 (calc-locate-cursor-element (point)))) |
232 |
(reselect calc-keep-selection) |
(calc-sel-reselect calc-keep-selection) |
233 |
(entry (calc-top num 'entry)) |
(entry (calc-top num 'entry)) |
234 |
(expr (car entry)) |
(expr (car entry)) |
235 |
(sel (or (calc-auto-selection entry) expr))) |
(sel (or (calc-auto-selection entry) expr))) |
240 |
(list (calc-replace-sub-formula |
(list (calc-replace-sub-formula |
241 |
expr sel (nth 1 sel))) |
expr sel (nth 1 sel))) |
242 |
num |
num |
243 |
(list (and reselect (nth 1 sel))))))) |
(list (and calc-sel-reselect (nth 1 sel))))))) |
244 |
|
|
245 |
(defun calc-sel-isolate () |
(defun calc-sel-isolate () |
246 |
(interactive) |
(interactive) |
247 |
(calc-slow-wrapper |
(calc-slow-wrapper |
248 |
(calc-preserve-point) |
(calc-preserve-point) |
249 |
(let* ((num (max 1 (calc-locate-cursor-element (point)))) |
(let* ((num (max 1 (calc-locate-cursor-element (point)))) |
250 |
(reselect calc-keep-selection) |
(calc-sel-reselect calc-keep-selection) |
251 |
(entry (calc-top num 'entry)) |
(entry (calc-top num 'entry)) |
252 |
(expr (car entry)) |
(expr (car entry)) |
253 |
(sel (or (calc-auto-selection entry) (error "No selection"))) |
(sel (or (calc-auto-selection entry) (error "No selection"))) |
270 |
(list (calc-replace-sub-formula |
(list (calc-replace-sub-formula |
271 |
expr eqn soln)) |
expr eqn soln)) |
272 |
num |
num |
273 |
(list (and reselect sel))) |
(list (and calc-sel-reselect sel))) |
274 |
(calc-handle-whys)))) |
(calc-handle-whys)))) |
275 |
|
|
276 |
(defun calc-sel-commute (many) |
(defun calc-sel-commute (many) |