Mercurial > emacs
annotate lisp/calc/calc-trail.el @ 112411:6178cf733e6f
Merge from mainline.
author | Paul Eggert <eggert@cs.ucla.edu> |
---|---|
date | Fri, 21 Jan 2011 21:52:29 -0800 |
parents | ef719132ddfa |
children |
rev | line source |
---|---|
41271
fcd507927105
Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
1 ;;; calc-trail.el --- functions for manipulating the Calc "trail" |
fcd507927105
Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
2 |
64325
1db49616ce05
Update copyright information.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
62442
diff
changeset
|
3 ;; Copyright (C) 1990, 1991, 1992, 1993, 2001, 2002, 2003, 2004, |
112218
376148b31b5e
Add 2011 to FSF/AIST copyright years.
Glenn Morris <rgm@gnu.org>
parents:
106815
diff
changeset
|
4 ;; 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. |
41271
fcd507927105
Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
5 |
fcd507927105
Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
6 ;; Author: David Gillespie <daveg@synaptics.com> |
77465
1154f082efd9
Update maintainer's address.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
76595
diff
changeset
|
7 ;; Maintainer: Jay Belanger <jay.p.belanger@gmail.com> |
40785 | 8 |
9 ;; This file is part of GNU Emacs. | |
10 | |
94654
6c9af2bfcfee
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
11 ;; GNU Emacs is free software: you can redistribute it and/or modify |
76595
497d17a80bb8
Change form of license text to match rest of Emacs.
Glenn Morris <rgm@gnu.org>
parents:
75346
diff
changeset
|
12 ;; it under the terms of the GNU General Public License as published by |
94654
6c9af2bfcfee
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
13 ;; the Free Software Foundation, either version 3 of the License, or |
6c9af2bfcfee
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
14 ;; (at your option) any later version. |
40785 | 15 |
76595
497d17a80bb8
Change form of license text to match rest of Emacs.
Glenn Morris <rgm@gnu.org>
parents:
75346
diff
changeset
|
16 ;; GNU Emacs is distributed in the hope that it will be useful, |
497d17a80bb8
Change form of license text to match rest of Emacs.
Glenn Morris <rgm@gnu.org>
parents:
75346
diff
changeset
|
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
497d17a80bb8
Change form of license text to match rest of Emacs.
Glenn Morris <rgm@gnu.org>
parents:
75346
diff
changeset
|
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
497d17a80bb8
Change form of license text to match rest of Emacs.
Glenn Morris <rgm@gnu.org>
parents:
75346
diff
changeset
|
19 ;; GNU General Public License for more details. |
497d17a80bb8
Change form of license text to match rest of Emacs.
Glenn Morris <rgm@gnu.org>
parents:
75346
diff
changeset
|
20 |
497d17a80bb8
Change form of license text to match rest of Emacs.
Glenn Morris <rgm@gnu.org>
parents:
75346
diff
changeset
|
21 ;; You should have received a copy of the GNU General Public License |
94654
6c9af2bfcfee
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
40785 | 23 |
41271
fcd507927105
Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
24 ;;; Commentary: |
40785 | 25 |
41271
fcd507927105
Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
26 ;;; Code: |
40785 | 27 |
28 ;; This file is autoloaded from calc-ext.el. | |
58675
0f204f1642ec
Add a provide statement.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
52401
diff
changeset
|
29 |
40785 | 30 (require 'calc-ext) |
31 (require 'calc-macs) | |
32 | |
33 ;;; Trail commands. | |
34 | |
35 (defun calc-trail-in () | |
36 (interactive) | |
37 (let ((win (get-buffer-window (calc-trail-display t)))) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40785
diff
changeset
|
38 (and win (select-window win)))) |
40785 | 39 |
40 (defun calc-trail-out () | |
41 (interactive) | |
42 (calc-select-buffer) | |
43 (let ((win (get-buffer-window (current-buffer)))) | |
44 (if win | |
45 (progn | |
46 (select-window win) | |
47 (calc-align-stack-window)) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40785
diff
changeset
|
48 (calc)))) |
40785 | 49 |
50 (defun calc-trail-next (n) | |
51 (interactive "p") | |
52 (calc-with-trail-buffer | |
53 (forward-line n) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40785
diff
changeset
|
54 (calc-trail-here))) |
40785 | 55 |
56 (defun calc-trail-previous (n) | |
57 (interactive "p") | |
58 (calc-with-trail-buffer | |
59 (forward-line (- n)) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40785
diff
changeset
|
60 (calc-trail-here))) |
40785 | 61 |
62 (defun calc-trail-first (n) | |
63 (interactive "p") | |
64 (calc-with-trail-buffer | |
65 (goto-char (point-min)) | |
66 (forward-line n) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40785
diff
changeset
|
67 (calc-trail-here))) |
40785 | 68 |
69 (defun calc-trail-last (n) | |
70 (interactive "p") | |
71 (calc-with-trail-buffer | |
72 (goto-char (point-max)) | |
73 (forward-line (- n)) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40785
diff
changeset
|
74 (calc-trail-here))) |
40785 | 75 |
76 (defun calc-trail-scroll-left (n) | |
77 (interactive "P") | |
78 (let ((curwin (selected-window))) | |
79 (calc-with-trail-buffer | |
80 (unwind-protect | |
81 (progn | |
82 (select-window (get-buffer-window (current-buffer))) | |
83 (calc-scroll-left n)) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40785
diff
changeset
|
84 (select-window curwin))))) |
40785 | 85 |
86 (defun calc-trail-scroll-right (n) | |
87 (interactive "P") | |
88 (let ((curwin (selected-window))) | |
89 (calc-with-trail-buffer | |
90 (unwind-protect | |
91 (progn | |
92 (select-window (get-buffer-window (current-buffer))) | |
93 (calc-scroll-right n)) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40785
diff
changeset
|
94 (select-window curwin))))) |
40785 | 95 |
96 (defun calc-trail-forward (n) | |
97 (interactive "p") | |
98 (calc-with-trail-buffer | |
99 (forward-line (* n (1- (window-height)))) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40785
diff
changeset
|
100 (calc-trail-here))) |
40785 | 101 |
102 (defun calc-trail-backward (n) | |
103 (interactive "p") | |
104 (calc-with-trail-buffer | |
105 (forward-line (- (* n (1- (window-height))))) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40785
diff
changeset
|
106 (calc-trail-here))) |
40785 | 107 |
108 (defun calc-trail-isearch-forward () | |
109 (interactive) | |
110 (calc-with-trail-buffer | |
108660
1e3c6cb46d2a
calc-trail.el (calc-trail-isearch-forward)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
106815
diff
changeset
|
111 (let ((win (get-buffer-window (current-buffer))) |
1e3c6cb46d2a
calc-trail.el (calc-trail-isearch-forward)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
106815
diff
changeset
|
112 pos) |
1e3c6cb46d2a
calc-trail.el (calc-trail-isearch-forward)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
106815
diff
changeset
|
113 (save-window-excursion |
1e3c6cb46d2a
calc-trail.el (calc-trail-isearch-forward)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
106815
diff
changeset
|
114 (select-window win) |
1e3c6cb46d2a
calc-trail.el (calc-trail-isearch-forward)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
106815
diff
changeset
|
115 (isearch-forward) |
1e3c6cb46d2a
calc-trail.el (calc-trail-isearch-forward)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
106815
diff
changeset
|
116 (setq pos (point))) |
1e3c6cb46d2a
calc-trail.el (calc-trail-isearch-forward)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
106815
diff
changeset
|
117 (goto-char pos) |
1e3c6cb46d2a
calc-trail.el (calc-trail-isearch-forward)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
106815
diff
changeset
|
118 (set-window-point win pos) |
1e3c6cb46d2a
calc-trail.el (calc-trail-isearch-forward)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
106815
diff
changeset
|
119 (calc-trail-here)))) |
40785 | 120 |
121 (defun calc-trail-isearch-backward () | |
122 (interactive) | |
123 (calc-with-trail-buffer | |
108660
1e3c6cb46d2a
calc-trail.el (calc-trail-isearch-forward)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
106815
diff
changeset
|
124 (let ((win (get-buffer-window (current-buffer))) |
1e3c6cb46d2a
calc-trail.el (calc-trail-isearch-forward)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
106815
diff
changeset
|
125 pos) |
1e3c6cb46d2a
calc-trail.el (calc-trail-isearch-forward)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
106815
diff
changeset
|
126 (save-window-excursion |
1e3c6cb46d2a
calc-trail.el (calc-trail-isearch-forward)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
106815
diff
changeset
|
127 (select-window win) |
1e3c6cb46d2a
calc-trail.el (calc-trail-isearch-forward)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
106815
diff
changeset
|
128 (isearch-backward) |
1e3c6cb46d2a
calc-trail.el (calc-trail-isearch-forward)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
106815
diff
changeset
|
129 (setq pos (point))) |
1e3c6cb46d2a
calc-trail.el (calc-trail-isearch-forward)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
106815
diff
changeset
|
130 (goto-char pos) |
1e3c6cb46d2a
calc-trail.el (calc-trail-isearch-forward)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
106815
diff
changeset
|
131 (set-window-point win pos) |
1e3c6cb46d2a
calc-trail.el (calc-trail-isearch-forward)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
106815
diff
changeset
|
132 (calc-trail-here)))) |
40785 | 133 |
134 (defun calc-trail-yank (arg) | |
135 (interactive "P") | |
136 (calc-wrapper | |
137 (or arg (calc-set-command-flag 'hold-trail)) | |
138 (calc-enter-result 0 "yank" | |
139 (calc-with-trail-buffer | |
140 (if arg | |
141 (forward-line (- (prefix-numeric-value arg)))) | |
142 (if (or (looking-at "Emacs Calc") | |
143 (looking-at "----") | |
144 (looking-at " ? ? ?[^ \n]* *$") | |
145 (looking-at "..?.?$")) | |
146 (error "Can't yank that line")) | |
147 (if (looking-at ".*, \\.\\.\\., ") | |
148 (error "Can't yank (vector was abbreviated)")) | |
149 (forward-char 4) | |
150 (search-forward " ") | |
151 (let* ((next (save-excursion (forward-line 1) (point))) | |
152 (str (buffer-substring (point) (1- next))) | |
105792
2c12fbae77c2
* calc/calc.el (calc, calc-refresh, calc-trail-buffer, calc-record)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
100908
diff
changeset
|
153 (val (with-current-buffer save-buf |
40785 | 154 (math-read-plain-expr str)))) |
155 (if (eq (car-safe val) 'error) | |
156 (error "Can't yank that line: %s" (nth 2 val)) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40785
diff
changeset
|
157 val)))))) |
40785 | 158 |
159 (defun calc-trail-marker (str) | |
160 (interactive "sText to insert in trail: ") | |
161 (calc-with-trail-buffer | |
162 (forward-line 1) | |
163 (let ((buffer-read-only nil)) | |
164 (insert "---- " str "\n")) | |
165 (forward-line -1) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40785
diff
changeset
|
166 (calc-trail-here))) |
40785 | 167 |
168 (defun calc-trail-kill (n) | |
169 (interactive "p") | |
170 (calc-with-trail-buffer | |
171 (let ((buffer-read-only nil)) | |
172 (save-restriction | |
173 (narrow-to-region ; don't delete "Emacs Trail" header | |
174 (save-excursion | |
175 (goto-char (point-min)) | |
176 (forward-line 1) | |
177 (point)) | |
178 (point-max)) | |
179 (kill-line n))) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40785
diff
changeset
|
180 (calc-trail-here))) |
40785 | 181 |
58675
0f204f1642ec
Add a provide statement.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
52401
diff
changeset
|
182 (provide 'calc-trail) |
0f204f1642ec
Add a provide statement.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
52401
diff
changeset
|
183 |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40785
diff
changeset
|
184 ;;; calc-trail.el ends here |