Mercurial > emacs
comparison lisp/calc/calc-prog.el @ 112392:70d7e5c6e611
calc/calc-prog.el
calc/calc-graph.el
calc/calc-map.el: Change `arglist' to `math-arglist' throughout.
author | Jay Belanger <jay.p.belanger@gmail.com> |
---|---|
date | Thu, 20 Jan 2011 21:48:26 -0600 |
parents | ef719132ddfa |
children |
comparison
equal
deleted
inserted
replaced
112391:93209af5dc0b | 112392:70d7e5c6e611 |
---|---|
169 | 169 |
170 (defun calc-user-define-formula () | 170 (defun calc-user-define-formula () |
171 (interactive) | 171 (interactive) |
172 (calc-wrapper | 172 (calc-wrapper |
173 (let* ((form (calc-top 1)) | 173 (let* ((form (calc-top 1)) |
174 (arglist nil) | 174 (math-arglist nil) |
175 (is-lambda (and (eq (car-safe form) 'calcFunc-lambda) | 175 (is-lambda (and (eq (car-safe form) 'calcFunc-lambda) |
176 (>= (length form) 2))) | 176 (>= (length form) 2))) |
177 odef key keyname cmd cmd-base cmd-base-default | 177 odef key keyname cmd cmd-base cmd-base-default |
178 func calc-user-formula-alist is-symb) | 178 func calc-user-formula-alist is-symb) |
179 (if is-lambda | 179 (if is-lambda |
180 (setq arglist (mapcar (function (lambda (x) (nth 1 x))) | 180 (setq math-arglist (mapcar (function (lambda (x) (nth 1 x))) |
181 (nreverse (cdr (reverse (cdr form))))) | 181 (nreverse (cdr (reverse (cdr form))))) |
182 form (nth (1- (length form)) form)) | 182 form (nth (1- (length form)) form)) |
183 (calc-default-formula-arglist form) | 183 (calc-default-formula-arglist form) |
184 (setq arglist (sort arglist 'string-lessp))) | 184 (setq math-arglist (sort math-arglist 'string-lessp))) |
185 (message "Define user key: z-") | 185 (message "Define user key: z-") |
186 (setq key (read-char)) | 186 (setq key (read-char)) |
187 (if (= (calc-user-function-classify key) 0) | 187 (if (= (calc-user-function-classify key) 0) |
188 (error "Can't redefine \"?\" key")) | 188 (error "Can't redefine \"?\" key")) |
189 (setq key (and (not (memq key '(13 32))) key) | 189 (setq key (and (not (memq key '(13 32))) key) |
265 (or keyname | 265 (or keyname |
266 (and cmd (symbol-name cmd)) | 266 (and cmd (symbol-name cmd)) |
267 (format "%05d" (% (random) 10000))))))) | 267 (format "%05d" (% (random) 10000))))))) |
268 | 268 |
269 (if is-lambda | 269 (if is-lambda |
270 (setq calc-user-formula-alist arglist) | 270 (setq calc-user-formula-alist math-arglist) |
271 (while | 271 (while |
272 (progn | 272 (progn |
273 (setq calc-user-formula-alist | 273 (setq calc-user-formula-alist |
274 (read-from-minibuffer "Function argument list: " | 274 (read-from-minibuffer "Function argument list: " |
275 (if arglist | 275 (if math-arglist |
276 (prin1-to-string arglist) | 276 (prin1-to-string math-arglist) |
277 "()") | 277 "()") |
278 minibuffer-local-map | 278 minibuffer-local-map |
279 t)) | 279 t)) |
280 (and (not (calc-subsetp calc-user-formula-alist arglist)) | 280 (and (not (calc-subsetp calc-user-formula-alist math-arglist)) |
281 (not (y-or-n-p | 281 (not (y-or-n-p |
282 "Okay for arguments that don't appear in formula to be ignored? ")))))) | 282 "Okay for arguments that don't appear in formula to be ignored? ")))))) |
283 (setq is-symb (and calc-user-formula-alist | 283 (setq is-symb (and calc-user-formula-alist |
284 func | 284 func |
285 (y-or-n-p | 285 (y-or-n-p |
326 (if old | 326 (if old |
327 (setcdr old cmd) | 327 (setcdr old cmd) |
328 (setcdr kmap (cons (cons key cmd) (cdr kmap))))))) | 328 (setcdr kmap (cons (cons key cmd) (cdr kmap))))))) |
329 (message ""))) | 329 (message ""))) |
330 | 330 |
331 (defvar arglist) ; dynamically bound in all callers | 331 (defvar math-arglist) ; dynamically bound in all callers |
332 (defun calc-default-formula-arglist (form) | 332 (defun calc-default-formula-arglist (form) |
333 (if (consp form) | 333 (if (consp form) |
334 (if (eq (car form) 'var) | 334 (if (eq (car form) 'var) |
335 (if (or (memq (nth 1 form) arglist) | 335 (if (or (memq (nth 1 form) math-arglist) |
336 (math-const-var form)) | 336 (math-const-var form)) |
337 () | 337 () |
338 (setq arglist (cons (nth 1 form) arglist))) | 338 (setq math-arglist (cons (nth 1 form) math-arglist))) |
339 (calc-default-formula-arglist-step (cdr form))))) | 339 (calc-default-formula-arglist-step (cdr form))))) |
340 | 340 |
341 (defun calc-default-formula-arglist-step (l) | 341 (defun calc-default-formula-arglist-step (l) |
342 (and l | 342 (and l |
343 (progn | 343 (progn |
392 (lambda (x) | 392 (lambda (x) |
393 (fboundp | 393 (fboundp |
394 (intern (concat "calcFunc-" x)))))))) | 394 (intern (concat "calcFunc-" x)))))))) |
395 (comps (get func 'math-compose-forms)) | 395 (comps (get func 'math-compose-forms)) |
396 entry entry2 | 396 entry entry2 |
397 (arglist nil) | 397 (math-arglist nil) |
398 (calc-user-formula-alist nil)) | 398 (calc-user-formula-alist nil)) |
399 (if (math-zerop comp) | 399 (if (math-zerop comp) |
400 (if (setq entry (assq calc-language comps)) | 400 (if (setq entry (assq calc-language comps)) |
401 (put func 'math-compose-forms (delq entry comps))) | 401 (put func 'math-compose-forms (delq entry comps))) |
402 (calc-default-formula-arglist comp) | 402 (calc-default-formula-arglist comp) |
403 (setq arglist (sort arglist 'string-lessp)) | 403 (setq math-arglist (sort math-arglist 'string-lessp)) |
404 (while | 404 (while |
405 (progn | 405 (progn |
406 (setq calc-user-formula-alist | 406 (setq calc-user-formula-alist |
407 (read-from-minibuffer "Composition argument list: " | 407 (read-from-minibuffer "Composition argument list: " |
408 (if arglist | 408 (if math-arglist |
409 (prin1-to-string arglist) | 409 (prin1-to-string math-arglist) |
410 "()") | 410 "()") |
411 minibuffer-local-map | 411 minibuffer-local-map |
412 t)) | 412 t)) |
413 (and (not (calc-subsetp calc-user-formula-alist arglist)) | 413 (and (not (calc-subsetp calc-user-formula-alist math-arglist)) |
414 (y-or-n-p | 414 (y-or-n-p |
415 "Okay for arguments that don't appear in formula to be invisible? ")))) | 415 "Okay for arguments that don't appear in formula to be invisible? ")))) |
416 (or (setq entry (assq calc-language comps)) | 416 (or (setq entry (assq calc-language comps)) |
417 (put func 'math-compose-forms | 417 (put func 'math-compose-forms |
418 (cons (setq entry (list calc-language)) comps))) | 418 (cons (setq entry (list calc-language)) comps))) |