(Fcall_interactively): Doc fix.
[emacs.git] / lisp / calc / calc-trail.el
blobcee2b4fc4618fd7e229e262b328bffa0652fbca9
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 ;; Maintainers: D. Goel <deego@gnufans.org>
7 ;; Colin Walters <walters@debian.org>
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.
26 ;;; Commentary:
28 ;;; Code:
30 ;; This file is autoloaded from calc-ext.el.
31 (require 'calc-ext)
33 (require 'calc-macs)
35 (defun calc-Need-calc-trail () nil)
38 ;;; Trail commands.
40 (defun calc-trail-in ()
41 (interactive)
42 (let ((win (get-buffer-window (calc-trail-display t))))
43 (and win (select-window win))))
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))
53 (calc))))
55 (defun calc-trail-next (n)
56 (interactive "p")
57 (calc-with-trail-buffer
58 (forward-line n)
59 (calc-trail-here)))
61 (defun calc-trail-previous (n)
62 (interactive "p")
63 (calc-with-trail-buffer
64 (forward-line (- n))
65 (calc-trail-here)))
67 (defun calc-trail-first (n)
68 (interactive "p")
69 (calc-with-trail-buffer
70 (goto-char (point-min))
71 (forward-line n)
72 (calc-trail-here)))
74 (defun calc-trail-last (n)
75 (interactive "p")
76 (calc-with-trail-buffer
77 (goto-char (point-max))
78 (forward-line (- n))
79 (calc-trail-here)))
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))
89 (select-window curwin)))))
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))
99 (select-window curwin)))))
101 (defun calc-trail-forward (n)
102 (interactive "p")
103 (calc-with-trail-buffer
104 (forward-line (* n (1- (window-height))))
105 (calc-trail-here)))
107 (defun calc-trail-backward (n)
108 (interactive "p")
109 (calc-with-trail-buffer
110 (forward-line (- (* n (1- (window-height)))))
111 (calc-trail-here)))
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)))
120 (calc-trail-here)))
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)))
129 (calc-trail-here)))
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))
155 val))))))
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)
164 (calc-trail-here)))
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)))
178 (calc-trail-here)))
180 ;;; arch-tag: 59b76655-d882-4aab-a3ee-b83870e530d0
181 ;;; calc-trail.el ends here