(texinfo-insert-menu): specify previously free variable `level' in a
[bpt/emacs.git] / lisp / calc / calc-trail.el
CommitLineData
3132f345
CW
1;;; calc-trail.el --- functions for manipulating the Calc "trail"
2
bf77c646 3;; Copyright (C) 1990, 1991, 1992, 1993, 2001 Free Software Foundation, Inc.
3132f345
CW
4
5;; Author: David Gillespie <daveg@synaptics.com>
6;; Maintainer: Colin Walters <walters@debian.org>
136211a9
EZ
7
8;; This file is part of GNU Emacs.
9
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.
16
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.
24
3132f345 25;;; Commentary:
136211a9 26
3132f345 27;;; Code:
136211a9
EZ
28
29;; This file is autoloaded from calc-ext.el.
30(require 'calc-ext)
31
32(require 'calc-macs)
33
34(defun calc-Need-calc-trail () nil)
35
36
37;;; Trail commands.
38
39(defun calc-trail-in ()
40 (interactive)
41 (let ((win (get-buffer-window (calc-trail-display t))))
bf77c646 42 (and win (select-window win))))
136211a9
EZ
43
44(defun calc-trail-out ()
45 (interactive)
46 (calc-select-buffer)
47 (let ((win (get-buffer-window (current-buffer))))
48 (if win
49 (progn
50 (select-window win)
51 (calc-align-stack-window))
bf77c646 52 (calc))))
136211a9
EZ
53
54(defun calc-trail-next (n)
55 (interactive "p")
56 (calc-with-trail-buffer
57 (forward-line n)
bf77c646 58 (calc-trail-here)))
136211a9
EZ
59
60(defun calc-trail-previous (n)
61 (interactive "p")
62 (calc-with-trail-buffer
63 (forward-line (- n))
bf77c646 64 (calc-trail-here)))
136211a9
EZ
65
66(defun calc-trail-first (n)
67 (interactive "p")
68 (calc-with-trail-buffer
69 (goto-char (point-min))
70 (forward-line n)
bf77c646 71 (calc-trail-here)))
136211a9
EZ
72
73(defun calc-trail-last (n)
74 (interactive "p")
75 (calc-with-trail-buffer
76 (goto-char (point-max))
77 (forward-line (- n))
bf77c646 78 (calc-trail-here)))
136211a9
EZ
79
80(defun calc-trail-scroll-left (n)
81 (interactive "P")
82 (let ((curwin (selected-window)))
83 (calc-with-trail-buffer
84 (unwind-protect
85 (progn
86 (select-window (get-buffer-window (current-buffer)))
87 (calc-scroll-left n))
bf77c646 88 (select-window curwin)))))
136211a9
EZ
89
90(defun calc-trail-scroll-right (n)
91 (interactive "P")
92 (let ((curwin (selected-window)))
93 (calc-with-trail-buffer
94 (unwind-protect
95 (progn
96 (select-window (get-buffer-window (current-buffer)))
97 (calc-scroll-right n))
bf77c646 98 (select-window curwin)))))
136211a9
EZ
99
100(defun calc-trail-forward (n)
101 (interactive "p")
102 (calc-with-trail-buffer
103 (forward-line (* n (1- (window-height))))
bf77c646 104 (calc-trail-here)))
136211a9
EZ
105
106(defun calc-trail-backward (n)
107 (interactive "p")
108 (calc-with-trail-buffer
109 (forward-line (- (* n (1- (window-height)))))
bf77c646 110 (calc-trail-here)))
136211a9
EZ
111
112(defun calc-trail-isearch-forward ()
113 (interactive)
114 (calc-with-trail-buffer
115 (save-window-excursion
116 (select-window (get-buffer-window (current-buffer)))
117 (let ((search-exit-char ?\r))
118 (isearch-forward)))
bf77c646 119 (calc-trail-here)))
136211a9
EZ
120
121(defun calc-trail-isearch-backward ()
122 (interactive)
123 (calc-with-trail-buffer
124 (save-window-excursion
125 (select-window (get-buffer-window (current-buffer)))
126 (let ((search-exit-char ?\r))
127 (isearch-backward)))
bf77c646 128 (calc-trail-here)))
136211a9
EZ
129
130(defun calc-trail-yank (arg)
131 (interactive "P")
132 (calc-wrapper
133 (or arg (calc-set-command-flag 'hold-trail))
134 (calc-enter-result 0 "yank"
135 (calc-with-trail-buffer
136 (if arg
137 (forward-line (- (prefix-numeric-value arg))))
138 (if (or (looking-at "Emacs Calc")
139 (looking-at "----")
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)"))
145 (forward-char 4)
146 (search-forward " ")
147 (let* ((next (save-excursion (forward-line 1) (point)))
148 (str (buffer-substring (point) (1- next)))
149 (val (save-excursion
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))
bf77c646 154 val))))))
136211a9
EZ
155
156(defun calc-trail-marker (str)
157 (interactive "sText to insert in trail: ")
158 (calc-with-trail-buffer
159 (forward-line 1)
160 (let ((buffer-read-only nil))
161 (insert "---- " str "\n"))
162 (forward-line -1)
bf77c646 163 (calc-trail-here)))
136211a9
EZ
164
165(defun calc-trail-kill (n)
166 (interactive "p")
167 (calc-with-trail-buffer
168 (let ((buffer-read-only nil))
169 (save-restriction
170 (narrow-to-region ; don't delete "Emacs Trail" header
171 (save-excursion
172 (goto-char (point-min))
173 (forward-line 1)
174 (point))
175 (point-max))
176 (kill-line n)))
bf77c646 177 (calc-trail-here)))
136211a9 178
bf77c646 179;;; calc-trail.el ends here