Mercurial > emacs
annotate lisp/calc/calc-trail.el @ 80717:9a64a4d7dbe6
*** empty log message ***
author | Glenn Morris <rgm@gnu.org> |
---|---|
date | Sun, 10 Aug 2008 20:29:42 +0000 |
parents | 9754bb0422ed |
children | 606f2d163a64 1e3a407766b9 |
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, |
79702 | 4 ;; 2005, 2006, 2007, 2008 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 | |
76595
497d17a80bb8
Change form of license text to match rest of Emacs.
Glenn Morris <rgm@gnu.org>
parents:
75346
diff
changeset
|
11 ;; GNU Emacs is free software; you can redistribute it and/or modify |
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 |
78215
095d08e7d6bb
Switch license to GPLv3 or later.
Glenn Morris <rgm@gnu.org>
parents:
77465
diff
changeset
|
13 ;; the Free Software Foundation; either version 3, or (at your option) |
76595
497d17a80bb8
Change form of license text to match rest of Emacs.
Glenn Morris <rgm@gnu.org>
parents:
75346
diff
changeset
|
14 ;; 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 |
497d17a80bb8
Change form of license text to match rest of Emacs.
Glenn Morris <rgm@gnu.org>
parents:
75346
diff
changeset
|
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
497d17a80bb8
Change form of license text to match rest of Emacs.
Glenn Morris <rgm@gnu.org>
parents:
75346
diff
changeset
|
23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
497d17a80bb8
Change form of license text to match rest of Emacs.
Glenn Morris <rgm@gnu.org>
parents:
75346
diff
changeset
|
24 ;; Boston, MA 02110-1301, USA. |
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 ;;; Commentary: |
40785 | 27 |
41271
fcd507927105
Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
28 ;;; Code: |
40785 | 29 |
30 ;; 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
|
31 |
40785 | 32 (require 'calc-ext) |
33 (require 'calc-macs) | |
34 | |
35 ;;; Trail commands. | |
36 | |
37 (defun calc-trail-in () | |
38 (interactive) | |
39 (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
|
40 (and win (select-window win)))) |
40785 | 41 |
42 (defun calc-trail-out () | |
43 (interactive) | |
44 (calc-select-buffer) | |
45 (let ((win (get-buffer-window (current-buffer)))) | |
46 (if win | |
47 (progn | |
48 (select-window win) | |
49 (calc-align-stack-window)) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40785
diff
changeset
|
50 (calc)))) |
40785 | 51 |
52 (defun calc-trail-next (n) | |
53 (interactive "p") | |
54 (calc-with-trail-buffer | |
55 (forward-line n) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40785
diff
changeset
|
56 (calc-trail-here))) |
40785 | 57 |
58 (defun calc-trail-previous (n) | |
59 (interactive "p") | |
60 (calc-with-trail-buffer | |
61 (forward-line (- n)) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40785
diff
changeset
|
62 (calc-trail-here))) |
40785 | 63 |
64 (defun calc-trail-first (n) | |
65 (interactive "p") | |
66 (calc-with-trail-buffer | |
67 (goto-char (point-min)) | |
68 (forward-line n) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40785
diff
changeset
|
69 (calc-trail-here))) |
40785 | 70 |
71 (defun calc-trail-last (n) | |
72 (interactive "p") | |
73 (calc-with-trail-buffer | |
74 (goto-char (point-max)) | |
75 (forward-line (- n)) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40785
diff
changeset
|
76 (calc-trail-here))) |
40785 | 77 |
78 (defun calc-trail-scroll-left (n) | |
79 (interactive "P") | |
80 (let ((curwin (selected-window))) | |
81 (calc-with-trail-buffer | |
82 (unwind-protect | |
83 (progn | |
84 (select-window (get-buffer-window (current-buffer))) | |
85 (calc-scroll-left n)) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40785
diff
changeset
|
86 (select-window curwin))))) |
40785 | 87 |
88 (defun calc-trail-scroll-right (n) | |
89 (interactive "P") | |
90 (let ((curwin (selected-window))) | |
91 (calc-with-trail-buffer | |
92 (unwind-protect | |
93 (progn | |
94 (select-window (get-buffer-window (current-buffer))) | |
95 (calc-scroll-right n)) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40785
diff
changeset
|
96 (select-window curwin))))) |
40785 | 97 |
98 (defun calc-trail-forward (n) | |
99 (interactive "p") | |
100 (calc-with-trail-buffer | |
101 (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
|
102 (calc-trail-here))) |
40785 | 103 |
104 (defun calc-trail-backward (n) | |
105 (interactive "p") | |
106 (calc-with-trail-buffer | |
107 (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
|
108 (calc-trail-here))) |
40785 | 109 |
110 (defun calc-trail-isearch-forward () | |
111 (interactive) | |
112 (calc-with-trail-buffer | |
113 (save-window-excursion | |
114 (select-window (get-buffer-window (current-buffer))) | |
115 (let ((search-exit-char ?\r)) | |
116 (isearch-forward))) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40785
diff
changeset
|
117 (calc-trail-here))) |
40785 | 118 |
119 (defun calc-trail-isearch-backward () | |
120 (interactive) | |
121 (calc-with-trail-buffer | |
122 (save-window-excursion | |
123 (select-window (get-buffer-window (current-buffer))) | |
124 (let ((search-exit-char ?\r)) | |
125 (isearch-backward))) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40785
diff
changeset
|
126 (calc-trail-here))) |
40785 | 127 |
128 (defun calc-trail-yank (arg) | |
129 (interactive "P") | |
130 (calc-wrapper | |
131 (or arg (calc-set-command-flag 'hold-trail)) | |
132 (calc-enter-result 0 "yank" | |
133 (calc-with-trail-buffer | |
134 (if arg | |
135 (forward-line (- (prefix-numeric-value arg)))) | |
136 (if (or (looking-at "Emacs Calc") | |
137 (looking-at "----") | |
138 (looking-at " ? ? ?[^ \n]* *$") | |
139 (looking-at "..?.?$")) | |
140 (error "Can't yank that line")) | |
141 (if (looking-at ".*, \\.\\.\\., ") | |
142 (error "Can't yank (vector was abbreviated)")) | |
143 (forward-char 4) | |
144 (search-forward " ") | |
145 (let* ((next (save-excursion (forward-line 1) (point))) | |
146 (str (buffer-substring (point) (1- next))) | |
147 (val (save-excursion | |
148 (set-buffer save-buf) | |
149 (math-read-plain-expr str)))) | |
150 (if (eq (car-safe val) 'error) | |
151 (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
|
152 val)))))) |
40785 | 153 |
154 (defun calc-trail-marker (str) | |
155 (interactive "sText to insert in trail: ") | |
156 (calc-with-trail-buffer | |
157 (forward-line 1) | |
158 (let ((buffer-read-only nil)) | |
159 (insert "---- " str "\n")) | |
160 (forward-line -1) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40785
diff
changeset
|
161 (calc-trail-here))) |
40785 | 162 |
163 (defun calc-trail-kill (n) | |
164 (interactive "p") | |
165 (calc-with-trail-buffer | |
166 (let ((buffer-read-only nil)) | |
167 (save-restriction | |
168 (narrow-to-region ; don't delete "Emacs Trail" header | |
169 (save-excursion | |
170 (goto-char (point-min)) | |
171 (forward-line 1) | |
172 (point)) | |
173 (point-max)) | |
174 (kill-line n))) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40785
diff
changeset
|
175 (calc-trail-here))) |
40785 | 176 |
58675
0f204f1642ec
Add a provide statement.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
52401
diff
changeset
|
177 (provide 'calc-trail) |
0f204f1642ec
Add a provide statement.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
52401
diff
changeset
|
178 |
52401 | 179 ;;; 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
|
180 ;;; calc-trail.el ends here |