Mercurial > emacs
annotate lisp/calc/calc-trail.el @ 41267:e9718841a5b1
(math-fixnump, math-fixnatnump, calcFunc-trunc)
(calcFunc-floor): Ditto.
Change all toplevel `setq' forms to `defvar' forms, and move them
before their first use. Use `when', `unless'. Remove trailing
periods from error forms. Add description and headers suggested by
Emacs Lisp coding conventions.
author | Colin Walters <walters@gnu.org> |
---|---|
date | Mon, 19 Nov 2001 07:36:42 +0000 |
parents | 73f364fd8aaa |
children | fcd507927105 |
rev | line source |
---|---|
40785 | 1 ;; Calculator for GNU Emacs, part II [calc-trail.el] |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40785
diff
changeset
|
2 ;; Copyright (C) 1990, 1991, 1992, 1993, 2001 Free Software Foundation, Inc. |
40785 | 3 ;; Written by Dave Gillespie, daveg@synaptics.com. |
4 | |
5 ;; This file is part of GNU Emacs. | |
6 | |
7 ;; GNU Emacs is distributed in the hope that it will be useful, | |
8 ;; but WITHOUT ANY WARRANTY. No author or distributor | |
9 ;; accepts responsibility to anyone for the consequences of using it | |
10 ;; or for whether it serves any particular purpose or works at all, | |
11 ;; unless he says so in writing. Refer to the GNU Emacs General Public | |
12 ;; License for full details. | |
13 | |
14 ;; Everyone is granted permission to copy, modify and redistribute | |
15 ;; GNU Emacs, but only under the conditions described in the | |
16 ;; GNU Emacs General Public License. A copy of this license is | |
17 ;; supposed to have been given to you along with GNU Emacs so you | |
18 ;; can know your rights and responsibilities. It should be in a | |
19 ;; file named COPYING. Among other things, the copyright notice | |
20 ;; and this notice must be preserved on all copies. | |
21 | |
22 | |
23 | |
24 ;; This file is autoloaded from calc-ext.el. | |
25 (require 'calc-ext) | |
26 | |
27 (require 'calc-macs) | |
28 | |
29 (defun calc-Need-calc-trail () nil) | |
30 | |
31 | |
32 ;;; Trail commands. | |
33 | |
34 (defun calc-trail-in () | |
35 (interactive) | |
36 (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
|
37 (and win (select-window win)))) |
40785 | 38 |
39 (defun calc-trail-out () | |
40 (interactive) | |
41 (calc-select-buffer) | |
42 (let ((win (get-buffer-window (current-buffer)))) | |
43 (if win | |
44 (progn | |
45 (select-window win) | |
46 (calc-align-stack-window)) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40785
diff
changeset
|
47 (calc)))) |
40785 | 48 |
49 (defun calc-trail-next (n) | |
50 (interactive "p") | |
51 (calc-with-trail-buffer | |
52 (forward-line n) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40785
diff
changeset
|
53 (calc-trail-here))) |
40785 | 54 |
55 (defun calc-trail-previous (n) | |
56 (interactive "p") | |
57 (calc-with-trail-buffer | |
58 (forward-line (- n)) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40785
diff
changeset
|
59 (calc-trail-here))) |
40785 | 60 |
61 (defun calc-trail-first (n) | |
62 (interactive "p") | |
63 (calc-with-trail-buffer | |
64 (goto-char (point-min)) | |
65 (forward-line n) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40785
diff
changeset
|
66 (calc-trail-here))) |
40785 | 67 |
68 (defun calc-trail-last (n) | |
69 (interactive "p") | |
70 (calc-with-trail-buffer | |
71 (goto-char (point-max)) | |
72 (forward-line (- n)) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40785
diff
changeset
|
73 (calc-trail-here))) |
40785 | 74 |
75 (defun calc-trail-scroll-left (n) | |
76 (interactive "P") | |
77 (let ((curwin (selected-window))) | |
78 (calc-with-trail-buffer | |
79 (unwind-protect | |
80 (progn | |
81 (select-window (get-buffer-window (current-buffer))) | |
82 (calc-scroll-left n)) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40785
diff
changeset
|
83 (select-window curwin))))) |
40785 | 84 |
85 (defun calc-trail-scroll-right (n) | |
86 (interactive "P") | |
87 (let ((curwin (selected-window))) | |
88 (calc-with-trail-buffer | |
89 (unwind-protect | |
90 (progn | |
91 (select-window (get-buffer-window (current-buffer))) | |
92 (calc-scroll-right n)) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40785
diff
changeset
|
93 (select-window curwin))))) |
40785 | 94 |
95 (defun calc-trail-forward (n) | |
96 (interactive "p") | |
97 (calc-with-trail-buffer | |
98 (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
|
99 (calc-trail-here))) |
40785 | 100 |
101 (defun calc-trail-backward (n) | |
102 (interactive "p") | |
103 (calc-with-trail-buffer | |
104 (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
|
105 (calc-trail-here))) |
40785 | 106 |
107 (defun calc-trail-isearch-forward () | |
108 (interactive) | |
109 (calc-with-trail-buffer | |
110 (save-window-excursion | |
111 (select-window (get-buffer-window (current-buffer))) | |
112 (let ((search-exit-char ?\r)) | |
113 (isearch-forward))) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40785
diff
changeset
|
114 (calc-trail-here))) |
40785 | 115 |
116 (defun calc-trail-isearch-backward () | |
117 (interactive) | |
118 (calc-with-trail-buffer | |
119 (save-window-excursion | |
120 (select-window (get-buffer-window (current-buffer))) | |
121 (let ((search-exit-char ?\r)) | |
122 (isearch-backward))) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40785
diff
changeset
|
123 (calc-trail-here))) |
40785 | 124 |
125 (defun calc-trail-yank (arg) | |
126 (interactive "P") | |
127 (calc-wrapper | |
128 (or arg (calc-set-command-flag 'hold-trail)) | |
129 (calc-enter-result 0 "yank" | |
130 (calc-with-trail-buffer | |
131 (if arg | |
132 (forward-line (- (prefix-numeric-value arg)))) | |
133 (if (or (looking-at "Emacs Calc") | |
134 (looking-at "----") | |
135 (looking-at " ? ? ?[^ \n]* *$") | |
136 (looking-at "..?.?$")) | |
137 (error "Can't yank that line")) | |
138 (if (looking-at ".*, \\.\\.\\., ") | |
139 (error "Can't yank (vector was abbreviated)")) | |
140 (forward-char 4) | |
141 (search-forward " ") | |
142 (let* ((next (save-excursion (forward-line 1) (point))) | |
143 (str (buffer-substring (point) (1- next))) | |
144 (val (save-excursion | |
145 (set-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)) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40785
diff
changeset
|
149 val)))))) |
40785 | 150 |
151 (defun calc-trail-marker (str) | |
152 (interactive "sText to insert in trail: ") | |
153 (calc-with-trail-buffer | |
154 (forward-line 1) | |
155 (let ((buffer-read-only nil)) | |
156 (insert "---- " str "\n")) | |
157 (forward-line -1) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40785
diff
changeset
|
158 (calc-trail-here))) |
40785 | 159 |
160 (defun calc-trail-kill (n) | |
161 (interactive "p") | |
162 (calc-with-trail-buffer | |
163 (let ((buffer-read-only nil)) | |
164 (save-restriction | |
165 (narrow-to-region ; don't delete "Emacs Trail" header | |
166 (save-excursion | |
167 (goto-char (point-min)) | |
168 (forward-line 1) | |
169 (point)) | |
170 (point-max)) | |
171 (kill-line n))) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40785
diff
changeset
|
172 (calc-trail-here))) |
40785 | 173 |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40785
diff
changeset
|
174 ;;; calc-trail.el ends here |