annotate lisp/modes/view-less.el @ 171:929b76928fce r20-3b12

Import from CVS: tag r20-3b12
author cvs
date Mon, 13 Aug 2007 09:47:52 +0200
parents 3bb7ccffb0c0
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;; view-less.el --- Minor mode for browsing files with keybindings like `less'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 ;; Copyright (C) 1994, 1995 Tinker Systems and INS Engineering Corp.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;; Author: Jonathan Stigelman
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;; Keywords: wp unix
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 ;; This file is part of XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;; XEmacs is free software; you can redistribute it and/or modify
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;; it under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;; the Free Software Foundation; either version 2 of the License, or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;; (at your option) any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;; XEmacs is distributed in the hope that it will be useful,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;; GNU General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 ;; along with XEmacs; if not, write to the Free Software
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 ;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 ;;; Synched up with: Not in FSF.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 ;;; Commentary:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 ;; This mode is for browsing files without changing them. Keybindings
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 ;; similar to those used by the less(1) program are used.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 ;; Originally written for v18 by David Gudeman (gudeman@arizona.edu)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 ;; Mods by Bengt Martensson, to closely resemble less (July 1987)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 ;; If you would like all write-protected files to be visited in view-mode,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 ;; then add the following to your .emacs file:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 ;; (add-hook 'find-file-hooks 'auto-view-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 ;;; Code:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 (defvar view-search-string ""
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 "Last string searched for with view-search functions.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 (defvar view-search-arg 1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 "Argument to last view search.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 (defvar view-default-lines 10
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 "Default value for the \"d\" and \"u\" commands in view-mode")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 (defvar view-minor-mode nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 "Non-nil when view-mode is active. Call `view-mode' to toggle.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 (make-variable-buffer-local 'view-minor-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53
116
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 70
diff changeset
54 ;;;###autoload
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 (defvar view-minor-mode-map
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 (let ((map (make-keymap)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 (set-keymap-name map 'view-minor-mode-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 (suppress-keymap map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 (define-key map "-" 'negative-argument)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 (define-key map " " 'scroll-up)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 (define-key map "f" 'scroll-up)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 (define-key map "b" 'scroll-down)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 (define-key map 'backspace 'scroll-down)
159
3bb7ccffb0c0 Import from CVS: tag r20-3b6
cvs
parents: 153
diff changeset
64 (define-key map 'delete 'scroll-down)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 (define-key map "\r" 'view-scroll-lines-up)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 (define-key map "\n" 'view-scroll-lines-up)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 (define-key map "e" 'view-scroll-lines-up)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 (define-key map "j" 'view-scroll-lines-up)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 (define-key map "y" 'view-scroll-lines-down)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 (define-key map "k" 'view-scroll-lines-down)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 (define-key map "d" 'view-scroll-some-lines-up)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 (define-key map "u" 'view-scroll-some-lines-down)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 (define-key map "r" 'recenter)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 (define-key map "t" 'toggle-truncate-lines)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 (define-key map "N" 'view-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 (define-key map "E" 'view-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 (define-key map "P" 'view-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 (define-key map "!" 'shell-command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 (define-key map "|" 'shell-command-on-region)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 (define-key map "=" 'what-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 (define-key map "?" 'view-search-backward)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 (define-key map "h" 'view-mode-describe)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 (define-key map "s" 'view-repeat-search)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 (define-key map "n" 'view-repeat-search)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 (define-key map "/" 'view-search-forward)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 (define-key map "\\" 'view-search-backward)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 (define-key map "g" 'view-goto-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 (define-key map "G" 'view-last-windowful)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 (define-key map "%" 'view-goto-percent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 (define-key map "p" 'view-goto-percent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 (define-key map "m" 'point-to-register)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 (define-key map "'" 'register-to-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 (define-key map "C" 'view-cleanup-backspaces)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 (define-key map "\C-c\C-c" 'view-quit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 ;; #### - should this use substitute-command-keys?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 (define-key map "\C-x\C-q" 'view-quit-toggle-ro)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 (define-key map "q" 'view-quit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 map
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 (add-minor-mode 'view-minor-mode " View" view-minor-mode-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102
116
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 70
diff changeset
103 ;;;###autoload
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 (defvar view-mode-map
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 (let ((map (copy-keymap view-minor-mode-map)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 (set-keymap-name map 'view-mode-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 map))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 (defun view-file (file &optional other-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 "Find FILE, enter view mode. With prefix arg OTHER-P, use other window."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 (interactive "fView File: \nP")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 (let ((old-p (get-file-buffer file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 (obuf (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 (if other-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 (find-file-other-window file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 (find-file file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 (view-mode (if other-p nil obuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 (if old-p nil 'kill-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 (defun view-buffer (buf &optional other-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 "Switch to BUF, enter view mode. With prefix arg use other window."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 (interactive "bView Buffer: \nP")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 (let ((obuf (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 (if other-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 (switch-to-buffer-other-window buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 (switch-to-buffer buf))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 (view-mode (if other-p nil obuf) (if other-p nil 'bury-buffer))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 (defun view-file-other-window (file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 "Find FILE in other window, and enter view mode."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 (interactive "fView File: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 (view-file file t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 (defun view-buffer-other-window (buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 "Switch to BUFFER in another window, and enter view mode."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 (interactive "bView Buffer: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 (view-buffer buffer t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 (defun view-brief-help ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 (message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 (substitute-command-keys
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 "\\<view-minor-mode-map>\\[scroll-up] = page forward; \\[scroll-down] = page back; \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 \\[view-mode-describe] = help; \\[view-quit] = quit.")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 (defvar view-exit-position)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 (defvar view-prev-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 (defvar view-exit-action)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 (defvar view-old-buffer-read-only)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 (defun view-minor-mode (&optional prev-buffer exit-action)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 "Minor mode for viewing text, with bindings like `less'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 Commands are:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 \\<view-minor-mode-map>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 0..9 prefix args
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 - prefix minus
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 \\[scroll-up] page forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 \\[scroll-down] page back
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 \\[view-scroll-lines-up] scroll prefix-arg lines forward, default 1.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 \\[view-scroll-lines-down] scroll prefix-arg lines backward, default 1.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 \\[view-scroll-some-lines-down] scroll prefix-arg lines backward, default 10.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 \\[view-scroll-some-lines-up] scroll prefix-arg lines forward, default 10.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 \\[what-line] print line number
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 \\[view-mode-describe] print this help message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 \\[view-search-forward] regexp search, uses previous string if you just hit RET
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 \\[view-search-backward] as above but searches backward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 \\[view-repeat-search] repeat last search
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 \\[view-goto-line] goto line prefix-arg, default 1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 \\[view-last-windowful] goto line prefix-arg, default last line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 \\[view-goto-percent] goto a position by percentage
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 \\[toggle-truncate-lines] toggle truncate-lines
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 \\[view-file] view another file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 \\[view-buffer] view another buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 \\[view-cleanup-backspaces] cleanup backspace constructions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 \\[shell-command] execute a shell command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 \\[shell-command-on-region]\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 execute a shell command with the region as input
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 \\[view-quit] exit view-mode, and bury the current buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 If invoked with the optional (prefix) arg non-nil, view-mode cleans up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 backspace constructions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 More precisely:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 \\{view-minor-mode-map}"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 (make-local-variable 'view-default-lines)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 (set (make-local-variable 'view-exit-position) (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 (set (make-local-variable 'view-prev-buffer) prev-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 (set (make-local-variable 'view-exit-action) exit-action)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 (set (make-local-variable 'view-old-buffer-read-only) buffer-read-only)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 (add-hook (make-local-variable 'change-major-mode-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 'view-fixup-read-only)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 (setq view-minor-mode t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 buffer-read-only t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 (view-brief-help))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 (defun view-mode (&optional prev-buffer exit-action clean-bs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 "View the current buffer using view-minor-mode. This exists to be 99.9%
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 compatible with the implementations of `view-mode' in view.el and older
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 versions of view-less.el."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 (interactive (list nil 'bury-buffer current-prefix-arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 ;; #### - The first two arguments provide compatibility with view.el (and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 ;; thus FSFmacs), while the third argument as a prefix argument maintains
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 ;; interactive compatibility with older versions of view-less. --Stig
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 (if clean-bs (cleanup-backspaces))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 (view-minor-mode prev-buffer exit-action))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 (defun view-major-mode (&optional prev-buffer exit-action clean-bs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 "View the current buffer using view-mode, as a major mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 This function has a nonstandard name because `view-mode' is wrongly
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 named but is like this for compatibility reasons."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 ;; #### - The first two arguments provide compatibility with view.el (and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 ;; thus FSFmacs), while the third argument as a prefix argument maintains
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 ;; interactive compatibility with older versions of view-less. --Stig
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 (interactive (list nil 'bury-buffer current-prefix-arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 (kill-all-local-variables)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 (use-local-map view-mode-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 (setq major-mode 'view-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 (set (make-local-variable 'view-exit-position) (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 (set (make-local-variable 'view-prev-buffer) prev-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 (set (make-local-variable 'view-exit-action) exit-action)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 (set (make-local-variable 'view-old-buffer-read-only) buffer-read-only)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 (set (make-local-variable 'view-major-mode) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 (setq buffer-read-only t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 (if clean-bs (cleanup-backspaces))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 (run-hooks 'view-mode-hook))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 (defun auto-view-mode ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 "If the file of the current buffer is not writable, call view-mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 This is meant to be added to `find-file-hooks'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 (or (file-writable-p buffer-file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 (view-minor-mode)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 (defun view-fixup-read-only ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 ;; doing M-x normal mode should NOT leave the buffer read-only
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 (and (boundp 'view-old-buffer-read-only)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 (progn (setq buffer-read-only view-old-buffer-read-only)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 (kill-local-variable 'view-old-buffer-read-only))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 (defun view-quit-toggle-ro ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 "Exit view mode and execute the global binding of the key that invoked this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 command. Normally, this will toggle the state of `buffer-read-only', perhaps
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 invoking some version-control mechanism."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 (setq view-exit-position nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 ;; Kludge so this works as advertised. Stig, why can't you write
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 ;; bug-free code???
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 (let ((buffer-read-only buffer-read-only))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 (view-quit t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 ;; no longer in view-minor-mode, so the keymap has changed...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 (call-interactively (key-binding (this-command-keys))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 (defun view-quit (&optional no-exit-action)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 "Exit view mode. With prefix argument, keep the current buffer selected."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 (view-fixup-read-only)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 (setq view-minor-mode nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 (if view-exit-position (goto-char view-exit-position))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 (if (and (boundp 'view-major-mode) view-major-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 (fundamental-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 (let ((pbuf view-prev-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 (exitact view-exit-action))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 (if no-exit-action
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 (if exitact (funcall exitact (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 (if pbuf (switch-to-buffer pbuf))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 ;; #### - similar to what's in man.el and this ought to be written in C anyway... --Stig
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 (defun cleanup-backspaces ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 "Cleanup backspace constructions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 _^H and ^H_ sequences are deleted. x^Hx sequences are turned into x for all
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 characters x. ^^H| and |^H^ sequences are turned into ^. +^Ho and o^H+ are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 turned into (+)."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 (while (= (following-char) ?\C-h)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 (delete-char 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 (while (search-forward "\C-h" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 (forward-char -2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 (cond ((looking-at "_\C-h\\|\\(.\\)\C-h\\1\\||\C-h\\^")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 (delete-char 2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 ((looking-at ".\C-h_\\|\\^\C-h|")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 (forward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 (delete-char 2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 ((looking-at "+\C-ho\\|o\C-h+")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 (delete-char 3)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 (insert "(+)"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 ((looking-at "|\C-h-")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 (delete-char 3)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 (insert "*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 (t (forward-char 2))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 (defun view-cleanup-backspaces ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 "Cleanup backspaces and if buffer is currently unmodified, don't flag it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 as a modified buffer. This works even if the buffer is read-only."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 (let ((buffer-read-only)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 (buf-mod (buffer-modified-p)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 (cleanup-backspaces)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 ;; #### - THIS IS PROBABLY A REALLY DANGEROUS THING TO DO IN A MINOR MODE!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 (set-buffer-modified-p buf-mod)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 (defun toggle-truncate-lines (&optional p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 "Toggles the values of truncate-lines.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 Positive prefix arg sets, negative disables."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 (setq truncate-lines (if p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 (> (prefix-numeric-value p) 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 (not truncate-lines)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 (recenter))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 (defun view-scroll-lines-up (p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 "Scroll up prefix-arg lines, default 1."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 (scroll-up p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 (defun view-scroll-lines-down (p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 "Scroll down prefix-arg lines, default 1."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 (scroll-up (- p)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 (defun view-scroll-some-lines-down (&optional n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 "Scroll down prefix-arg lines, default 10, or last argument."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 (if (> n 1) (setq view-default-lines n))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 (scroll-down view-default-lines))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 (defun view-scroll-some-lines-up (&optional n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 "Scroll up prefix-arg lines, default 10, or last argument."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 (if (> n 1) (setq view-default-lines n))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 (scroll-up view-default-lines))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 (defun view-goto-line (&optional n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 "Goto prefix arg line N. N = 1 by default.."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 (goto-line n))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 (defun view-last-windowful (&optional n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 "Goto prefix arg line N or the first line of the last windowful in buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 (if current-prefix-arg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 (goto-line n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 (end-of-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 (recenter -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 (move-to-window-line 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 (defun view-goto-percent (&optional percent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 "Set mark and go to a position PERCENT way into the current buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 (set-mark-command nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 (goto-char (+ (point-min) (/ (* percent (- (point-max) (point-min))) 100)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 (beginning-of-line))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 (defun view-mode-describe ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 (let ((mode-name "View")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 (major-mode 'view-mode))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 (describe-mode)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 (defun view-search-forward (s p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 "Search forward for REGEXP. If regexp is empty, use last search string.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 With prefix ARG, search forward that many occurrences."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 (interactive "sView search: \np")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 (re-search-forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 (if (string-equal "" s) view-search-string s) nil nil p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 (setq view-search-arg p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 (or (string-equal "" s)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 (setq view-search-string s))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 (defun view-search-backward (s p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 "Search backward for REGEXP. If regexp is empty, use last search string.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 With prefix ARG, search forward that many occurrences."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 (interactive "sView search backward: \np")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 (view-search-forward s (- p)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 (defun view-repeat-search (p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 "Repeat last view search command. If a prefix arg is given, use that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 instead of the previous arg, if the prefix is just a -, then take the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 negative of the last prefix arg."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 (view-search-forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 view-search-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 (cond ((null p) view-search-arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 ((eq p '-) (- view-search-arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 (t (prefix-numeric-value p)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 (provide 'view)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 (provide 'view-less)