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: Jay Belanger <belanger@truman.edu>
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.
36 (defun calc-trail-in ()
38 (let ((win (get-buffer-window (calc-trail-display t))))
39 (and win (select-window win))))
41 (defun calc-trail-out ()
44 (let ((win (get-buffer-window (current-buffer))))
48 (calc-align-stack-window))
51 (defun calc-trail-next (n)
53 (calc-with-trail-buffer
57 (defun calc-trail-previous (n)
59 (calc-with-trail-buffer
63 (defun calc-trail-first (n)
65 (calc-with-trail-buffer
66 (goto-char (point-min))
70 (defun calc-trail-last (n)
72 (calc-with-trail-buffer
73 (goto-char (point-max))
77 (defun calc-trail-scroll-left (n)
79 (let ((curwin (selected-window)))
80 (calc-with-trail-buffer
83 (select-window (get-buffer-window (current-buffer)))
85 (select-window curwin)))))
87 (defun calc-trail-scroll-right (n)
89 (let ((curwin (selected-window)))
90 (calc-with-trail-buffer
93 (select-window (get-buffer-window (current-buffer)))
94 (calc-scroll-right n))
95 (select-window curwin)))))
97 (defun calc-trail-forward (n)
99 (calc-with-trail-buffer
100 (forward-line (* n (1- (window-height))))
103 (defun calc-trail-backward (n)
105 (calc-with-trail-buffer
106 (forward-line (- (* n (1- (window-height)))))
109 (defun calc-trail-isearch-forward ()
111 (calc-with-trail-buffer
112 (save-window-excursion
113 (select-window (get-buffer-window (current-buffer)))
114 (let ((search-exit-char ?\r))
118 (defun calc-trail-isearch-backward ()
120 (calc-with-trail-buffer
121 (save-window-excursion
122 (select-window (get-buffer-window (current-buffer)))
123 (let ((search-exit-char ?\r))
127 (defun calc-trail-yank (arg)
130 (or arg (calc-set-command-flag 'hold-trail))
131 (calc-enter-result 0 "yank"
132 (calc-with-trail-buffer
134 (forward-line (- (prefix-numeric-value arg))))
135 (if (or (looking-at "Emacs Calc")
137 (looking-at " ? ? ?[^ \n]* *$")
138 (looking-at "..?.?$"))
139 (error "Can't yank that line"))
140 (if (looking-at ".*, \\.\\.\\., ")
141 (error "Can't yank (vector was abbreviated)"))
144 (let* ((next (save-excursion (forward-line 1) (point)))
145 (str (buffer-substring (point) (1- next)))
147 (set-buffer save-buf)
148 (math-read-plain-expr str))))
149 (if (eq (car-safe val) 'error)
150 (error "Can't yank that line: %s" (nth 2 val))
153 (defun calc-trail-marker (str)
154 (interactive "sText to insert in trail: ")
155 (calc-with-trail-buffer
157 (let ((buffer-read-only nil))
158 (insert "---- " str "\n"))
162 (defun calc-trail-kill (n)
164 (calc-with-trail-buffer
165 (let ((buffer-read-only nil))
167 (narrow-to-region ; don't delete "Emacs Trail" header
169 (goto-char (point-min))
176 (provide 'calc-trail)
178 ;;; arch-tag: 59b76655-d882-4aab-a3ee-b83870e530d0
179 ;;; calc-trail.el ends here