1 ;;; calc-trail.el --- functions for manipulating the Calc "trail"
3 ;; Copyright (C) 1990, 1991, 1992, 1993, 2001 Free Software Foundation, Inc.
5 ;; Author: David Gillespie <daveg@synaptics.com>
6 ;; Maintainers: D. Goel <deego@gnufans.org>
7 ;; Colin Walters <walters@debian.org>
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is distributed in the hope that it will be useful,
12 ;; but WITHOUT ANY WARRANTY. No author or distributor
13 ;; accepts responsibility to anyone for the consequences of using it
14 ;; or for whether it serves any particular purpose or works at all,
15 ;; unless he says so in writing. Refer to the GNU Emacs General Public
16 ;; License for full details.
18 ;; Everyone is granted permission to copy, modify and redistribute
19 ;; GNU Emacs, but only under the conditions described in the
20 ;; GNU Emacs General Public License. A copy of this license is
21 ;; supposed to have been given to you along with GNU Emacs so you
22 ;; can know your rights and responsibilities. It should be in a
23 ;; file named COPYING. Among other things, the copyright notice
24 ;; and this notice must be preserved on all copies.
30 ;; This file is autoloaded from calc-ext.el.
35 (defun calc-Need-calc-trail () nil
)
40 (defun calc-trail-in ()
42 (let ((win (get-buffer-window (calc-trail-display t
))))
43 (and win
(select-window win
))))
45 (defun calc-trail-out ()
48 (let ((win (get-buffer-window (current-buffer))))
52 (calc-align-stack-window))
55 (defun calc-trail-next (n)
57 (calc-with-trail-buffer
61 (defun calc-trail-previous (n)
63 (calc-with-trail-buffer
67 (defun calc-trail-first (n)
69 (calc-with-trail-buffer
70 (goto-char (point-min))
74 (defun calc-trail-last (n)
76 (calc-with-trail-buffer
77 (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
)))))
91 (defun calc-trail-scroll-right (n)
93 (let ((curwin (selected-window)))
94 (calc-with-trail-buffer
97 (select-window (get-buffer-window (current-buffer)))
98 (calc-scroll-right n
))
99 (select-window curwin
)))))
101 (defun calc-trail-forward (n)
103 (calc-with-trail-buffer
104 (forward-line (* n
(1- (window-height))))
107 (defun calc-trail-backward (n)
109 (calc-with-trail-buffer
110 (forward-line (- (* n
(1- (window-height)))))
113 (defun calc-trail-isearch-forward ()
115 (calc-with-trail-buffer
116 (save-window-excursion
117 (select-window (get-buffer-window (current-buffer)))
118 (let ((search-exit-char ?
\r))
122 (defun calc-trail-isearch-backward ()
124 (calc-with-trail-buffer
125 (save-window-excursion
126 (select-window (get-buffer-window (current-buffer)))
127 (let ((search-exit-char ?
\r))
131 (defun calc-trail-yank (arg)
134 (or arg
(calc-set-command-flag 'hold-trail
))
135 (calc-enter-result 0 "yank"
136 (calc-with-trail-buffer
138 (forward-line (- (prefix-numeric-value arg
))))
139 (if (or (looking-at "Emacs Calc")
141 (looking-at " ? ? ?[^ \n]* *$")
142 (looking-at "..?.?$"))
143 (error "Can't yank that line"))
144 (if (looking-at ".*, \\.\\.\\., ")
145 (error "Can't yank (vector was abbreviated)"))
148 (let* ((next (save-excursion (forward-line 1) (point)))
149 (str (buffer-substring (point) (1- next
)))
151 (set-buffer save-buf
)
152 (math-read-plain-expr str
))))
153 (if (eq (car-safe val
) 'error
)
154 (error "Can't yank that line: %s" (nth 2 val
))
157 (defun calc-trail-marker (str)
158 (interactive "sText to insert in trail: ")
159 (calc-with-trail-buffer
161 (let ((buffer-read-only nil
))
162 (insert "---- " str
"\n"))
166 (defun calc-trail-kill (n)
168 (calc-with-trail-buffer
169 (let ((buffer-read-only nil
))
171 (narrow-to-region ; don't delete "Emacs Trail" header
173 (goto-char (point-min))
180 ;;; calc-trail.el ends here