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 ;; Maintainer: Colin Walters <walters@debian.org>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is distributed in the hope that it will be useful,
11 ;; but WITHOUT ANY WARRANTY. No author or distributor
12 ;; accepts responsibility to anyone for the consequences of using it
13 ;; or for whether it serves any particular purpose or works at all,
14 ;; unless he says so in writing. Refer to the GNU Emacs General Public
15 ;; License for full details.
17 ;; Everyone is granted permission to copy, modify and redistribute
18 ;; GNU Emacs, but only under the conditions described in the
19 ;; GNU Emacs General Public License. A copy of this license is
20 ;; supposed to have been given to you along with GNU Emacs so you
21 ;; can know your rights and responsibilities. It should be in a
22 ;; file named COPYING. Among other things, the copyright notice
23 ;; and this notice must be preserved on all copies.
29 ;; This file is autoloaded from calc-ext.el.
34 (defun calc-Need-calc-trail () nil)
39 (defun calc-trail-in ()
41 (let ((win (get-buffer-window (calc-trail-display t))))
42 (and win (select-window win))))
44 (defun calc-trail-out ()
47 (let ((win (get-buffer-window (current-buffer))))
51 (calc-align-stack-window))
54 (defun calc-trail-next (n)
56 (calc-with-trail-buffer
60 (defun calc-trail-previous (n)
62 (calc-with-trail-buffer
66 (defun calc-trail-first (n)
68 (calc-with-trail-buffer
69 (goto-char (point-min))
73 (defun calc-trail-last (n)
75 (calc-with-trail-buffer
76 (goto-char (point-max))
80 (defun calc-trail-scroll-left (n)
82 (let ((curwin (selected-window)))
83 (calc-with-trail-buffer
86 (select-window (get-buffer-window (current-buffer)))
88 (select-window curwin)))))
90 (defun calc-trail-scroll-right (n)
92 (let ((curwin (selected-window)))
93 (calc-with-trail-buffer
96 (select-window (get-buffer-window (current-buffer)))
97 (calc-scroll-right n))
98 (select-window curwin)))))
100 (defun calc-trail-forward (n)
102 (calc-with-trail-buffer
103 (forward-line (* n (1- (window-height))))
106 (defun calc-trail-backward (n)
108 (calc-with-trail-buffer
109 (forward-line (- (* n (1- (window-height)))))
112 (defun calc-trail-isearch-forward ()
114 (calc-with-trail-buffer
115 (save-window-excursion
116 (select-window (get-buffer-window (current-buffer)))
117 (let ((search-exit-char ?\r))
121 (defun calc-trail-isearch-backward ()
123 (calc-with-trail-buffer
124 (save-window-excursion
125 (select-window (get-buffer-window (current-buffer)))
126 (let ((search-exit-char ?\r))
130 (defun calc-trail-yank (arg)
133 (or arg (calc-set-command-flag 'hold-trail))
134 (calc-enter-result 0 "yank"
135 (calc-with-trail-buffer
137 (forward-line (- (prefix-numeric-value arg))))
138 (if (or (looking-at "Emacs Calc")
140 (looking-at " ? ? ?[^ \n]* *$")
141 (looking-at "..?.?$"))
142 (error "Can't yank that line"))
143 (if (looking-at ".*, \\.\\.\\., ")
144 (error "Can't yank (vector was abbreviated)"))
147 (let* ((next (save-excursion (forward-line 1) (point)))
148 (str (buffer-substring (point) (1- next)))
150 (set-buffer save-buf)
151 (math-read-plain-expr str))))
152 (if (eq (car-safe val) 'error)
153 (error "Can't yank that line: %s" (nth 2 val))
156 (defun calc-trail-marker (str)
157 (interactive "sText to insert in trail: ")
158 (calc-with-trail-buffer
160 (let ((buffer-read-only nil))
161 (insert "---- " str "\n"))
165 (defun calc-trail-kill (n)
167 (calc-with-trail-buffer
168 (let ((buffer-read-only nil))
170 (narrow-to-region ; don't delete "Emacs Trail" header
172 (goto-char (point-min))
179 ;;; calc-trail.el ends here