Mercurial > hg > xemacs-beta
comparison lisp/view-less.el @ 444:576fb035e263 r21-2-37
Import from CVS: tag r21-2-37
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:36:19 +0200 |
parents | 3ecd8885ac67 |
children | 1ccc32a20af4 |
comparison
equal
deleted
inserted
replaced
443:a8296e22da4e | 444:576fb035e263 |
---|---|
5 ;; Author: Jonathan Stigelman <stig@hackvan.com> | 5 ;; Author: Jonathan Stigelman <stig@hackvan.com> |
6 ;; Maintainer: XEmacs Development Team | 6 ;; Maintainer: XEmacs Development Team |
7 ;; Keywords: wp, unix | 7 ;; Keywords: wp, unix |
8 | 8 |
9 ;; This file is part of XEmacs. | 9 ;; This file is part of XEmacs. |
10 ;; | 10 ;; |
11 ;; XEmacs is free software; you can redistribute it and/or modify | 11 ;; XEmacs is free software; you can redistribute it and/or modify |
12 ;; it under the terms of the GNU General Public License as published by | 12 ;; it under the terms of the GNU General Public License as published by |
13 ;; the Free Software Foundation; either version 2 of the License, or | 13 ;; the Free Software Foundation; either version 2 of the License, or |
14 ;; (at your option) any later version. | 14 ;; (at your option) any later version. |
15 ;; | 15 ;; |
16 ;; XEmacs is distributed in the hope that it will be useful, | 16 ;; XEmacs is distributed in the hope that it will be useful, |
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | 17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
19 ;; GNU General Public License for more details. | 19 ;; GNU General Public License for more details. |
20 ;; | 20 ;; |
21 ;; You should have received a copy of the GNU General Public License | 21 ;; You should have received a copy of the GNU General Public License |
22 ;; along with XEmacs; if not, write to the Free Software | 22 ;; along with XEmacs; if not, write to the Free Software |
23 ;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 23 ;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
24 | 24 |
25 ;;; Synched up with: Not in FSF. | 25 ;;; Synched up with: Not in FSF. |
30 ;; similar to those used by the less(1) program are used. | 30 ;; similar to those used by the less(1) program are used. |
31 ;; | 31 ;; |
32 ;; Originally written for v18 by David Gudeman (gudeman@arizona.edu) | 32 ;; Originally written for v18 by David Gudeman (gudeman@arizona.edu) |
33 ;; Mods by Bengt Martensson, to closely resemble less (July 1987) | 33 ;; Mods by Bengt Martensson, to closely resemble less (July 1987) |
34 ;; | 34 ;; |
35 ;; If you would like all write-protected files to be visited in view-mode, | 35 ;; If you would like all write-protected files to be visited in view-mode, |
36 ;; then add the following to your .emacs file: | 36 ;; then add the following to your .emacs file: |
37 ;; | 37 ;; |
38 ;; (add-hook 'find-file-hooks 'auto-view-mode) | 38 ;; (add-hook 'find-file-hooks 'auto-view-mode) |
39 | 39 |
40 ;;; Code: | 40 ;;; Code: |
106 (let ((map (copy-keymap view-minor-mode-map))) | 106 (let ((map (copy-keymap view-minor-mode-map))) |
107 (set-keymap-name map 'view-mode-map) | 107 (set-keymap-name map 'view-mode-map) |
108 map)) | 108 map)) |
109 | 109 |
110 ;;;###autoload | 110 ;;;###autoload |
111 (defun view-file (file &optional other-p) | 111 (defun view-file (filename &optional other-window-p) |
112 "Find FILE, enter view mode. With prefix arg OTHER-P, use other window." | 112 "Find FILENAME, enter view mode. With prefix arg OTHER-WINDOW-P, use other window." |
113 (interactive "fView File: \nP") | 113 (interactive "fView File: \nP") |
114 (let ((old-p (get-file-buffer file)) | 114 (let ((old-p (get-file-buffer filename)) |
115 (obuf (current-buffer))) | 115 (obuf (current-buffer))) |
116 (if other-p | 116 (if other-window-p |
117 (find-file-other-window file) | 117 (find-file-other-window filename) |
118 (find-file file)) | 118 (find-file filename)) |
119 (view-mode (if other-p nil obuf) | 119 (view-mode (if other-window-p nil obuf) |
120 (if old-p nil 'kill-buffer)) | 120 (if old-p nil 'kill-buffer)) |
121 nil)) | 121 nil)) |
122 | 122 |
123 ;;;###autoload | 123 ;;;###autoload |
124 (defun view-buffer (buf &optional other-p) | 124 (defun view-buffer (buffer &optional other-window-p) |
125 "Switch to BUF, enter view mode. With prefix arg use other window." | 125 "Switch to BUFFER, enter view mode. With prefix arg use other window." |
126 (interactive "bView Buffer: \nP") | 126 (interactive "bView Buffer: \nP") |
127 (let ((obuf (current-buffer))) | 127 (let ((obuf (current-buffer))) |
128 (if other-p | 128 (if other-window-p |
129 (switch-to-buffer-other-window buf) | 129 (switch-to-buffer-other-window buffer) |
130 (switch-to-buffer buf)) | 130 (switch-to-buffer buffer)) |
131 (view-mode (if other-p nil obuf) (if other-p nil 'bury-buffer)))) | 131 (view-mode (if other-window-p nil obuf) |
132 | 132 (if other-window-p nil 'bury-buffer)))) |
133 ;;;###autoload | 133 |
134 (defun view-file-other-window (file) | 134 ;;;###autoload |
135 "Find FILE in other window, and enter view mode." | 135 (defun view-file-other-window (filename) |
136 "Find FILENAME in other window, and enter view mode." | |
136 (interactive "fView File: ") | 137 (interactive "fView File: ") |
137 (view-file file t)) | 138 (view-file filename t)) |
138 | 139 |
139 ;;;###autoload | 140 ;;;###autoload |
140 (defun view-buffer-other-window (buffer) | 141 (defun view-buffer-other-window (buffer) |
141 "Switch to BUFFER in another window, and enter view mode." | 142 "Switch to BUFFER in another window, and enter view mode." |
142 (interactive "bView Buffer: ") | 143 (interactive "bView Buffer: ") |
250 | 251 |
251 (defun view-quit-toggle-ro () | 252 (defun view-quit-toggle-ro () |
252 "Exit view mode and execute the global binding of the key that invoked this | 253 "Exit view mode and execute the global binding of the key that invoked this |
253 command. Normally, this will toggle the state of `buffer-read-only', perhaps | 254 command. Normally, this will toggle the state of `buffer-read-only', perhaps |
254 invoking some version-control mechanism." | 255 invoking some version-control mechanism." |
255 (interactive) | 256 (interactive) |
256 (setq view-exit-position nil) | 257 (setq view-exit-position nil) |
257 ;; Kludge so this works as advertised. Stig, why can't you write | 258 ;; Kludge so this works as advertised. Stig, why can't you write |
258 ;; bug-free code??? | 259 ;; bug-free code??? |
259 (let ((buffer-read-only buffer-read-only)) | 260 (let ((buffer-read-only buffer-read-only)) |
260 (view-quit t)) | 261 (view-quit t)) |
374 (defun view-search-forward (s p) | 375 (defun view-search-forward (s p) |
375 "Search forward for REGEXP. If regexp is empty, use last search string. | 376 "Search forward for REGEXP. If regexp is empty, use last search string. |
376 With prefix ARG, search forward that many occurrences." | 377 With prefix ARG, search forward that many occurrences." |
377 (interactive "sView search: \np") | 378 (interactive "sView search: \np") |
378 (unwind-protect | 379 (unwind-protect |
379 (re-search-forward | 380 (re-search-forward |
380 (if (string-equal "" s) view-search-string s) nil nil p) | 381 (if (string-equal "" s) view-search-string s) nil nil p) |
381 (setq view-search-arg p) | 382 (setq view-search-arg p) |
382 (or (string-equal "" s) | 383 (or (string-equal "" s) |
383 (setq view-search-string s)))) | 384 (setq view-search-string s)))) |
384 | 385 |