1 ;; Calculator for GNU Emacs, part II [calc-trail.el]
2 ;; Copyright (C) 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
3 ;; Written by Dave Gillespie, daveg@synaptics.com.
5 ;; This file is part of GNU Emacs.
7 ;; GNU Emacs is distributed in the hope that it will be useful,
8 ;; but WITHOUT ANY WARRANTY. No author or distributor
9 ;; accepts responsibility to anyone for the consequences of using it
10 ;; or for whether it serves any particular purpose or works at all,
11 ;; unless he says so in writing. Refer to the GNU Emacs General Public
12 ;; License for full details.
14 ;; Everyone is granted permission to copy, modify and redistribute
15 ;; GNU Emacs, but only under the conditions described in the
16 ;; GNU Emacs General Public License. A copy of this license is
17 ;; supposed to have been given to you along with GNU Emacs so you
18 ;; can know your rights and responsibilities. It should be in a
19 ;; file named COPYING. Among other things, the copyright notice
20 ;; and this notice must be preserved on all copies.
24 ;; This file is autoloaded from calc-ext.el.
29 (defun calc-Need-calc-trail () nil)
34 (defun calc-trail-in ()
36 (let ((win (get-buffer-window (calc-trail-display t))))
37 (and win (select-window win)))
40 (defun calc-trail-out ()
43 (let ((win (get-buffer-window (current-buffer))))
47 (calc-align-stack-window))
51 (defun calc-trail-next (n)
53 (calc-with-trail-buffer
58 (defun calc-trail-previous (n)
60 (calc-with-trail-buffer
65 (defun calc-trail-first (n)
67 (calc-with-trail-buffer
68 (goto-char (point-min))
73 (defun calc-trail-last (n)
75 (calc-with-trail-buffer
76 (goto-char (point-max))
81 (defun calc-trail-scroll-left (n)
83 (let ((curwin (selected-window)))
84 (calc-with-trail-buffer
87 (select-window (get-buffer-window (current-buffer)))
89 (select-window curwin))))
92 (defun calc-trail-scroll-right (n)
94 (let ((curwin (selected-window)))
95 (calc-with-trail-buffer
98 (select-window (get-buffer-window (current-buffer)))
99 (calc-scroll-right n))
100 (select-window curwin))))
103 (defun calc-trail-forward (n)
105 (calc-with-trail-buffer
106 (forward-line (* n (1- (window-height))))
110 (defun calc-trail-backward (n)
112 (calc-with-trail-buffer
113 (forward-line (- (* n (1- (window-height)))))
117 (defun calc-trail-isearch-forward ()
119 (calc-with-trail-buffer
120 (save-window-excursion
121 (select-window (get-buffer-window (current-buffer)))
122 (let ((search-exit-char ?\r))
127 (defun calc-trail-isearch-backward ()
129 (calc-with-trail-buffer
130 (save-window-excursion
131 (select-window (get-buffer-window (current-buffer)))
132 (let ((search-exit-char ?\r))
137 (defun calc-trail-yank (arg)
140 (or arg (calc-set-command-flag 'hold-trail))
141 (calc-enter-result 0 "yank"
142 (calc-with-trail-buffer
144 (forward-line (- (prefix-numeric-value arg))))
145 (if (or (looking-at "Emacs Calc")
147 (looking-at " ? ? ?[^ \n]* *$")
148 (looking-at "..?.?$"))
149 (error "Can't yank that line"))
150 (if (looking-at ".*, \\.\\.\\., ")
151 (error "Can't yank (vector was abbreviated)"))
154 (let* ((next (save-excursion (forward-line 1) (point)))
155 (str (buffer-substring (point) (1- next)))
157 (set-buffer save-buf)
158 (math-read-plain-expr str))))
159 (if (eq (car-safe val) 'error)
160 (error "Can't yank that line: %s" (nth 2 val))
164 (defun calc-trail-marker (str)
165 (interactive "sText to insert in trail: ")
166 (calc-with-trail-buffer
168 (let ((buffer-read-only nil))
169 (insert "---- " str "\n"))
174 (defun calc-trail-kill (n)
176 (calc-with-trail-buffer
177 (let ((buffer-read-only nil))
179 (narrow-to-region ; don't delete "Emacs Trail" header
181 (goto-char (point-min))