Mercurial > emacs
annotate lisp/calc/calc-trail.el @ 99266:8d57082234b9
(indent-for-tab-command): Use use-region-p.
author | Chong Yidong <cyd@stupidchicken.com> |
---|---|
date | Thu, 30 Oct 2008 23:52:39 +0000 |
parents | 6c9af2bfcfee |
children | a9dc0e7c3f2b |
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 | |
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 | |
111 (save-window-excursion | |
112 (select-window (get-buffer-window (current-buffer))) | |
113 (let ((search-exit-char ?\r)) | |
114 (isearch-forward))) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40785
diff
changeset
|
115 (calc-trail-here))) |
40785 | 116 |
117 (defun calc-trail-isearch-backward () | |
118 (interactive) | |
119 (calc-with-trail-buffer | |
120 (save-window-excursion | |
121 (select-window (get-buffer-window (current-buffer))) | |
122 (let ((search-exit-char ?\r)) | |
123 (isearch-backward))) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40785
diff
changeset
|
124 (calc-trail-here))) |
40785 | 125 |
126 (defun calc-trail-yank (arg) | |
127 (interactive "P") | |
128 (calc-wrapper | |
129 (or arg (calc-set-command-flag 'hold-trail)) | |
130 (calc-enter-result 0 "yank" | |
131 (calc-with-trail-buffer | |
132 (if arg | |
133 (forward-line (- (prefix-numeric-value arg)))) | |
134 (if (or (looking-at "Emacs Calc") | |
135 (looking-at "----") | |
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)")) | |
141 (forward-char 4) | |
142 (search-forward " ") | |
143 (let* ((next (save-excursion (forward-line 1) (point))) | |
144 (str (buffer-substring (point) (1- next))) | |
145 (val (save-excursion | |
146 (set-buffer save-buf) | |
147 (math-read-plain-expr str)))) | |
148 (if (eq (car-safe val) 'error) | |
149 (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
|
150 val)))))) |
40785 | 151 |
152 (defun calc-trail-marker (str) | |
153 (interactive "sText to insert in trail: ") | |
154 (calc-with-trail-buffer | |
155 (forward-line 1) | |
156 (let ((buffer-read-only nil)) | |
157 (insert "---- " str "\n")) | |
158 (forward-line -1) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40785
diff
changeset
|
159 (calc-trail-here))) |
40785 | 160 |
161 (defun calc-trail-kill (n) | |
162 (interactive "p") | |
163 (calc-with-trail-buffer | |
164 (let ((buffer-read-only nil)) | |
165 (save-restriction | |
166 (narrow-to-region ; don't delete "Emacs Trail" header | |
167 (save-excursion | |
168 (goto-char (point-min)) | |
169 (forward-line 1) | |
170 (point)) | |
171 (point-max)) | |
172 (kill-line n))) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40785
diff
changeset
|
173 (calc-trail-here))) |
40785 | 174 |
58675
0f204f1642ec
Add a provide statement.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
52401
diff
changeset
|
175 (provide 'calc-trail) |
0f204f1642ec
Add a provide statement.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
52401
diff
changeset
|
176 |
93975
1e3a407766b9
Fix up comment convention on the arch-tag lines.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79702
diff
changeset
|
177 ;; 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
|
178 ;;; calc-trail.el ends here |