1 ;;; calc-trail.el --- functions for manipulating the Calc "trail"
3 ;; Copyright (C) 1990, 1991, 1992, 1993, 2001, 2002, 2003, 2004,
4 ;; 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
6 ;; Author: David Gillespie <daveg@synaptics.com>
7 ;; Maintainer: Jay Belanger <jay.p.belanger@gmail.com>
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software: you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation, either version 3 of the License, or
14 ;; (at your option) any later version.
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
28 ;; This file is autoloaded from calc-ext.el.
35 (defun calc-trail-in ()
37 (let ((win (get-buffer-window (calc-trail-display t
))))
38 (and win
(select-window win
))))
40 (defun calc-trail-out ()
43 (let ((win (get-buffer-window (current-buffer))))
47 (calc-align-stack-window))
50 (defun calc-trail-next (n)
52 (calc-with-trail-buffer
56 (defun calc-trail-previous (n)
58 (calc-with-trail-buffer
62 (defun calc-trail-first (n)
64 (calc-with-trail-buffer
65 (goto-char (point-min))
69 (defun calc-trail-last (n)
71 (calc-with-trail-buffer
72 (goto-char (point-max))
76 (defun calc-trail-scroll-left (n)
78 (let ((curwin (selected-window)))
79 (calc-with-trail-buffer
82 (select-window (get-buffer-window (current-buffer)))
84 (select-window curwin
)))))
86 (defun calc-trail-scroll-right (n)
88 (let ((curwin (selected-window)))
89 (calc-with-trail-buffer
92 (select-window (get-buffer-window (current-buffer)))
93 (calc-scroll-right n
))
94 (select-window curwin
)))))
96 (defun calc-trail-forward (n)
98 (calc-with-trail-buffer
99 (forward-line (* n
(1- (window-height))))
102 (defun calc-trail-backward (n)
104 (calc-with-trail-buffer
105 (forward-line (- (* n
(1- (window-height)))))
108 (defun calc-trail-isearch-forward ()
110 (calc-with-trail-buffer
111 (save-window-excursion
112 (select-window (get-buffer-window (current-buffer)))
113 (let ((search-exit-char ?
\r))
117 (defun calc-trail-isearch-backward ()
119 (calc-with-trail-buffer
120 (save-window-excursion
121 (select-window (get-buffer-window (current-buffer)))
122 (let ((search-exit-char ?
\r))
126 (defun calc-trail-yank (arg)
129 (or arg
(calc-set-command-flag 'hold-trail
))
130 (calc-enter-result 0 "yank"
131 (calc-with-trail-buffer
133 (forward-line (- (prefix-numeric-value arg
))))
134 (if (or (looking-at "Emacs Calc")
136 (looking-at " ? ? ?[^ \n]* *$")
137 (looking-at "..?.?$"))
138 (error "Can't yank that line"))
139 (if (looking-at ".*, \\.\\.\\., ")
140 (error "Can't yank (vector was abbreviated)"))
143 (let* ((next (save-excursion (forward-line 1) (point)))
144 (str (buffer-substring (point) (1- next
)))
145 (val (with-current-buffer save-buf
146 (math-read-plain-expr str
))))
147 (if (eq (car-safe val
) 'error
)
148 (error "Can't yank that line: %s" (nth 2 val
))
151 (defun calc-trail-marker (str)
152 (interactive "sText to insert in trail: ")
153 (calc-with-trail-buffer
155 (let ((buffer-read-only nil
))
156 (insert "---- " str
"\n"))
160 (defun calc-trail-kill (n)
162 (calc-with-trail-buffer
163 (let ((buffer-read-only nil
))
165 (narrow-to-region ; don't delete "Emacs Trail" header
167 (goto-char (point-min))
174 (provide 'calc-trail
)
176 ;; arch-tag: 59b76655-d882-4aab-a3ee-b83870e530d0
177 ;;; calc-trail.el ends here