55 |
(if (not no-delete) |
(if (not no-delete) |
56 |
(calc-pop-stack n (- num n -1)))) |
(calc-pop-stack n (- num n -1)))) |
57 |
(setq calc-last-kill (cons (car kill-ring) stuff))))) |
(setq calc-last-kill (cons (car kill-ring) stuff))))) |
58 |
(kill-line nn)) |
(kill-line nn))) |
|
) |
|
59 |
|
|
60 |
(defun calc-force-refresh () |
(defun calc-force-refresh () |
61 |
(if (or calc-executing-macro calc-display-dirty) |
(if (or calc-executing-macro calc-display-dirty) |
62 |
(let ((calc-executing-macro nil)) |
(let ((calc-executing-macro nil)) |
63 |
(calc-refresh))) |
(calc-refresh)))) |
|
) |
|
64 |
|
|
65 |
(defun calc-locate-cursor-element (pt) |
(defun calc-locate-cursor-element (pt) |
66 |
(save-excursion |
(save-excursion |
67 |
(goto-char (point-max)) |
(goto-char (point-max)) |
68 |
(calc-locate-cursor-scan (- calc-stack-top) calc-stack pt)) |
(calc-locate-cursor-scan (- calc-stack-top) calc-stack pt))) |
|
) |
|
69 |
|
|
70 |
(defun calc-locate-cursor-scan (n stack pt) |
(defun calc-locate-cursor-scan (n stack pt) |
71 |
(if (or (<= (point) pt) |
(if (or (<= (point) pt) |
72 |
(null stack)) |
(null stack)) |
73 |
n |
n |
74 |
(forward-line (- (nth 1 (car stack)))) |
(forward-line (- (nth 1 (car stack)))) |
75 |
(calc-locate-cursor-scan (1+ n) (cdr stack) pt)) |
(calc-locate-cursor-scan (1+ n) (cdr stack) pt))) |
|
) |
|
76 |
|
|
77 |
(defun calc-kill-region (top bot &optional no-delete) |
(defun calc-kill-region (top bot &optional no-delete) |
78 |
(interactive "r") |
(interactive "r") |
90 |
(calc-pop-stack num bot-num)))) |
(calc-pop-stack num bot-num)))) |
91 |
(if no-delete |
(if no-delete |
92 |
(copy-region-as-kill top bot) |
(copy-region-as-kill top bot) |
93 |
(kill-region top bot))) |
(kill-region top bot)))) |
|
) |
|
94 |
|
|
95 |
(defun calc-copy-as-kill (n) |
(defun calc-copy-as-kill (n) |
96 |
(interactive "P") |
(interactive "P") |
97 |
(calc-kill n t) |
(calc-kill n t)) |
|
) |
|
98 |
|
|
99 |
(defun calc-copy-region-as-kill (top bot) |
(defun calc-copy-region-as-kill (top bot) |
100 |
(interactive "r") |
(interactive "r") |
101 |
(calc-kill-region top bot t) |
(calc-kill-region top bot t)) |
|
) |
|
102 |
|
|
103 |
;;; This function uses calc-last-kill if possible to get an exact result, |
;;; This function uses calc-last-kill if possible to get an exact result, |
104 |
;;; otherwise it just parses the yanked string. |
;;; otherwise it just parses the yanked string. |
121 |
(if (eq (car-safe val) 'error) |
(if (eq (car-safe val) 'error) |
122 |
(error "Bad format in yanked data") |
(error "Bad format in yanked data") |
123 |
val)) |
val)) |
124 |
val))))))) |
val)))))))) |
|
) |
|
125 |
|
|
126 |
(defun calc-clean-newlines (s) |
(defun calc-clean-newlines (s) |
127 |
(cond |
(cond |
136 |
(calc-clean-newlines (concat (math-match-substring s 1) "," |
(calc-clean-newlines (concat (math-match-substring s 1) "," |
137 |
(math-match-substring s 2)))) |
(math-match-substring s 2)))) |
138 |
|
|
139 |
(t s)) |
(t s))) |
|
) |
|
140 |
|
|
141 |
|
|
142 |
(defun calc-do-grab-region (top bot arg) |
(defun calc-do-grab-region (top bot arg) |
182 |
(forward-char (+ (nth 1 vals) (if single 0 1))) |
(forward-char (+ (nth 1 vals) (if single 0 1))) |
183 |
(error (nth 2 vals)))) |
(error (nth 2 vals)))) |
184 |
(calc-slow-wrapper |
(calc-slow-wrapper |
185 |
(calc-enter-result 0 "grab" vals))) |
(calc-enter-result 0 "grab" vals)))) |
|
) |
|
186 |
|
|
187 |
|
|
188 |
(defun calc-do-grab-rectangle (top bot arg &optional reduce) |
(defun calc-do-grab-rectangle (top bot arg &optional reduce) |
263 |
(if reduce |
(if reduce |
264 |
(calc-enter-result 0 "grb+" (list reduce '(var add var-add) |
(calc-enter-result 0 "grb+" (list reduce '(var add var-add) |
265 |
(nreverse mat))) |
(nreverse mat))) |
266 |
(calc-enter-result 0 "grab" (nreverse mat))))) |
(calc-enter-result 0 "grab" (nreverse mat)))))) |
|
) |
|
267 |
|
|
268 |
|
|
269 |
(defun calc-copy-to-buffer (nn) |
(defun calc-copy-to-buffer (nn) |
343 |
(not thebuf) |
(not thebuf) |
344 |
(progn |
(progn |
345 |
(calc-quit t) |
(calc-quit t) |
346 |
(switch-to-buffer newbuf)))) |
(switch-to-buffer newbuf))))) |
|
) |
|
347 |
|
|
348 |
(defun calc-overwrite-string (str eat-lnums) |
(defun calc-overwrite-string (str eat-lnums) |
349 |
(if (string-match "\n\\'" str) |
(if (string-match "\n\\'" str) |
367 |
(forward-char 1)) |
(forward-char 1)) |
368 |
(if eat-lnums (setq i (+ i 4))))) |
(if eat-lnums (setq i (+ i 4))))) |
369 |
(self-insert-command 1)) |
(self-insert-command 1)) |
370 |
(setq i (1+ i))))) |
(setq i (1+ i)))))) |
|
) |
|
371 |
|
|
372 |
;;; First, require that buffer is visible and does not begin with "*" |
;;; First, require that buffer is visible and does not begin with "*" |
373 |
;;; Second, require only that it not begin with "*Calc" |
;;; Second, require only that it not begin with "*Calc" |
379 |
(or (string-match "\\`\\*.*" (buffer-name (car buf))) |
(or (string-match "\\`\\*.*" (buffer-name (car buf))) |
380 |
(not (get-buffer-window (car buf)))))) |
(not (get-buffer-window (car buf)))))) |
381 |
(calc-find-writable-buffer (cdr buf) mode) |
(calc-find-writable-buffer (cdr buf) mode) |
382 |
(car buf))) |
(car buf)))) |
|
) |
|
383 |
|
|
384 |
|
|
385 |
(defun calc-edit (n) |
(defun calc-edit (n) |
404 |
(while list |
(while list |
405 |
(insert (car list) "\n") |
(insert (car list) "\n") |
406 |
(setq list (cdr list))))) |
(setq list (cdr list))))) |
407 |
(calc-show-edit-buffer) |
(calc-show-edit-buffer)) |
|
) |
|
408 |
|
|
409 |
(defun calc-alg-edit (str) |
(defun calc-alg-edit (str) |
410 |
(calc-edit-mode '(calc-finish-stack-edit 0)) |
(calc-edit-mode '(calc-finish-stack-edit 0)) |
411 |
(calc-show-edit-buffer) |
(calc-show-edit-buffer) |
412 |
(insert str "\n") |
(insert str "\n") |
413 |
(backward-char 1) |
(backward-char 1) |
414 |
(calc-set-command-flag 'do-edit) |
(calc-set-command-flag 'do-edit)) |
|
) |
|
415 |
|
|
416 |
(defvar calc-edit-mode-map nil "Keymap for use by the calc-edit command.") |
(defvar calc-edit-mode-map nil "Keymap for use by the calc-edit command.") |
417 |
(if calc-edit-mode-map |
(if calc-edit-mode-map |
419 |
(setq calc-edit-mode-map (make-sparse-keymap)) |
(setq calc-edit-mode-map (make-sparse-keymap)) |
420 |
(define-key calc-edit-mode-map "\n" 'calc-edit-finish) |
(define-key calc-edit-mode-map "\n" 'calc-edit-finish) |
421 |
(define-key calc-edit-mode-map "\r" 'calc-edit-return) |
(define-key calc-edit-mode-map "\r" 'calc-edit-return) |
422 |
(define-key calc-edit-mode-map "\C-c\C-c" 'calc-edit-finish) |
(define-key calc-edit-mode-map "\C-c\C-c" 'calc-edit-finish)) |
|
) |
|
423 |
|
|
424 |
(defun calc-edit-mode (&optional handler allow-ret title) |
(defun calc-edit-mode (&optional handler allow-ret title) |
425 |
"Calculator editing mode. Press RET, LFD, or C-c C-c to finish. |
"Calculator editing mode. Press RET, LFD, or C-c C-c to finish. |
459 |
(if (eq (lookup-key (current-global-map) "\e#") 'calc-dispatch) |
(if (eq (lookup-key (current-global-map) "\e#") 'calc-dispatch) |
460 |
"M-# x" |
"M-# x" |
461 |
"C-x k RET") |
"C-x k RET") |
462 |
" to cancel.\n")) |
" to cancel.\n"))) |
|
) |
|
463 |
(put 'calc-edit-mode 'mode-class 'special) |
(put 'calc-edit-mode 'mode-class 'special) |
464 |
|
|
465 |
(defun calc-show-edit-buffer () |
(defun calc-show-edit-buffer () |
477 |
(delete-window win)))) |
(delete-window win)))) |
478 |
(set-buffer-modified-p nil) |
(set-buffer-modified-p nil) |
479 |
(goto-char (point-min)) |
(goto-char (point-min)) |
480 |
(forward-line 1)) |
(forward-line 1))) |
|
) |
|
481 |
|
|
482 |
(defun calc-edit-return () |
(defun calc-edit-return () |
483 |
(interactive) |
(interactive) |
484 |
(if (and (boundp 'calc-allow-ret) calc-allow-ret) |
(if (and (boundp 'calc-allow-ret) calc-allow-ret) |
485 |
(newline) |
(newline) |
486 |
(calc-edit-finish)) |
(calc-edit-finish))) |
|
) |
|
487 |
|
|
488 |
(defun calc-edit-finish (&optional keep) |
(defun calc-edit-finish (&optional keep) |
489 |
"Finish calc-edit mode. Parse buffer contents and push them on the stack." |
"Finish calc-edit mode. Parse buffer contents and push them on the stack." |
523 |
(if disp-trail |
(if disp-trail |
524 |
(calc-wrapper |
(calc-wrapper |
525 |
(calc-trail-display 1 t))) |
(calc-trail-display 1 t))) |
526 |
(message "")) |
(message ""))) |
|
) |
|
527 |
|
|
528 |
(defun calc-edit-cancel () |
(defun calc-edit-cancel () |
529 |
"Cancel calc-edit mode. Ignore the Calc Edit buffer and don't change stack." |
"Cancel calc-edit mode. Ignore the Calc Edit buffer and don't change stack." |
530 |
(interactive) |
(interactive) |
531 |
(let ((calc-edit-handler nil)) |
(let ((calc-edit-handler nil)) |
532 |
(calc-edit-finish)) |
(calc-edit-finish)) |
533 |
(message "(Cancelled)") |
(message "(Cancelled)")) |
|
) |
|
534 |
|
|
535 |
(defun calc-finish-stack-edit (num) |
(defun calc-finish-stack-edit (num) |
536 |
(let ((buf (current-buffer)) |
(let ((buf (current-buffer)) |
563 |
calc-simplify-mode))) |
calc-simplify-mode))) |
564 |
(if (>= num 0) |
(if (>= num 0) |
565 |
(calc-enter-result num "edit" vals) |
(calc-enter-result num "edit" vals) |
566 |
(calc-enter-result 1 "edit" vals (- num))))))))) |
(calc-enter-result 1 "edit" vals (- num)))))))))) |
|
) |
|
|
|
|
|
|
|
|
|
|
567 |
|
|
568 |
|
;;; calc-yank.el ends here |