1 ;;; calc-trail.el --- functions for manipulating the Calc "trail"
3 ;; Copyright (C) 1990-1993, 2001-2015 Free Software Foundation, Inc.
5 ;; Author: David Gillespie <daveg@synaptics.com>
6 ;; Maintainer: Jay Belanger <jay.p.belanger@gmail.com>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software: you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation, either version 3 of the License, or
13 ;; (at your option) any later version.
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
27 ;; This file is autoloaded from calc-ext.el.
34 (defun calc-trail-in ()
36 (let ((win (get-buffer-window (calc-trail-display t
))))
37 (and win
(select-window win
))))
39 (defun calc-trail-out ()
42 (let ((win (get-buffer-window (current-buffer))))
46 (calc-align-stack-window))
49 (defun calc-trail-next (n)
51 (calc-with-trail-buffer
55 (defun calc-trail-previous (n)
57 (calc-with-trail-buffer
61 (defun calc-trail-first (n)
63 (calc-with-trail-buffer
64 (goto-char (point-min))
68 (defun calc-trail-last (n)
70 (calc-with-trail-buffer
71 (goto-char (point-max))
75 (defun calc-trail-scroll-left (n)
77 (let ((curwin (selected-window)))
78 (calc-with-trail-buffer
81 (select-window (get-buffer-window (current-buffer)))
83 (select-window curwin
)))))
85 (defun calc-trail-scroll-right (n)
87 (let ((curwin (selected-window)))
88 (calc-with-trail-buffer
91 (select-window (get-buffer-window (current-buffer)))
92 (calc-scroll-right n
))
93 (select-window curwin
)))))
95 (defun calc-trail-forward (n)
97 (calc-with-trail-buffer
98 (forward-line (* n
(1- (window-height))))
101 (defun calc-trail-backward (n)
103 (calc-with-trail-buffer
104 (forward-line (- (* n
(1- (window-height)))))
107 (defun calc-trail-isearch-forward ()
109 (calc-with-trail-buffer
110 (let ((win (get-buffer-window (current-buffer)))
112 (save-window-excursion
117 (set-window-point win pos
)
120 (defun calc-trail-isearch-backward ()
122 (calc-with-trail-buffer
123 (let ((win (get-buffer-window (current-buffer)))
125 (save-window-excursion
130 (set-window-point win pos
)
133 (defun calc-trail-yank (arg)
136 (or arg
(calc-set-command-flag 'hold-trail
))
137 (calc-enter-result 0 "yank"
138 (calc-with-trail-buffer
140 (forward-line (- (prefix-numeric-value arg
))))
141 (if (or (looking-at "Emacs Calc")
143 (looking-at " ? ? ?[^ \n]* *$")
144 (looking-at "..?.?$"))
145 (error "Can't yank that line"))
146 (if (looking-at ".*, \\.\\.\\., ")
147 (error "Can't yank (vector was abbreviated)"))
150 (let* ((next (save-excursion (forward-line 1) (point)))
151 (str (buffer-substring (point) (1- next
)))
152 (val (with-current-buffer save-buf
153 (math-read-plain-expr str
))))
154 (if (eq (car-safe val
) 'error
)
155 (error "Can't yank that line: %s" (nth 2 val
))
158 (defun calc-trail-marker (str)
159 (interactive "sText to insert in trail: ")
160 (calc-with-trail-buffer
162 (let ((buffer-read-only nil
))
163 (insert "---- " str
"\n"))
167 (defun calc-trail-kill (n)
169 (calc-with-trail-buffer
170 (let ((buffer-read-only nil
))
172 (narrow-to-region ; don't delete "Emacs Trail" header
174 (goto-char (point-min))
181 (provide 'calc-trail
)
183 ;;; calc-trail.el ends here