| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 |
|
|---|
| 25 |
|
|---|
| 26 |
|
|---|
| 27 |
|
|---|
| 28 |
|
|---|
| 29 |
|
|---|
| 30 |
|
|---|
| 31 |
|
|---|
| 32 |
(require 'calc-ext) |
|---|
| 33 |
(require 'calc-macs) |
|---|
| 34 |
|
|---|
| 35 |
|
|---|
| 36 |
|
|---|
| 37 |
(defun calc-trail-in () |
|---|
| 38 |
(interactive) |
|---|
| 39 |
(let ((win (get-buffer-window (calc-trail-display t)))) |
|---|
| 40 |
(and win (select-window win)))) |
|---|
| 41 |
|
|---|
| 42 |
(defun calc-trail-out () |
|---|
| 43 |
(interactive) |
|---|
| 44 |
(calc-select-buffer) |
|---|
| 45 |
(let ((win (get-buffer-window (current-buffer)))) |
|---|
| 46 |
(if win |
|---|
| 47 |
(progn |
|---|
| 48 |
(select-window win) |
|---|
| 49 |
(calc-align-stack-window)) |
|---|
| 50 |
(calc)))) |
|---|
| 51 |
|
|---|
| 52 |
(defun calc-trail-next (n) |
|---|
| 53 |
(interactive "p") |
|---|
| 54 |
(calc-with-trail-buffer |
|---|
| 55 |
(forward-line n) |
|---|
| 56 |
(calc-trail-here))) |
|---|
| 57 |
|
|---|
| 58 |
(defun calc-trail-previous (n) |
|---|
| 59 |
(interactive "p") |
|---|
| 60 |
(calc-with-trail-buffer |
|---|
| 61 |
(forward-line (- n)) |
|---|
| 62 |
(calc-trail-here))) |
|---|
| 63 |
|
|---|
| 64 |
(defun calc-trail-first (n) |
|---|
| 65 |
(interactive "p") |
|---|
| 66 |
(calc-with-trail-buffer |
|---|
| 67 |
(goto-char (point-min)) |
|---|
| 68 |
(forward-line n) |
|---|
| 69 |
(calc-trail-here))) |
|---|
| 70 |
|
|---|
| 71 |
(defun calc-trail-last (n) |
|---|
| 72 |
(interactive "p") |
|---|
| 73 |
(calc-with-trail-buffer |
|---|
| 74 |
(goto-char (point-max)) |
|---|
| 75 |
(forward-line (- n)) |
|---|
| 76 |
(calc-trail-here))) |
|---|
| 77 |
|
|---|
| 78 |
(defun calc-trail-scroll-left (n) |
|---|
| 79 |
(interactive "P") |
|---|
| 80 |
(let ((curwin (selected-window))) |
|---|
| 81 |
(calc-with-trail-buffer |
|---|
| 82 |
(unwind-protect |
|---|
| 83 |
(progn |
|---|
| 84 |
(select-window (get-buffer-window (current-buffer))) |
|---|
| 85 |
(calc-scroll-left n)) |
|---|
| 86 |
(select-window curwin))))) |
|---|
| 87 |
|
|---|
| 88 |
(defun calc-trail-scroll-right (n) |
|---|
| 89 |
(interactive "P") |
|---|
| 90 |
(let ((curwin (selected-window))) |
|---|
| 91 |
(calc-with-trail-buffer |
|---|
| 92 |
(unwind-protect |
|---|
| 93 |
(progn |
|---|
| 94 |
(select-window (get-buffer-window (current-buffer))) |
|---|
| 95 |
(calc-scroll-right n)) |
|---|
| 96 |
(select-window curwin))))) |
|---|
| 97 |
|
|---|
| 98 |
(defun calc-trail-forward (n) |
|---|
| 99 |
(interactive "p") |
|---|
| 100 |
(calc-with-trail-buffer |
|---|
| 101 |
(forward-line (* n (1- (window-height)))) |
|---|
| 102 |
(calc-trail-here))) |
|---|
| 103 |
|
|---|
| 104 |
(defun calc-trail-backward (n) |
|---|
| 105 |
(interactive "p") |
|---|
| 106 |
(calc-with-trail-buffer |
|---|
| 107 |
(forward-line (- (* n (1- (window-height))))) |
|---|
| 108 |
(calc-trail-here))) |
|---|
| 109 |
|
|---|
| 110 |
(defun calc-trail-isearch-forward () |
|---|
| 111 |
(interactive) |
|---|
| 112 |
(calc-with-trail-buffer |
|---|
| 113 |
(save-window-excursion |
|---|
| 114 |
(select-window (get-buffer-window (current-buffer))) |
|---|
| 115 |
(let ((search-exit-char ?\r)) |
|---|
| 116 |
(isearch-forward))) |
|---|
| 117 |
(calc-trail-here))) |
|---|
| 118 |
|
|---|
| 119 |
(defun calc-trail-isearch-backward () |
|---|
| 120 |
(interactive) |
|---|
| 121 |
(calc-with-trail-buffer |
|---|
| 122 |
(save-window-excursion |
|---|
| 123 |
(select-window (get-buffer-window (current-buffer))) |
|---|
| 124 |
(let ((search-exit-char ?\r)) |
|---|
| 125 |
(isearch-backward))) |
|---|
| 126 |
(calc-trail-here))) |
|---|
| 127 |
|
|---|
| 128 |
(defun calc-trail-yank (arg) |
|---|
| 129 |
(interactive "P") |
|---|
| 130 |
(calc-wrapper |
|---|
| 131 |
(or arg (calc-set-command-flag 'hold-trail)) |
|---|
| 132 |
(calc-enter-result 0 "yank" |
|---|
| 133 |
(calc-with-trail-buffer |
|---|
| 134 |
(if arg |
|---|
| 135 |
(forward-line (- (prefix-numeric-value arg)))) |
|---|
| 136 |
(if (or (looking-at "Emacs Calc") |
|---|
| 137 |
(looking-at "----") |
|---|
| 138 |
(looking-at " ? ? ?[^ \n]* *$") |
|---|
| 139 |
(looking-at "..?.?$")) |
|---|
| 140 |
(error "Can't yank that line")) |
|---|
| 141 |
(if (looking-at ".*, \\.\\.\\., ") |
|---|
| 142 |
(error "Can't yank (vector was abbreviated)")) |
|---|
| 143 |
(forward-char 4) |
|---|
| 144 |
(search-forward " ") |
|---|
| 145 |
(let* ((next (save-excursion (forward-line 1) (point))) |
|---|
| 146 |
(str (buffer-substring (point) (1- next))) |
|---|
| 147 |
(val (save-excursion |
|---|
| 148 |
(set-buffer save-buf) |
|---|
| 149 |
(math-read-plain-expr str)))) |
|---|
| 150 |
(if (eq (car-safe val) 'error) |
|---|
| 151 |
(error "Can't yank that line: %s" (nth 2 val)) |
|---|
| 152 |
val)))))) |
|---|
| 153 |
|
|---|
| 154 |
(defun calc-trail-marker (str) |
|---|
| 155 |
(interactive "sText to insert in trail: ") |
|---|
| 156 |
(calc-with-trail-buffer |
|---|
| 157 |
(forward-line 1) |
|---|
| 158 |
(let ((buffer-read-only nil)) |
|---|
| 159 |
(insert "---- " str "\n")) |
|---|
| 160 |
(forward-line -1) |
|---|
| 161 |
(calc-trail-here))) |
|---|
| 162 |
|
|---|
| 163 |
(defun calc-trail-kill (n) |
|---|
| 164 |
(interactive "p") |
|---|
| 165 |
(calc-with-trail-buffer |
|---|
| 166 |
(let ((buffer-read-only nil)) |
|---|
| 167 |
(save-restriction |
|---|
| 168 |
(narrow-to-region |
|---|
| 169 |
(save-excursion |
|---|
| 170 |
(goto-char (point-min)) |
|---|
| 171 |
(forward-line 1) |
|---|
| 172 |
(point)) |
|---|
| 173 |
(point-max)) |
|---|
| 174 |
(kill-line n))) |
|---|
| 175 |
(calc-trail-here))) |
|---|
| 176 |
|
|---|
| 177 |
(provide 'calc-trail) |
|---|
| 178 |
|
|---|
| 179 |
|
|---|
| 180 |
|
|---|
| 181 |
|
|---|