• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /macosx-10.10.1/emacs-93/emacs/lisp/calc/

Lines Matching +defs:calc +defs:trail +defs:mode

0 ;;; calc-yank.el --- kill-ring functionality for Calc
30 ;; This file is autoloaded from calc-ext.el.
32 (require 'calc-ext)
33 (require 'calc-macs)
37 (defun calc-kill (nn &optional no-delete)
39 (if (eq major-mode 'calc-mode)
40 (calc-wrapper
41 (calc-force-refresh)
42 (calc-set-command-flag 'no-align)
43 (let ((num (max (calc-locate-cursor-element (point)) 1))
51 (let ((stuff (calc-top-list n (- num n -1))))
52 (calc-cursor-stack-index num)
54 (calc-cursor-stack-index (- num n))
59 (calc-pop-stack n (- num n -1))))
60 (setq calc-last-kill (cons (car kill-ring) stuff)))))
63 (defun calc-force-refresh ()
64 (if (or calc-executing-macro calc-display-dirty)
65 (let ((calc-executing-macro nil))
66 (calc-refresh))))
68 (defun calc-locate-cursor-element (pt)
71 (calc-locate-cursor-scan (- calc-stack-top) calc-stack pt)))
73 (defun calc-locate-cursor-scan (n stack pt)
78 (calc-locate-cursor-scan (1+ n) (cdr stack) pt)))
80 (defun calc-kill-region (top bot &optional no-delete)
82 (if (eq major-mode 'calc-mode)
83 (calc-wrapper
84 (calc-force-refresh)
85 (calc-set-command-flag 'no-align)
86 (let* ((top-num (calc-locate-cursor-element top))
87 (bot-num (calc-locate-cursor-element (1- bot)))
90 (setq calc-last-kill (cons (car kill-ring)
91 (calc-top-list num bot-num)))
93 (calc-pop-stack num bot-num))))
98 (defun calc-copy-as-kill (n)
100 (calc-kill n t))
102 (defun calc-copy-region-as-kill (top bot)
104 (calc-kill-region top bot t))
106 ;;; This function uses calc-last-kill if possible to get an exact result,
109 (defun calc-yank ()
111 (calc-wrapper
112 (calc-pop-push-record-list
117 (if (eq (car-safe calc-last-kill) thing)
118 (cdr calc-last-kill)
120 (let ((val (math-read-exprs (calc-clean-newlines thing))))
129 (defun calc-clean-newlines (s)
135 (calc-clean-newlines (math-match-substring s 1)))
139 (calc-clean-newlines (concat (math-match-substring s 1) ","
145 (defun calc-do-grab-region (top bot arg)
146 (when (memq major-mode '(calc-mode calc-trail-mode))
149 (calc-was-started (get-buffer-window "*Calculator*"))
170 (calc)
180 (if calc-was-started
182 (calc-quit t)
187 (calc-slow-wrapper
188 (calc-enter-result 0 "grab" vals))))
191 (defun calc-do-grab-rectangle (top bot arg &optional reduce)
192 (and (memq major-mode '(calc-mode calc-trail-mode))
197 (calc-was-started (get-buffer-window "*Calculator*"))
210 (calc)
253 (if calc-was-started
255 (calc-quit t)
265 (calc-slow-wrapper
267 (calc-enter-result 0 "grb+" (list reduce '(var add var-add)
269 (calc-enter-result 0 "grab" (nreverse mat))))))
272 (defun calc-copy-to-buffer (nn)
275 (let ((thebuf (and (not (memq major-mode '(calc-mode calc-trail-mode)))
279 (calc-wrapper
281 (calc-force-refresh)
283 (eat-lnums calc-line-numbering)
284 (big-offset (if (eq calc-language 'big) 1 0))
288 (calc-find-writable-buffer (buffer-list) 0)
289 (calc-find-writable-buffer (buffer-list) 1)
293 (= (calc-substack-height 0)
294 (- (1- (calc-substack-height 1)) big-offset)))
295 (calc-cursor-stack-index 1)
297 (if calc-line-numbering "[0-9]+: *[^ \n]" " *[^ \n]"))
301 (calc-cursor-stack-index 0)
304 (calc-cursor-stack-index n)
306 (calc-cursor-stack-index 0)
309 (calc-cursor-stack-index (- n))
311 (calc-cursor-stack-index (1- (- n)))
317 (calc-cursor-stack-index 0)
324 (if (and overwrite-mode (not (consp nn)))
325 (calc-overwrite-string (save-excursion
349 (calc-quit t)
352 (defun calc-overwrite-string (str eat-lnums)
378 (defun calc-find-writable-buffer (buf mode)
382 (and (= mode 0)
385 (calc-find-writable-buffer (cdr buf) mode)
389 (defun calc-edit (n)
391 (calc-slow-wrapper
393 (setq n (calc-stack-size)))
405 (calc-top-list n)
406 (calc-top-list 1 (- n)))))))
407 (calc-edit-mode (list 'calc-finish-stack-edit (or flag n)) allow-ret)
411 (calc-show-edit-buffer))
413 (defun calc-alg-edit (str)
414 (calc-edit-mode '(calc-finish-stack-edit 0))
415 (calc-show-edit-buffer)
418 (calc-set-command-flag 'do-edit))
420 (defvar calc-edit-mode-map nil "Keymap for use by the calc-edit command.")
421 (if calc-edit-mode-map
423 (setq calc-edit-mode-map (make-sparse-keymap))
424 (define-key calc-edit-mode-map "\n" 'calc-edit-finish)
425 (define-key calc-edit-mode-map "\r" 'calc-edit-return)
426 (define-key calc-edit-mode-map "\C-c\C-c" 'calc-edit-finish))
428 (defvar calc-original-buffer)
429 (defvar calc-return-buffer)
430 (defvar calc-one-window)
431 (defvar calc-edit-handler)
432 (defvar calc-restore-trail)
433 (defvar calc-allow-ret)
434 (defvar calc-edit-top)
436 (defun calc-edit-mode (&optional handler allow-ret title)
437 "Calculator editing mode. Press RET, LFD, or C-c C-c to finish.
441 (error "This command can be used only indirectly through calc-edit"))
446 (use-local-map calc-edit-mode-map)
449 (setq major-mode 'calc-edit-mode)
450 (setq mode-name "Calc Edit")
451 (run-mode-hooks 'calc-edit-mode-hook)
452 (make-local-variable 'calc-original-buffer)
453 (setq calc-original-buffer oldbuf)
454 (make-local-variable 'calc-return-buffer)
455 (setq calc-return-buffer oldbuf)
456 (make-local-variable 'calc-one-window)
457 (setq calc-one-window (and (one-window-p t) pop-up-windows))
458 (make-local-variable 'calc-edit-handler)
459 (setq calc-edit-handler handler)
460 (make-local-variable 'calc-restore-trail)
461 (setq calc-restore-trail (get-buffer-window (calc-trail-buffer)))
462 (make-local-variable 'calc-allow-ret)
463 (setq calc-allow-ret allow-ret)
467 (let ((calc-edit-handler nil))
468 (calc-edit-finish t))
477 (make-local-variable 'calc-edit-top)
478 (setq calc-edit-top (point))))
479 (put 'calc-edit-mode 'mode-class 'special)
481 (defun calc-show-edit-buffer ()
485 (and calc-embedded-info (get-buffer-window (aref calc-embedded-info 1))
486 (select-window (get-buffer-window (aref calc-embedded-info 1))))
488 (setq calc-return-buffer buf)
490 calc-display-trail)
491 (let ((win (get-buffer-window (calc-trail-buffer))))
495 (goto-char calc-edit-top)))
497 (defun calc-edit-return ()
499 (if (and (boundp 'calc-allow-ret) calc-allow-ret)
501 (calc-edit-finish)))
503 ;; The variable calc-edit-disp-trail is local to calc-edit finish, but
504 ;; is used by calc-finish-selection-edit and calc-finish-stack-edit.
505 (defvar calc-edit-disp-trail)
507 (defun calc-edit-finish (&optional keep)
508 "Finish calc-edit mode. Parse buffer contents and push them on the stack."
511 (or (and (boundp 'calc-original-buffer)
512 (boundp 'calc-return-buffer)
513 (boundp 'calc-one-window)
514 (boundp 'calc-edit-handler)
515 (boundp 'calc-restore-trail)
516 (eq major-mode 'calc-edit-mode))
517 (error "This command is valid only in buffers created by calc-edit"))
519 (original calc-original-buffer)
520 (return calc-return-buffer)
521 (one-window calc-one-window)
522 (calc-edit-disp-trail calc-restore-trail))
527 (not (eq major-mode 'calc-mode))))
529 (goto-char calc-edit-top)
531 (eval calc-edit-handler))
540 (if calc-edit-disp-trail
541 (calc-wrapper
542 (calc-trail-display 1 t)))
545 (defun calc-edit-cancel ()
546 "Cancel calc-edit mode. Ignore the Calc Edit buffer and don't change stack."
548 (let ((calc-edit-handler nil))
549 (calc-edit-finish))
552 (defun calc-finish-stack-edit (num)
554 (str (buffer-substring calc-edit-top (point-max)))
560 (switch-to-buffer calc-original-buffer)
561 (let ((vals (let ((calc-language nil)
569 (calc-wrapper
573 (calc-refresh-evaltos num))
574 (if calc-edit-disp-trail
575 (calc-trail-display 1 t))
577 (let ((calc-simplify-mode (if (eq last-command-char ?\C-j)
579 calc-simplify-mode)))
581 (calc-enter-result num "edit" vals)
582 (calc-enter-result 1 "edit" vals (- num))))))))))
584 (provide 'calc-yank)
587 ;;; calc-yank.el ends here