1 ;;; calc-trail.el --- functions for manipulating the Calc "trail"
3 ;; Copyright (C) 1990-1993, 2001-2016 Free Software Foundation, Inc.
5 ;; Author: David Gillespie <daveg@synaptics.com>
7 ;; This file is part of GNU Emacs.
9 ;; GNU Emacs is free software: you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation, either version 3 of the License, or
12 ;; (at your option) any later version.
14 ;; GNU Emacs is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;; GNU General Public License for more details.
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
26 ;; This file is autoloaded from calc-ext.el.
33 (defun calc-trail-in ()
35 (let ((win (get-buffer-window (calc-trail-display t))))
36 (and win (select-window win))))
38 (defun calc-trail-out ()
41 (let ((win (get-buffer-window (current-buffer))))
45 (calc-align-stack-window))
48 (defun calc-trail-next (n)
50 (calc-with-trail-buffer
54 (defun calc-trail-previous (n)
56 (calc-with-trail-buffer
60 (defun calc-trail-first (n)
62 (calc-with-trail-buffer
63 (goto-char (point-min))
67 (defun calc-trail-last (n)
69 (calc-with-trail-buffer
70 (goto-char (point-max))
74 (defun calc-trail-scroll-left (n)
76 (let ((curwin (selected-window)))
77 (calc-with-trail-buffer
80 (select-window (get-buffer-window (current-buffer)))
82 (select-window curwin)))))
84 (defun calc-trail-scroll-right (n)
86 (let ((curwin (selected-window)))
87 (calc-with-trail-buffer
90 (select-window (get-buffer-window (current-buffer)))
91 (calc-scroll-right n))
92 (select-window curwin)))))
94 (defun calc-trail-forward (n)
96 (calc-with-trail-buffer
97 (forward-line (* n (1- (window-height))))
100 (defun calc-trail-backward (n)
102 (calc-with-trail-buffer
103 (forward-line (- (* n (1- (window-height)))))
106 (defun calc-trail-isearch-forward ()
108 (calc-with-trail-buffer
109 (let ((win (get-buffer-window (current-buffer)))
111 (save-window-excursion
116 (set-window-point win pos)
119 (defun calc-trail-isearch-backward ()
121 (calc-with-trail-buffer
122 (let ((win (get-buffer-window (current-buffer)))
124 (save-window-excursion
129 (set-window-point win pos)
132 (defun calc-trail-yank (arg)
135 (or arg (calc-set-command-flag 'hold-trail))
136 (calc-enter-result 0 "yank"
137 (calc-with-trail-buffer
139 (forward-line (- (prefix-numeric-value arg))))
140 (if (or (looking-at "Emacs Calc")
142 (looking-at " ? ? ?[^ \n]* *$")
143 (looking-at "..?.?$"))
144 (error "Can't yank that line"))
145 (if (looking-at ".*, \\.\\.\\., ")
146 (error "Can't yank (vector was abbreviated)"))
149 (let* ((next (save-excursion (forward-line 1) (point)))
150 (str (buffer-substring (point) (1- next)))
151 (val (with-current-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))
157 (defun calc-trail-marker (str)
158 (interactive "sText to insert in trail: ")
159 (calc-with-trail-buffer
161 (let ((buffer-read-only nil))
162 (insert "---- " str "\n"))
166 (defun calc-trail-kill (n)
168 (calc-with-trail-buffer
169 (let ((buffer-read-only nil))
171 (narrow-to-region ; don't delete "Emacs Trail" header
173 (goto-char (point-min))
180 (provide 'calc-trail)
182 ;;; calc-trail.el ends here