1 ;;; calc-trail.el --- functions for manipulating the Calc "trail"
3 ;; Copyright (C) 1990, 1991, 1992, 1993, 2001, 2002, 2003, 2004,
4 ;; 2005, 2006 Free Software Foundation, Inc.
6 ;; Author: David Gillespie <daveg@synaptics.com>
7 ;; Maintainer: Jay Belanger <belanger@truman.edu>
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.
37 (defun calc-trail-in ()
39 (let ((win (get-buffer-window (calc-trail-display t
))))
40 (and win
(select-window win
))))
42 (defun calc-trail-out ()
45 (let ((win (get-buffer-window (current-buffer))))
49 (calc-align-stack-window))
52 (defun calc-trail-next (n)
54 (calc-with-trail-buffer
58 (defun calc-trail-previous (n)
60 (calc-with-trail-buffer
64 (defun calc-trail-first (n)
66 (calc-with-trail-buffer
67 (goto-char (point-min))
71 (defun calc-trail-last (n)
73 (calc-with-trail-buffer
74 (goto-char (point-max))
78 (defun calc-trail-scroll-left (n)
80 (let ((curwin (selected-window)))
81 (calc-with-trail-buffer
84 (select-window (get-buffer-window (current-buffer)))
86 (select-window curwin
)))))
88 (defun calc-trail-scroll-right (n)
90 (let ((curwin (selected-window)))
91 (calc-with-trail-buffer
94 (select-window (get-buffer-window (current-buffer)))
95 (calc-scroll-right n
))
96 (select-window curwin
)))))
98 (defun calc-trail-forward (n)
100 (calc-with-trail-buffer
101 (forward-line (* n
(1- (window-height))))
104 (defun calc-trail-backward (n)
106 (calc-with-trail-buffer
107 (forward-line (- (* n
(1- (window-height)))))
110 (defun calc-trail-isearch-forward ()
112 (calc-with-trail-buffer
113 (save-window-excursion
114 (select-window (get-buffer-window (current-buffer)))
115 (let ((search-exit-char ?
\r))
119 (defun calc-trail-isearch-backward ()
121 (calc-with-trail-buffer
122 (save-window-excursion
123 (select-window (get-buffer-window (current-buffer)))
124 (let ((search-exit-char ?
\r))
128 (defun calc-trail-yank (arg)
131 (or arg
(calc-set-command-flag 'hold-trail
))
132 (calc-enter-result 0 "yank"
133 (calc-with-trail-buffer
135 (forward-line (- (prefix-numeric-value arg
))))
136 (if (or (looking-at "Emacs Calc")
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)"))
145 (let* ((next (save-excursion (forward-line 1) (point)))
146 (str (buffer-substring (point) (1- next
)))
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
))
154 (defun calc-trail-marker (str)
155 (interactive "sText to insert in trail: ")
156 (calc-with-trail-buffer
158 (let ((buffer-read-only nil
))
159 (insert "---- " str
"\n"))
163 (defun calc-trail-kill (n)
165 (calc-with-trail-buffer
166 (let ((buffer-read-only nil
))
168 (narrow-to-region ; don't delete "Emacs Trail" header
170 (goto-char (point-min))
177 (provide 'calc-trail
)
179 ;;; arch-tag: 59b76655-d882-4aab-a3ee-b83870e530d0
180 ;;; calc-trail.el ends here