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