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