Mercurial > emacs
annotate lisp/view.el @ 110407:e9bd1f306e02
Add xml.o dependencies to deps.mk.
deps.mk (xml.o): Add dependencies.
author | Eli Zaretskii <eliz@gnu.org> |
---|---|
date | Sat, 18 Sep 2010 16:09:40 +0200 |
parents | 0b37f86b040e |
children | 417b1e4d63cd |
rev | line source |
---|---|
38436
b174db545cfd
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
33423
diff
changeset
|
1 ;;; view.el --- peruse file or buffer without editing |
657
fec3f9a1e3e5
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
584
diff
changeset
|
2 |
64762
41bb365f41c4
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64091
diff
changeset
|
3 ;; Copyright (C) 1985, 1989, 1994, 1995, 1997, 2000, 2001, 2002, |
106815 | 4 ;; 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. |
840
113281b361ec
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
807
diff
changeset
|
5 |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
657
diff
changeset
|
6 ;; Author: K. Shane Hartman |
18271 | 7 ;; Maintainer: Inge Frick <inge@nada.kth.se> |
39117 | 8 ;; Keywords: files |
44 | 9 |
10 ;; This file is part of GNU Emacs. | |
11 | |
94678
ee5932bf781d
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
12 ;; GNU Emacs is free software: you can redistribute it and/or modify |
44 | 13 ;; it under the terms of the GNU General Public License as published by |
94678
ee5932bf781d
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
14 ;; the Free Software Foundation, either version 3 of the License, or |
ee5932bf781d
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
15 ;; (at your option) any later version. |
44 | 16 |
17 ;; GNU Emacs is distributed in the hope that it will be useful, | |
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
20 ;; GNU General Public License for more details. | |
21 | |
22 ;; You should have received a copy of the GNU General Public License | |
94678
ee5932bf781d
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
23 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
44 | 24 |
2319
d98c49df2acd
Added or corrected Commentary section
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
931
diff
changeset
|
25 ;;; Commentary: |
d98c49df2acd
Added or corrected Commentary section
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
931
diff
changeset
|
26 |
12856 | 27 ;; This package provides the `view' minor mode documented in the Emacs |
2319
d98c49df2acd
Added or corrected Commentary section
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
931
diff
changeset
|
28 ;; user's manual. |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
29 ;; View mode entry and exit is done through the functions view-mode-enter |
18448
7cf9cdba062d
Changed some documentation.
Richard M. Stallman <rms@gnu.org>
parents:
18335
diff
changeset
|
30 ;; and view-mode-exit. Use these functions to enter or exit view-mode from |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
31 ;; emacs lisp programs. |
18448
7cf9cdba062d
Changed some documentation.
Richard M. Stallman <rms@gnu.org>
parents:
18335
diff
changeset
|
32 ;; We use both view- and View- as prefix for symbols. View- is used as |
20072
92d2c2e3b3f3
Some changes in comments and documentation.
Karl Heuer <kwzh@gnu.org>
parents:
19841
diff
changeset
|
33 ;; prefix for commands that have a key binding. view- is used for commands |
18448
7cf9cdba062d
Changed some documentation.
Richard M. Stallman <rms@gnu.org>
parents:
18335
diff
changeset
|
34 ;; without key binding. The purpose of this is to make it easier for a |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
35 ;; user to use command name completion. |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
36 |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
37 ;;; Suggested key bindings: |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
38 ;; |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
39 ;; (define-key ctl-x-4-map "v" 'view-file-other-window) ; ^x4v |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
40 ;; (define-key ctl-x-5-map "v" 'view-file-other-frame) ; ^x5v |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
41 ;; |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
42 ;; You could also bind view-file, view-buffer, view-buffer-other-window and |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
43 ;; view-buffer-other-frame to keys. |
50786
01b16e9a75fb
(Helper-return-blurb): Add defvar. (Also rearrange defuns.)
Richard M. Stallman <rms@gnu.org>
parents:
50634
diff
changeset
|
44 |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
657
diff
changeset
|
45 ;;; Code: |
44 | 46 |
20072
92d2c2e3b3f3
Some changes in comments and documentation.
Karl Heuer <kwzh@gnu.org>
parents:
19841
diff
changeset
|
47 (defgroup view nil |
92d2c2e3b3f3
Some changes in comments and documentation.
Karl Heuer <kwzh@gnu.org>
parents:
19841
diff
changeset
|
48 "Peruse file or buffer without editing." |
92d2c2e3b3f3
Some changes in comments and documentation.
Karl Heuer <kwzh@gnu.org>
parents:
19841
diff
changeset
|
49 :link '(function-link view-mode) |
92d2c2e3b3f3
Some changes in comments and documentation.
Karl Heuer <kwzh@gnu.org>
parents:
19841
diff
changeset
|
50 :link '(custom-manual "(emacs)Misc File Ops") |
107378
904ccd8f2acb
Reorganize Custom groups.
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
51 :group 'wp) |
20072
92d2c2e3b3f3
Some changes in comments and documentation.
Karl Heuer <kwzh@gnu.org>
parents:
19841
diff
changeset
|
52 |
92d2c2e3b3f3
Some changes in comments and documentation.
Karl Heuer <kwzh@gnu.org>
parents:
19841
diff
changeset
|
53 (defcustom view-highlight-face 'highlight |
100171 | 54 "The face used for highlighting the match found by View mode search." |
20072
92d2c2e3b3f3
Some changes in comments and documentation.
Karl Heuer <kwzh@gnu.org>
parents:
19841
diff
changeset
|
55 :type 'face |
92d2c2e3b3f3
Some changes in comments and documentation.
Karl Heuer <kwzh@gnu.org>
parents:
19841
diff
changeset
|
56 :group 'view) |
13167
c378e215f4d0
(view-highlight-face): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
13158
diff
changeset
|
57 |
18448
7cf9cdba062d
Changed some documentation.
Richard M. Stallman <rms@gnu.org>
parents:
18335
diff
changeset
|
58 ;; `view-mode-auto-exit' is replaced by the following option variable which |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
59 ;; only says if scrolling past buffer end should leave view mode or not, it |
18250 | 60 ;; doesn't say if leaving view mode should restore windows or not. The latter |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
61 ;; is now controlled by the presence of a value in `view-return-to-alist'. |
20072
92d2c2e3b3f3
Some changes in comments and documentation.
Karl Heuer <kwzh@gnu.org>
parents:
19841
diff
changeset
|
62 (defcustom view-scroll-auto-exit nil |
100171 | 63 "Non-nil means scrolling past the end of buffer exits View mode. |
77716
c8be59c5a8b1
(view-inhibit-help-message): Fix typo in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
76780
diff
changeset
|
64 A value of nil means attempting to scroll past the end of the buffer, |
20072
92d2c2e3b3f3
Some changes in comments and documentation.
Karl Heuer <kwzh@gnu.org>
parents:
19841
diff
changeset
|
65 only rings the bell and gives a message on how to leave." |
92d2c2e3b3f3
Some changes in comments and documentation.
Karl Heuer <kwzh@gnu.org>
parents:
19841
diff
changeset
|
66 :type 'boolean |
92d2c2e3b3f3
Some changes in comments and documentation.
Karl Heuer <kwzh@gnu.org>
parents:
19841
diff
changeset
|
67 :group 'view) |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
68 |
20072
92d2c2e3b3f3
Some changes in comments and documentation.
Karl Heuer <kwzh@gnu.org>
parents:
19841
diff
changeset
|
69 (defcustom view-try-extend-at-buffer-end nil |
100171 | 70 "Non-nil means try to load more of file when reaching end of buffer. |
18448
7cf9cdba062d
Changed some documentation.
Richard M. Stallman <rms@gnu.org>
parents:
18335
diff
changeset
|
71 This variable is mainly intended to be temporarily set to non-nil by |
7cf9cdba062d
Changed some documentation.
Richard M. Stallman <rms@gnu.org>
parents:
18335
diff
changeset
|
72 the F command in view-mode, but you can set it to t if you want the action |
20072
92d2c2e3b3f3
Some changes in comments and documentation.
Karl Heuer <kwzh@gnu.org>
parents:
19841
diff
changeset
|
73 for all scroll commands in view mode." |
92d2c2e3b3f3
Some changes in comments and documentation.
Karl Heuer <kwzh@gnu.org>
parents:
19841
diff
changeset
|
74 :type 'boolean |
92d2c2e3b3f3
Some changes in comments and documentation.
Karl Heuer <kwzh@gnu.org>
parents:
19841
diff
changeset
|
75 :group 'view) |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
76 |
86004
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
77 ;;;###autoload |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
78 (defcustom view-remove-frame-by-deleting t |
100171 | 79 "Determine how View mode removes a frame no longer needed. |
20072
92d2c2e3b3f3
Some changes in comments and documentation.
Karl Heuer <kwzh@gnu.org>
parents:
19841
diff
changeset
|
80 If nil, make an icon of the frame. If non-nil, delete the frame." |
92d2c2e3b3f3
Some changes in comments and documentation.
Karl Heuer <kwzh@gnu.org>
parents:
19841
diff
changeset
|
81 :type 'boolean |
86004
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
82 :group 'view |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
83 ;; Changed the default of this to t for Emacs 23. Users consider |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
84 ;; frame iconification annoying. |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
85 :version "23.1") |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
86 |
20072
92d2c2e3b3f3
Some changes in comments and documentation.
Karl Heuer <kwzh@gnu.org>
parents:
19841
diff
changeset
|
87 (defcustom view-exits-all-viewing-windows nil |
100171 | 88 "Non-nil means restore all windows used to view buffer. |
18448
7cf9cdba062d
Changed some documentation.
Richard M. Stallman <rms@gnu.org>
parents:
18335
diff
changeset
|
89 Commands that restore windows when finished viewing a buffer, apply to all |
7cf9cdba062d
Changed some documentation.
Richard M. Stallman <rms@gnu.org>
parents:
18335
diff
changeset
|
90 windows that display the buffer and have restore information in |
20072
92d2c2e3b3f3
Some changes in comments and documentation.
Karl Heuer <kwzh@gnu.org>
parents:
19841
diff
changeset
|
91 `view-return-to-alist'. |
21187
f072dd90378d
(view-return-to-alist): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
20072
diff
changeset
|
92 If `view-exits-all-viewing-windows' is nil, only the selected window is |
20072
92d2c2e3b3f3
Some changes in comments and documentation.
Karl Heuer <kwzh@gnu.org>
parents:
19841
diff
changeset
|
93 considered for restoring." |
92d2c2e3b3f3
Some changes in comments and documentation.
Karl Heuer <kwzh@gnu.org>
parents:
19841
diff
changeset
|
94 :type 'boolean |
92d2c2e3b3f3
Some changes in comments and documentation.
Karl Heuer <kwzh@gnu.org>
parents:
19841
diff
changeset
|
95 :group 'view) |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
96 |
67203
78e1225a40a2
(view-inhibit-help-message): New defcustom.
Romain Francoise <romain@orebokech.com>
parents:
66488
diff
changeset
|
97 (defcustom view-inhibit-help-message nil |
100171 | 98 "Non-nil inhibits the help message shown upon entering View mode." |
67203
78e1225a40a2
(view-inhibit-help-message): New defcustom.
Romain Francoise <romain@orebokech.com>
parents:
66488
diff
changeset
|
99 :type 'boolean |
78e1225a40a2
(view-inhibit-help-message): New defcustom.
Romain Francoise <romain@orebokech.com>
parents:
66488
diff
changeset
|
100 :group 'view |
78e1225a40a2
(view-inhibit-help-message): New defcustom.
Romain Francoise <romain@orebokech.com>
parents:
66488
diff
changeset
|
101 :version "22.1") |
78e1225a40a2
(view-inhibit-help-message): New defcustom.
Romain Francoise <romain@orebokech.com>
parents:
66488
diff
changeset
|
102 |
18335
6f48844ce1a9
(view-mode): Add autoload cookie to this variable.
Kenichi Handa <handa@m17n.org>
parents:
18271
diff
changeset
|
103 ;;;###autoload |
20072
92d2c2e3b3f3
Some changes in comments and documentation.
Karl Heuer <kwzh@gnu.org>
parents:
19841
diff
changeset
|
104 (defvar view-mode nil |
92d2c2e3b3f3
Some changes in comments and documentation.
Karl Heuer <kwzh@gnu.org>
parents:
19841
diff
changeset
|
105 "Non-nil if View mode is enabled. |
92d2c2e3b3f3
Some changes in comments and documentation.
Karl Heuer <kwzh@gnu.org>
parents:
19841
diff
changeset
|
106 Don't change this variable directly, you must change it by one of the |
92d2c2e3b3f3
Some changes in comments and documentation.
Karl Heuer <kwzh@gnu.org>
parents:
19841
diff
changeset
|
107 functions that enable or disable view mode.") |
18335
6f48844ce1a9
(view-mode): Add autoload cookie to this variable.
Kenichi Handa <handa@m17n.org>
parents:
18271
diff
changeset
|
108 ;;;###autoload |
12856 | 109 (make-variable-buffer-local 'view-mode) |
110 | |
20072
92d2c2e3b3f3
Some changes in comments and documentation.
Karl Heuer <kwzh@gnu.org>
parents:
19841
diff
changeset
|
111 (defcustom view-mode-hook nil |
92d2c2e3b3f3
Some changes in comments and documentation.
Karl Heuer <kwzh@gnu.org>
parents:
19841
diff
changeset
|
112 "Normal hook run when starting to view a buffer or file." |
92d2c2e3b3f3
Some changes in comments and documentation.
Karl Heuer <kwzh@gnu.org>
parents:
19841
diff
changeset
|
113 :type 'hook |
92d2c2e3b3f3
Some changes in comments and documentation.
Karl Heuer <kwzh@gnu.org>
parents:
19841
diff
changeset
|
114 :group 'view) |
50786
01b16e9a75fb
(Helper-return-blurb): Add defvar. (Also rearrange defuns.)
Richard M. Stallman <rms@gnu.org>
parents:
50634
diff
changeset
|
115 |
13078
d7735534db86
(view-mode-enter): Renamed from view-mode. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
12857
diff
changeset
|
116 (defvar view-old-buffer-read-only nil) |
d7735534db86
(view-mode-enter): Renamed from view-mode. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
12857
diff
changeset
|
117 (make-variable-buffer-local 'view-old-buffer-read-only) |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
118 |
13078
d7735534db86
(view-mode-enter): Renamed from view-mode. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
12857
diff
changeset
|
119 (defvar view-old-Helper-return-blurb) |
d7735534db86
(view-mode-enter): Renamed from view-mode. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
12857
diff
changeset
|
120 (make-variable-buffer-local 'view-old-Helper-return-blurb) |
d7735534db86
(view-mode-enter): Renamed from view-mode. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
12857
diff
changeset
|
121 |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
122 (defvar view-page-size nil |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
123 "Default number of lines to scroll by View page commands. |
57521
3ac03a07be63
(view-mode-enable): Set view-page-size and view-half-page-size to nil.
Richard M. Stallman <rms@gnu.org>
parents:
55014
diff
changeset
|
124 If nil that means use the window size.") |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
125 (make-variable-buffer-local 'view-page-size) |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
126 |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
127 (defvar view-half-page-size nil |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
128 "Default number of lines to scroll by View half page commands. |
57521
3ac03a07be63
(view-mode-enable): Set view-page-size and view-half-page-size to nil.
Richard M. Stallman <rms@gnu.org>
parents:
55014
diff
changeset
|
129 If nil that means use half the window size.") |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
130 (make-variable-buffer-local 'view-half-page-size) |
13078
d7735534db86
(view-mode-enter): Renamed from view-mode. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
12857
diff
changeset
|
131 |
d7735534db86
(view-mode-enter): Renamed from view-mode. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
12857
diff
changeset
|
132 (defvar view-last-regexp nil) |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
133 (make-variable-buffer-local 'view-last-regexp) ; Global is better??? |
13078
d7735534db86
(view-mode-enter): Renamed from view-mode. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
12857
diff
changeset
|
134 |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
135 (defvar view-return-to-alist nil |
18448
7cf9cdba062d
Changed some documentation.
Richard M. Stallman <rms@gnu.org>
parents:
18335
diff
changeset
|
136 "What to do with used windows and where to go when finished viewing buffer. |
7cf9cdba062d
Changed some documentation.
Richard M. Stallman <rms@gnu.org>
parents:
18335
diff
changeset
|
137 This is local in each buffer being viewed. |
21187
f072dd90378d
(view-return-to-alist): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
20072
diff
changeset
|
138 It is added to by `view-mode-enter' when starting to view a buffer and |
f072dd90378d
(view-return-to-alist): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
20072
diff
changeset
|
139 subtracted from by `view-mode-exit' when finished viewing the buffer. |
18448
7cf9cdba062d
Changed some documentation.
Richard M. Stallman <rms@gnu.org>
parents:
18335
diff
changeset
|
140 |
7cf9cdba062d
Changed some documentation.
Richard M. Stallman <rms@gnu.org>
parents:
18335
diff
changeset
|
141 See RETURN-TO-ALIST argument of function `view-mode-exit' for the format of |
18250 | 142 `view-return-to-alist'.") |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
143 (make-variable-buffer-local 'view-return-to-alist) |
55014
202b0dc516a5
(view-return-to-alist): Mark it permanent local.
Richard M. Stallman <rms@gnu.org>
parents:
53845
diff
changeset
|
144 (put 'view-return-to-alist 'permanent-local t) |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
145 |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
146 (defvar view-exit-action nil |
86004
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
147 "If non-nil, a function with one argument (a buffer) called when finished viewing. |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
148 Commands like \\[view-file] and \\[view-file-other-window] may |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
149 set this to bury or kill the viewed buffer. |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
150 Observe that the buffer viewed might not appear in any window at |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
151 the time this function is called.") |
13078
d7735534db86
(view-mode-enter): Renamed from view-mode. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
12857
diff
changeset
|
152 (make-variable-buffer-local 'view-exit-action) |
d7735534db86
(view-mode-enter): Renamed from view-mode. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
12857
diff
changeset
|
153 |
19229
e272bd93c93c
(view-just-bury): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
18448
diff
changeset
|
154 (defvar view-no-disable-on-exit nil |
e272bd93c93c
(view-just-bury): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
18448
diff
changeset
|
155 "If non-nil, View mode \"exit\" commands don't actually disable View mode. |
e272bd93c93c
(view-just-bury): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
18448
diff
changeset
|
156 Instead, these commands just switch buffers or windows. |
e272bd93c93c
(view-just-bury): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
18448
diff
changeset
|
157 This is set in certain buffers by specialized features such as help commands |
e272bd93c93c
(view-just-bury): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
18448
diff
changeset
|
158 that use View mode automatically.") |
e272bd93c93c
(view-just-bury): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
18448
diff
changeset
|
159 |
13122
05bae277596e
(View-search-regexp-forward, View-search-regexp-backward):
Richard M. Stallman <rms@gnu.org>
parents:
13078
diff
changeset
|
160 (defvar view-overlay nil |
13167
c378e215f4d0
(view-highlight-face): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
13158
diff
changeset
|
161 "Overlay used to display where a search operation found its match. |
c378e215f4d0
(view-highlight-face): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
13158
diff
changeset
|
162 This is local in each buffer, once it is used.") |
13122
05bae277596e
(View-search-regexp-forward, View-search-regexp-backward):
Richard M. Stallman <rms@gnu.org>
parents:
13078
diff
changeset
|
163 (make-variable-buffer-local 'view-overlay) |
50786
01b16e9a75fb
(Helper-return-blurb): Add defvar. (Also rearrange defuns.)
Richard M. Stallman <rms@gnu.org>
parents:
50634
diff
changeset
|
164 |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
165 ;; Define keymap inside defvar to make it easier to load changes. |
20072
92d2c2e3b3f3
Some changes in comments and documentation.
Karl Heuer <kwzh@gnu.org>
parents:
19841
diff
changeset
|
166 ;; Some redundant "less"-like key bindings below have been commented out. |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
167 (defvar view-mode-map |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
168 (let ((map (make-sparse-keymap))) |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
169 (define-key map "C" 'View-kill-and-leave) |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
170 (define-key map "c" 'View-leave) |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
171 (define-key map "Q" 'View-quit-all) |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
172 (define-key map "E" 'View-exit-and-edit) |
96229
f0fef621a168
Fix up comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
173 ;; (define-key map "v" 'View-exit) |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
174 (define-key map "e" 'View-exit) |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
175 (define-key map "q" 'View-quit) |
96229
f0fef621a168
Fix up comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
176 ;; (define-key map "N" 'View-search-last-regexp-backward) |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
177 (define-key map "p" 'View-search-last-regexp-backward) |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
178 (define-key map "n" 'View-search-last-regexp-forward) |
96229
f0fef621a168
Fix up comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
179 ;; (define-key map "?" 'View-search-regexp-backward) ; Less does this. |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
180 (define-key map "\\" 'View-search-regexp-backward) |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
181 (define-key map "/" 'View-search-regexp-forward) |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
182 (define-key map "r" 'isearch-backward) |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
183 (define-key map "s" 'isearch-forward) |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
184 (define-key map "m" 'point-to-register) |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
185 (define-key map "'" 'register-to-point) |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
186 (define-key map "x" 'exchange-point-and-mark) |
27544
4e3e1730232c
Some changes in documentation. Removed some trailing
Gerd Moellmann <gerd@gnu.org>
parents:
25219
diff
changeset
|
187 (define-key map "@" 'View-back-to-mark) |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
188 (define-key map "." 'set-mark-command) |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
189 (define-key map "%" 'View-goto-percent) |
96229
f0fef621a168
Fix up comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
190 ;; (define-key map "G" 'View-goto-line-last) |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
191 (define-key map "g" 'View-goto-line) |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
192 (define-key map "=" 'what-line) |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
193 (define-key map "F" 'View-revert-buffer-scroll-page-forward) |
96229
f0fef621a168
Fix up comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
194 ;; (define-key map "k" 'View-scroll-line-backward) |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
195 (define-key map "y" 'View-scroll-line-backward) |
96229
f0fef621a168
Fix up comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
196 ;; (define-key map "j" 'View-scroll-line-forward) |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
197 (define-key map "\n" 'View-scroll-line-forward) |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
198 (define-key map "\r" 'View-scroll-line-forward) |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
199 (define-key map "u" 'View-scroll-half-page-backward) |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
200 (define-key map "d" 'View-scroll-half-page-forward) |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
201 (define-key map "z" 'View-scroll-page-forward-set-page-size) |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
202 (define-key map "w" 'View-scroll-page-backward-set-page-size) |
96229
f0fef621a168
Fix up comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
203 ;; (define-key map "b" 'View-scroll-page-backward) |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
204 (define-key map "\C-?" 'View-scroll-page-backward) |
96229
f0fef621a168
Fix up comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
205 ;; (define-key map "f" 'View-scroll-page-forward) |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
206 (define-key map " " 'View-scroll-page-forward) |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
207 (define-key map "o" 'View-scroll-to-buffer-end) |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
208 (define-key map ">" 'end-of-buffer) |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
209 (define-key map "<" 'beginning-of-buffer) |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
210 (define-key map "-" 'negative-argument) |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
211 (define-key map "9" 'digit-argument) |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
212 (define-key map "8" 'digit-argument) |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
213 (define-key map "7" 'digit-argument) |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
214 (define-key map "6" 'digit-argument) |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
215 (define-key map "5" 'digit-argument) |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
216 (define-key map "4" 'digit-argument) |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
217 (define-key map "3" 'digit-argument) |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
218 (define-key map "2" 'digit-argument) |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
219 (define-key map "1" 'digit-argument) |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
220 (define-key map "0" 'digit-argument) |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
221 (define-key map "H" 'describe-mode) |
27544
4e3e1730232c
Some changes in documentation. Removed some trailing
Gerd Moellmann <gerd@gnu.org>
parents:
25219
diff
changeset
|
222 (define-key map "?" 'describe-mode) ; Maybe do as less instead? See above. |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
223 (define-key map "h" 'describe-mode) |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
224 map)) |
50786
01b16e9a75fb
(Helper-return-blurb): Add defvar. (Also rearrange defuns.)
Richard M. Stallman <rms@gnu.org>
parents:
50634
diff
changeset
|
225 |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
226 ;;; Commands that enter or exit view mode. |
44 | 227 |
79880
2be6cb49457d
Add comment before kill-buffer-if-not-modified.
Eli Zaretskii <eliz@gnu.org>
parents:
79831
diff
changeset
|
228 ;; This is used when view mode is exited, to make sure we don't try to |
2be6cb49457d
Add comment before kill-buffer-if-not-modified.
Eli Zaretskii <eliz@gnu.org>
parents:
79831
diff
changeset
|
229 ;; kill a buffer modified by the user. A buffer in view mode can |
2be6cb49457d
Add comment before kill-buffer-if-not-modified.
Eli Zaretskii <eliz@gnu.org>
parents:
79831
diff
changeset
|
230 ;; become modified if the user types C-x C-q, edits the buffer, then |
2be6cb49457d
Add comment before kill-buffer-if-not-modified.
Eli Zaretskii <eliz@gnu.org>
parents:
79831
diff
changeset
|
231 ;; types C-x C-q again to return to view mode. |
91465
3e380c491c96
(kill-buffer-if-not-modified): Add an autoload cookie.
Eli Zaretskii <eliz@gnu.org>
parents:
88038
diff
changeset
|
232 ;;;###autoload |
79831
8b17197a6be3
(view-file-other-window, view-file-other-frame): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents:
79829
diff
changeset
|
233 (defun kill-buffer-if-not-modified (buf) |
8b17197a6be3
(view-file-other-window, view-file-other-frame): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents:
79829
diff
changeset
|
234 "Like `kill-buffer', but does nothing if the buffer is modified." |
87957
eeb928a40b37
Sven Joachim <svenjoac at gmx.de>
Glenn Morris <rgm@gnu.org>
parents:
87903
diff
changeset
|
235 (let ((buf (get-buffer buf))) |
79831
8b17197a6be3
(view-file-other-window, view-file-other-frame): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents:
79829
diff
changeset
|
236 (and buf (not (buffer-modified-p buf)) |
8b17197a6be3
(view-file-other-window, view-file-other-frame): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents:
79829
diff
changeset
|
237 (kill-buffer buf)))) |
8b17197a6be3
(view-file-other-window, view-file-other-frame): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents:
79829
diff
changeset
|
238 |
256 | 239 ;;;###autoload |
27544
4e3e1730232c
Some changes in documentation. Removed some trailing
Gerd Moellmann <gerd@gnu.org>
parents:
25219
diff
changeset
|
240 (defun view-file (file) |
44 | 241 "View FILE in View mode, returning to previous buffer when done. |
86004
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
242 Emacs commands editing the buffer contents are not available; instead, a |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
243 special set of commands (mostly letters and punctuation) are defined for |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
244 moving around in the buffer. |
44 | 245 Space scrolls forward, Delete scrolls backward. |
86004
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
246 For a list of all View commands, type H or h while viewing. |
354 | 247 |
6330
3badf836d51d
(view-mode): Run view-mode-hook as well as view-hook.
Richard M. Stallman <rms@gnu.org>
parents:
5123
diff
changeset
|
248 This command runs the normal hook `view-mode-hook'." |
354 | 249 (interactive "fView file: ") |
51371
463499edca88
(view-file, view-file-other-window, view-file-other-frame):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50786
diff
changeset
|
250 (unless (file-exists-p file) (error "%s does not exist" file)) |
51848
2ec7d96e306e
(view-file): If existing buffer's major mode is special,
Richard M. Stallman <rms@gnu.org>
parents:
51371
diff
changeset
|
251 (let ((had-a-buf (get-file-buffer file)) |
2ec7d96e306e
(view-file): If existing buffer's major mode is special,
Richard M. Stallman <rms@gnu.org>
parents:
51371
diff
changeset
|
252 (buffer (find-file-noselect file))) |
107897
1721e4658521
Test for special mode-class in view-buffer instead of view-file (bug#5513).
Juri Linkov <juri@jurta.org>
parents:
107378
diff
changeset
|
253 (view-buffer buffer (and (not had-a-buf) 'kill-buffer-if-not-modified)))) |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
254 |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
255 ;;;###autoload |
27544
4e3e1730232c
Some changes in documentation. Removed some trailing
Gerd Moellmann <gerd@gnu.org>
parents:
25219
diff
changeset
|
256 (defun view-file-other-window (file) |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
257 "View FILE in View mode in another window. |
79829
9cd51e20e318
(view-file-other-window, view-file-other-frame): Don't kill the buffer if it
Eli Zaretskii <eliz@gnu.org>
parents:
79721
diff
changeset
|
258 When done, return that window to its previous buffer, and kill the |
9cd51e20e318
(view-file-other-window, view-file-other-frame): Don't kill the buffer if it
Eli Zaretskii <eliz@gnu.org>
parents:
79721
diff
changeset
|
259 buffer visiting FILE if unmodified and if it wasn't visited before. |
9cd51e20e318
(view-file-other-window, view-file-other-frame): Don't kill the buffer if it
Eli Zaretskii <eliz@gnu.org>
parents:
79721
diff
changeset
|
260 |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
261 Emacs commands editing the buffer contents are not available; instead, |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
262 a special set of commands (mostly letters and punctuation) |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
263 are defined for moving around in the buffer. |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
264 Space scrolls forward, Delete scrolls backward. |
86004
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
265 For a list of all View commands, type H or h while viewing. |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
266 |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
267 This command runs the normal hook `view-mode-hook'." |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
268 (interactive "fIn other window view file: ") |
51371
463499edca88
(view-file, view-file-other-window, view-file-other-frame):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50786
diff
changeset
|
269 (unless (file-exists-p file) (error "%s does not exist" file)) |
79829
9cd51e20e318
(view-file-other-window, view-file-other-frame): Don't kill the buffer if it
Eli Zaretskii <eliz@gnu.org>
parents:
79721
diff
changeset
|
270 (let ((had-a-buf (get-file-buffer file)) |
9cd51e20e318
(view-file-other-window, view-file-other-frame): Don't kill the buffer if it
Eli Zaretskii <eliz@gnu.org>
parents:
79721
diff
changeset
|
271 (buf-to-view (find-file-noselect file))) |
9cd51e20e318
(view-file-other-window, view-file-other-frame): Don't kill the buffer if it
Eli Zaretskii <eliz@gnu.org>
parents:
79721
diff
changeset
|
272 (view-buffer-other-window buf-to-view nil |
9cd51e20e318
(view-file-other-window, view-file-other-frame): Don't kill the buffer if it
Eli Zaretskii <eliz@gnu.org>
parents:
79721
diff
changeset
|
273 (and (not had-a-buf) |
79831
8b17197a6be3
(view-file-other-window, view-file-other-frame): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents:
79829
diff
changeset
|
274 'kill-buffer-if-not-modified)))) |
354 | 275 |
276 ;;;###autoload | |
27544
4e3e1730232c
Some changes in documentation. Removed some trailing
Gerd Moellmann <gerd@gnu.org>
parents:
25219
diff
changeset
|
277 (defun view-file-other-frame (file) |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
278 "View FILE in View mode in another frame. |
79829
9cd51e20e318
(view-file-other-window, view-file-other-frame): Don't kill the buffer if it
Eli Zaretskii <eliz@gnu.org>
parents:
79721
diff
changeset
|
279 When done, kill the buffer visiting FILE if unmodified and if it wasn't |
9cd51e20e318
(view-file-other-window, view-file-other-frame): Don't kill the buffer if it
Eli Zaretskii <eliz@gnu.org>
parents:
79721
diff
changeset
|
280 visited before; also, maybe delete other frame and/or return to previous |
9cd51e20e318
(view-file-other-window, view-file-other-frame): Don't kill the buffer if it
Eli Zaretskii <eliz@gnu.org>
parents:
79721
diff
changeset
|
281 buffer. |
9cd51e20e318
(view-file-other-window, view-file-other-frame): Don't kill the buffer if it
Eli Zaretskii <eliz@gnu.org>
parents:
79721
diff
changeset
|
282 |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
283 Emacs commands editing the buffer contents are not available; instead, |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
284 a special set of commands (mostly letters and punctuation) |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
285 are defined for moving around in the buffer. |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
286 Space scrolls forward, Delete scrolls backward. |
86004
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
287 For a list of all View commands, type H or h while viewing. |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
288 |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
289 This command runs the normal hook `view-mode-hook'." |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
290 (interactive "fIn other frame view file: ") |
51371
463499edca88
(view-file, view-file-other-window, view-file-other-frame):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50786
diff
changeset
|
291 (unless (file-exists-p file) (error "%s does not exist" file)) |
79829
9cd51e20e318
(view-file-other-window, view-file-other-frame): Don't kill the buffer if it
Eli Zaretskii <eliz@gnu.org>
parents:
79721
diff
changeset
|
292 (let ((had-a-buf (get-file-buffer file)) |
9cd51e20e318
(view-file-other-window, view-file-other-frame): Don't kill the buffer if it
Eli Zaretskii <eliz@gnu.org>
parents:
79721
diff
changeset
|
293 (buf-to-view (find-file-noselect file))) |
9cd51e20e318
(view-file-other-window, view-file-other-frame): Don't kill the buffer if it
Eli Zaretskii <eliz@gnu.org>
parents:
79721
diff
changeset
|
294 (view-buffer-other-frame buf-to-view nil |
9cd51e20e318
(view-file-other-window, view-file-other-frame): Don't kill the buffer if it
Eli Zaretskii <eliz@gnu.org>
parents:
79721
diff
changeset
|
295 (and (not had-a-buf) |
79831
8b17197a6be3
(view-file-other-window, view-file-other-frame): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents:
79829
diff
changeset
|
296 'kill-buffer-if-not-modified)))) |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
297 |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
298 |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
299 ;;;###autoload |
27544
4e3e1730232c
Some changes in documentation. Removed some trailing
Gerd Moellmann <gerd@gnu.org>
parents:
25219
diff
changeset
|
300 (defun view-buffer (buffer &optional exit-action) |
44 | 301 "View BUFFER in View mode, returning to previous buffer when done. |
86004
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
302 Emacs commands editing the buffer contents are not available; instead, a |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
303 special set of commands (mostly letters and punctuation) are defined for |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
304 moving around in the buffer. |
44 | 305 Space scrolls forward, Delete scrolls backward. |
86004
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
306 For a list of all View commands, type H or h while viewing. |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
307 |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
308 This command runs the normal hook `view-mode-hook'. |
44 | 309 |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
310 Optional argument EXIT-ACTION is either nil or a function with buffer as |
86004
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
311 argument. This function is called when finished viewing buffer. Use |
88038
e75f63aebb2b
(view-buffer): Explain in doc-string why exit-action
Martin Rudalics <rudalics@gmx.at>
parents:
87957
diff
changeset
|
312 this argument instead of explicitly setting `view-exit-action'. |
e75f63aebb2b
(view-buffer): Explain in doc-string why exit-action
Martin Rudalics <rudalics@gmx.at>
parents:
87957
diff
changeset
|
313 |
e75f63aebb2b
(view-buffer): Explain in doc-string why exit-action
Martin Rudalics <rudalics@gmx.at>
parents:
87957
diff
changeset
|
314 Do not set EXIT-ACTION to `kill-buffer' when BUFFER visits a |
e75f63aebb2b
(view-buffer): Explain in doc-string why exit-action
Martin Rudalics <rudalics@gmx.at>
parents:
87957
diff
changeset
|
315 file: Users may suspend viewing in order to modify the buffer. |
e75f63aebb2b
(view-buffer): Explain in doc-string why exit-action
Martin Rudalics <rudalics@gmx.at>
parents:
87957
diff
changeset
|
316 Exiting View mode will then discard the user's edits. Setting |
e75f63aebb2b
(view-buffer): Explain in doc-string why exit-action
Martin Rudalics <rudalics@gmx.at>
parents:
87957
diff
changeset
|
317 EXIT-ACTION to `kill-buffer-if-not-modified' avoids this." |
44 | 318 (interactive "bView buffer: ") |
107897
1721e4658521
Test for special mode-class in view-buffer instead of view-file (bug#5513).
Juri Linkov <juri@jurta.org>
parents:
107378
diff
changeset
|
319 (if (eq (with-current-buffer buffer |
1721e4658521
Test for special mode-class in view-buffer instead of view-file (bug#5513).
Juri Linkov <juri@jurta.org>
parents:
107378
diff
changeset
|
320 (get major-mode 'mode-class)) |
1721e4658521
Test for special mode-class in view-buffer instead of view-file (bug#5513).
Juri Linkov <juri@jurta.org>
parents:
107378
diff
changeset
|
321 'special) |
1721e4658521
Test for special mode-class in view-buffer instead of view-file (bug#5513).
Juri Linkov <juri@jurta.org>
parents:
107378
diff
changeset
|
322 (progn |
1721e4658521
Test for special mode-class in view-buffer instead of view-file (bug#5513).
Juri Linkov <juri@jurta.org>
parents:
107378
diff
changeset
|
323 (switch-to-buffer buffer) |
1721e4658521
Test for special mode-class in view-buffer instead of view-file (bug#5513).
Juri Linkov <juri@jurta.org>
parents:
107378
diff
changeset
|
324 (message "Not using View mode because the major mode is special")) |
1721e4658521
Test for special mode-class in view-buffer instead of view-file (bug#5513).
Juri Linkov <juri@jurta.org>
parents:
107378
diff
changeset
|
325 (let ((undo-window (list (window-buffer) (window-start) (window-point)))) |
1721e4658521
Test for special mode-class in view-buffer instead of view-file (bug#5513).
Juri Linkov <juri@jurta.org>
parents:
107378
diff
changeset
|
326 (switch-to-buffer buffer) |
1721e4658521
Test for special mode-class in view-buffer instead of view-file (bug#5513).
Juri Linkov <juri@jurta.org>
parents:
107378
diff
changeset
|
327 (view-mode-enter (cons (selected-window) (cons nil undo-window)) |
1721e4658521
Test for special mode-class in view-buffer instead of view-file (bug#5513).
Juri Linkov <juri@jurta.org>
parents:
107378
diff
changeset
|
328 exit-action)))) |
44 | 329 |
256 | 330 ;;;###autoload |
27544
4e3e1730232c
Some changes in documentation. Removed some trailing
Gerd Moellmann <gerd@gnu.org>
parents:
25219
diff
changeset
|
331 (defun view-buffer-other-window (buffer &optional not-return exit-action) |
12856 | 332 "View BUFFER in View mode in another window. |
86004
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
333 Return to previous buffer when done, unless optional NOT-RETURN is |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
334 non-nil. Emacs commands editing the buffer contents are not available; |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
335 instead, a special set of commands (mostly letters and punctuation) are |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
336 defined for moving around in the buffer. |
354 | 337 Space scrolls forward, Delete scrolls backward. |
86004
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
338 For a list of all View commands, type H or h while viewing. |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
339 |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
340 This command runs the normal hook `view-mode-hook'. |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
341 |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
342 Optional argument EXIT-ACTION is either nil or a function with buffer as |
86004
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
343 argument. This function is called when finished viewing buffer. Use |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
344 this argument instead of explicitly setting `view-exit-action'." |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
345 (interactive "bIn other window view buffer:\nP") |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
346 (let* ((win ; This window will be selected by |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
347 (get-lru-window)) ; switch-to-buffer-other-window below. |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
348 (return-to |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
349 (and (not not-return) |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
350 (cons (selected-window) |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
351 (if (eq win (selected-window)) |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
352 t ; Has to make new window. |
27544
4e3e1730232c
Some changes in documentation. Removed some trailing
Gerd Moellmann <gerd@gnu.org>
parents:
25219
diff
changeset
|
353 (list |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
354 (window-buffer win) ; Other windows old buffer. |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
355 (window-start win) |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
356 (window-point win))))))) |
27544
4e3e1730232c
Some changes in documentation. Removed some trailing
Gerd Moellmann <gerd@gnu.org>
parents:
25219
diff
changeset
|
357 (switch-to-buffer-other-window buffer) |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
358 (view-mode-enter (and return-to (cons (selected-window) return-to)) |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
359 exit-action))) |
354 | 360 |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
361 ;;;###autoload |
27544
4e3e1730232c
Some changes in documentation. Removed some trailing
Gerd Moellmann <gerd@gnu.org>
parents:
25219
diff
changeset
|
362 (defun view-buffer-other-frame (buffer &optional not-return exit-action) |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
363 "View BUFFER in View mode in another frame. |
86004
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
364 Return to previous buffer when done, unless optional NOT-RETURN is |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
365 non-nil. Emacs commands editing the buffer contents are not available; |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
366 instead, a special set of commands (mostly letters and punctuation) are |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
367 defined for moving around in the buffer. |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
368 Space scrolls forward, Delete scrolls backward. |
86004
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
369 For a list of all View commands, type H or h while viewing. |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
370 |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
371 This command runs the normal hook `view-mode-hook'. |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
372 |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
373 Optional argument EXIT-ACTION is either nil or a function with buffer as |
86004
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
374 argument. This function is called when finished viewing buffer. Use |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
375 this argument instead of explicitly setting `view-exit-action'." |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
376 (interactive "bView buffer in other frame: \nP") |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
377 (let ((return-to |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
378 (and (not not-return) (cons (selected-window) t)))) ; Old window. |
27544
4e3e1730232c
Some changes in documentation. Removed some trailing
Gerd Moellmann <gerd@gnu.org>
parents:
25219
diff
changeset
|
379 (switch-to-buffer-other-frame buffer) |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
380 (view-mode-enter (and return-to (cons (selected-window) return-to)) |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
381 exit-action))) |
50786
01b16e9a75fb
(Helper-return-blurb): Add defvar. (Also rearrange defuns.)
Richard M. Stallman <rms@gnu.org>
parents:
50634
diff
changeset
|
382 |
354 | 383 ;;;###autoload |
108220
0b37f86b040e
Use define-minor-mode where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
107897
diff
changeset
|
384 (define-minor-mode view-mode |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
385 ;; In the following documentation string we have to use some explicit key |
18250 | 386 ;; bindings instead of using the \\[] construction. The reason for this |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
387 ;; is that most commands have more than one key binding. |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
388 "Toggle View mode, a minor mode for viewing text but not editing it. |
78492
7c8949dbfa0d
Replace `iff' in doc-strings and comments.
Glenn Morris <rgm@gnu.org>
parents:
78236
diff
changeset
|
389 With prefix argument ARG, turn View mode on if ARG is positive, otherwise |
7c8949dbfa0d
Replace `iff' in doc-strings and comments.
Glenn Morris <rgm@gnu.org>
parents:
78236
diff
changeset
|
390 turn it off. |
15556 | 391 |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
392 Emacs commands that do not change the buffer contents are available as usual. |
18250 | 393 Kill commands insert text in kill buffers but do not delete. Other commands |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
394 \(among them most letters and punctuation) beep and tell that the buffer is |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
395 read-only. |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
396 \\<view-mode-map> |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
397 The following additional commands are provided. Most commands take prefix |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
398 arguments. Page commands default to \"page size\" lines which is almost a whole |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
399 window full, or number of lines set by \\[View-scroll-page-forward-set-page-size] or \\[View-scroll-page-backward-set-page-size]. Half page commands default to |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
400 and set \"half page size\" lines which initially is half a window full. Search |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
401 commands default to a repeat count of one. |
13640
ee453099e188
(view-mode, view-mode-enter): Doc changes.
Richard M. Stallman <rms@gnu.org>
parents:
13639
diff
changeset
|
402 |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
403 H, h, ? This message. |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
404 Digits provide prefix arguments. |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
405 \\[negative-argument] negative prefix argument. |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
406 \\[beginning-of-buffer] move to the beginning of buffer. |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
407 > move to the end of buffer. |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
408 \\[View-scroll-to-buffer-end] scroll so that buffer end is at last line of window. |
27544
4e3e1730232c
Some changes in documentation. Removed some trailing
Gerd Moellmann <gerd@gnu.org>
parents:
25219
diff
changeset
|
409 SPC scroll forward \"page size\" lines. |
4e3e1730232c
Some changes in documentation. Removed some trailing
Gerd Moellmann <gerd@gnu.org>
parents:
25219
diff
changeset
|
410 With prefix scroll forward prefix lines. |
4e3e1730232c
Some changes in documentation. Removed some trailing
Gerd Moellmann <gerd@gnu.org>
parents:
25219
diff
changeset
|
411 DEL scroll backward \"page size\" lines. |
4e3e1730232c
Some changes in documentation. Removed some trailing
Gerd Moellmann <gerd@gnu.org>
parents:
25219
diff
changeset
|
412 With prefix scroll backward prefix lines. |
4e3e1730232c
Some changes in documentation. Removed some trailing
Gerd Moellmann <gerd@gnu.org>
parents:
25219
diff
changeset
|
413 \\[View-scroll-page-forward-set-page-size] like \\[View-scroll-page-forward] but with prefix sets \"page size\" to prefix. |
4e3e1730232c
Some changes in documentation. Removed some trailing
Gerd Moellmann <gerd@gnu.org>
parents:
25219
diff
changeset
|
414 \\[View-scroll-page-backward-set-page-size] like \\[View-scroll-page-backward] but with prefix sets \"page size\" to prefix. |
4e3e1730232c
Some changes in documentation. Removed some trailing
Gerd Moellmann <gerd@gnu.org>
parents:
25219
diff
changeset
|
415 \\[View-scroll-half-page-forward] scroll forward \"half page size\" lines. With prefix, sets |
4e3e1730232c
Some changes in documentation. Removed some trailing
Gerd Moellmann <gerd@gnu.org>
parents:
25219
diff
changeset
|
416 \"half page size\" to prefix lines and scrolls forward that much. |
4e3e1730232c
Some changes in documentation. Removed some trailing
Gerd Moellmann <gerd@gnu.org>
parents:
25219
diff
changeset
|
417 \\[View-scroll-half-page-backward] scroll backward \"half page size\" lines. With prefix, sets |
4e3e1730232c
Some changes in documentation. Removed some trailing
Gerd Moellmann <gerd@gnu.org>
parents:
25219
diff
changeset
|
418 \"half page size\" to prefix lines and scrolls backward that much. |
4e3e1730232c
Some changes in documentation. Removed some trailing
Gerd Moellmann <gerd@gnu.org>
parents:
25219
diff
changeset
|
419 RET, LFD scroll forward one line. With prefix scroll forward prefix line(s). |
4e3e1730232c
Some changes in documentation. Removed some trailing
Gerd Moellmann <gerd@gnu.org>
parents:
25219
diff
changeset
|
420 y scroll backward one line. With prefix scroll backward prefix line(s). |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
421 \\[View-revert-buffer-scroll-page-forward] revert-buffer if necessary and scroll forward. |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
422 Use this to view a changing file. |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
423 \\[what-line] prints the current line number. |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
424 \\[View-goto-percent] goes prefix argument (default 100) percent into buffer. |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
425 \\[View-goto-line] goes to line given by prefix argument (default first line). |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
426 . set the mark. |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
427 x exchanges point and mark. |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
428 \\[View-back-to-mark] return to mark and pops mark ring. |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
429 Mark ring is pushed at start of every successful search and when |
18250 | 430 jump to line occurs. The mark is set on jump to buffer start or end. |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
431 \\[point-to-register] save current position in character register. |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
432 ' go to position saved in character register. |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
433 s do forward incremental search. |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
434 r do reverse incremental search. |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
435 \\[View-search-regexp-forward] searches forward for regular expression, starting after current page. |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
436 ! and @ have a special meaning at the beginning of the regexp. |
18250 | 437 ! means search for a line with no match for regexp. @ means start |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
438 search at beginning (end for backward search) of buffer. |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
439 \\ searches backward for regular expression, starting before current page. |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
440 \\[View-search-last-regexp-forward] searches forward for last regular expression. |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
441 p searches backward for last regular expression. |
49439 | 442 \\[View-quit] quit View mode, restoring this window and buffer to previous state. |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
443 \\[View-quit] is the normal way to leave view mode. |
18250 | 444 \\[View-exit] exit View mode but stay in current buffer. Use this if you started |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
445 viewing a buffer (file) and find out you want to edit it. |
49439 | 446 This command restores the previous read-only status of the buffer. |
447 \\[View-exit-and-edit] exit View mode, and make the current buffer editable | |
448 even if it was not editable before entry to View mode. | |
449 \\[View-quit-all] quit View mode, restoring all windows to previous state. | |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
450 \\[View-leave] quit View mode and maybe switch buffers, but don't kill this buffer. |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
451 \\[View-kill-and-leave] quit View mode, kill current buffer and go back to other buffer. |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
452 |
76780
7a9103325d0f
(view-mode): Fix typos in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
75347
diff
changeset
|
453 The effect of \\[View-leave], \\[View-quit] and \\[View-kill-and-leave] depends on how view-mode was entered. If it was |
67287 | 454 entered by view-file, view-file-other-window, view-file-other-frame, or |
455 \\[dired-view-file] \(\\[view-file], \\[view-file-other-window], | |
456 \\[view-file-other-frame], or the Dired mode v command), | |
457 then \\[View-quit] will try to kill the current buffer. | |
458 If view-mode was entered from another buffer, by \\[view-buffer], | |
459 \\[view-buffer-other-window], \\[view-buffer-other frame], \\[view-file], | |
460 \\[view-file-other-window], or \\[view-file-other-frame], | |
76780
7a9103325d0f
(view-mode): Fix typos in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
75347
diff
changeset
|
461 then \\[View-leave], \\[View-quit] and \\[View-kill-and-leave] will return to that buffer. |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
462 |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
463 Entry to view-mode runs the normal hook `view-mode-hook'." |
108220
0b37f86b040e
Use define-minor-mode where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
107897
diff
changeset
|
464 :lighter " View" :keymap view-mode-map |
0b37f86b040e
Use define-minor-mode where applicable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
107897
diff
changeset
|
465 (if view-mode (view-mode-enable) (view-mode-disable))) |
50786
01b16e9a75fb
(Helper-return-blurb): Add defvar. (Also rearrange defuns.)
Richard M. Stallman <rms@gnu.org>
parents:
50634
diff
changeset
|
466 |
18250 | 467 (defun view-mode-enable () |
468 "Turn on View mode." | |
18268
a42f063f003b
Don't globally add to change-major-mode-hook.
Richard M. Stallman <rms@gnu.org>
parents:
18250
diff
changeset
|
469 ;; Always leave view mode before changing major mode. |
a42f063f003b
Don't globally add to change-major-mode-hook.
Richard M. Stallman <rms@gnu.org>
parents:
18250
diff
changeset
|
470 ;; This is to guarantee that the buffer-read-only variable is restored. |
a42f063f003b
Don't globally add to change-major-mode-hook.
Richard M. Stallman <rms@gnu.org>
parents:
18250
diff
changeset
|
471 (add-hook 'change-major-mode-hook 'view-mode-disable nil t) |
18250 | 472 (setq view-mode t |
57521
3ac03a07be63
(view-mode-enable): Set view-page-size and view-half-page-size to nil.
Richard M. Stallman <rms@gnu.org>
parents:
55014
diff
changeset
|
473 view-page-size nil |
3ac03a07be63
(view-mode-enable): Set view-page-size and view-half-page-size to nil.
Richard M. Stallman <rms@gnu.org>
parents:
55014
diff
changeset
|
474 view-half-page-size nil |
18250 | 475 view-old-buffer-read-only buffer-read-only |
104076
5a8c46298f5a
* view.el (view-mode-enable): Don't define Helper-return-blurb if
Chong Yidong <cyd@stupidchicken.com>
parents:
103297
diff
changeset
|
476 buffer-read-only t) |
5a8c46298f5a
* view.el (view-mode-enable): Don't define Helper-return-blurb if
Chong Yidong <cyd@stupidchicken.com>
parents:
103297
diff
changeset
|
477 (if (boundp 'Helper-return-blurb) |
5a8c46298f5a
* view.el (view-mode-enable): Don't define Helper-return-blurb if
Chong Yidong <cyd@stupidchicken.com>
parents:
103297
diff
changeset
|
478 (setq view-old-Helper-return-blurb (and (boundp 'Helper-return-blurb) |
5a8c46298f5a
* view.el (view-mode-enable): Don't define Helper-return-blurb if
Chong Yidong <cyd@stupidchicken.com>
parents:
103297
diff
changeset
|
479 Helper-return-blurb) |
5a8c46298f5a
* view.el (view-mode-enable): Don't define Helper-return-blurb if
Chong Yidong <cyd@stupidchicken.com>
parents:
103297
diff
changeset
|
480 Helper-return-blurb |
5a8c46298f5a
* view.el (view-mode-enable): Don't define Helper-return-blurb if
Chong Yidong <cyd@stupidchicken.com>
parents:
103297
diff
changeset
|
481 (format "continue viewing %s" |
5a8c46298f5a
* view.el (view-mode-enable): Don't define Helper-return-blurb if
Chong Yidong <cyd@stupidchicken.com>
parents:
103297
diff
changeset
|
482 (if (buffer-file-name) |
5a8c46298f5a
* view.el (view-mode-enable): Don't define Helper-return-blurb if
Chong Yidong <cyd@stupidchicken.com>
parents:
103297
diff
changeset
|
483 (file-name-nondirectory (buffer-file-name)) |
5a8c46298f5a
* view.el (view-mode-enable): Don't define Helper-return-blurb if
Chong Yidong <cyd@stupidchicken.com>
parents:
103297
diff
changeset
|
484 (buffer-name))))) |
25218
9c0733c601c9
(view-mode-enable, view-mode-disable):
Karl Heuer <kwzh@gnu.org>
parents:
23987
diff
changeset
|
485 (force-mode-line-update) |
18250 | 486 (run-hooks 'view-mode-hook)) |
487 | |
488 (defun view-mode-disable () | |
489 "Turn off View mode." | |
18268
a42f063f003b
Don't globally add to change-major-mode-hook.
Richard M. Stallman <rms@gnu.org>
parents:
18250
diff
changeset
|
490 (remove-hook 'change-major-mode-hook 'view-mode-disable t) |
18250 | 491 (and view-overlay (delete-overlay view-overlay)) |
25218
9c0733c601c9
(view-mode-enable, view-mode-disable):
Karl Heuer <kwzh@gnu.org>
parents:
23987
diff
changeset
|
492 (force-mode-line-update) |
28198
1ea4cf592264
(view-mode-disable): Kill local binding of view-read-only.
Richard M. Stallman <rms@gnu.org>
parents:
27544
diff
changeset
|
493 ;; Calling toggle-read-only while View mode is enabled |
1ea4cf592264
(view-mode-disable): Kill local binding of view-read-only.
Richard M. Stallman <rms@gnu.org>
parents:
27544
diff
changeset
|
494 ;; sets view-read-only to t as a buffer-local variable |
1ea4cf592264
(view-mode-disable): Kill local binding of view-read-only.
Richard M. Stallman <rms@gnu.org>
parents:
27544
diff
changeset
|
495 ;; after exiting View mode. That arranges that the next toggle-read-only |
1ea4cf592264
(view-mode-disable): Kill local binding of view-read-only.
Richard M. Stallman <rms@gnu.org>
parents:
27544
diff
changeset
|
496 ;; will reenable View mode. |
1ea4cf592264
(view-mode-disable): Kill local binding of view-read-only.
Richard M. Stallman <rms@gnu.org>
parents:
27544
diff
changeset
|
497 ;; Cancelling View mode in any other way should cancel that, too, |
1ea4cf592264
(view-mode-disable): Kill local binding of view-read-only.
Richard M. Stallman <rms@gnu.org>
parents:
27544
diff
changeset
|
498 ;; so that View mode stays off if toggle-read-only is called. |
1ea4cf592264
(view-mode-disable): Kill local binding of view-read-only.
Richard M. Stallman <rms@gnu.org>
parents:
27544
diff
changeset
|
499 (if (local-variable-p 'view-read-only) |
1ea4cf592264
(view-mode-disable): Kill local binding of view-read-only.
Richard M. Stallman <rms@gnu.org>
parents:
27544
diff
changeset
|
500 (kill-local-variable 'view-read-only)) |
104076
5a8c46298f5a
* view.el (view-mode-enable): Don't define Helper-return-blurb if
Chong Yidong <cyd@stupidchicken.com>
parents:
103297
diff
changeset
|
501 (setq view-mode nil) |
5a8c46298f5a
* view.el (view-mode-enable): Don't define Helper-return-blurb if
Chong Yidong <cyd@stupidchicken.com>
parents:
103297
diff
changeset
|
502 (if (boundp 'Helper-return-blurb) |
5a8c46298f5a
* view.el (view-mode-enable): Don't define Helper-return-blurb if
Chong Yidong <cyd@stupidchicken.com>
parents:
103297
diff
changeset
|
503 (setq Helper-return-blurb view-old-Helper-return-blurb)) |
25219
1b99ab7ab219
(view-mode-disable): If buffer-read-only is nil,
Karl Heuer <kwzh@gnu.org>
parents:
25218
diff
changeset
|
504 (if buffer-read-only |
1b99ab7ab219
(view-mode-disable): If buffer-read-only is nil,
Karl Heuer <kwzh@gnu.org>
parents:
25218
diff
changeset
|
505 (setq buffer-read-only view-old-buffer-read-only))) |
13640
ee453099e188
(view-mode, view-mode-enter): Doc changes.
Richard M. Stallman <rms@gnu.org>
parents:
13639
diff
changeset
|
506 |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
507 ;;;###autoload |
86004
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
508 (defun view-return-to-alist-update (buffer &optional item) |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
509 "Update `view-return-to-alist' of buffer BUFFER. |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
510 Remove from `view-return-to-alist' all entries referencing dead |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
511 windows. Optional argument ITEM non-nil means add ITEM to |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
512 `view-return-to-alist' after purging. For a decsription of items |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
513 that can be added see the RETURN-TO-ALIST argument of the |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
514 function `view-mode-exit'. If `view-return-to-alist' contains an |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
515 entry for the selected window, purge that entry from |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
516 `view-return-to-alist' before adding ITEM." |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
517 (with-current-buffer buffer |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
518 (when view-return-to-alist |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
519 (let* ((list view-return-to-alist) |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
520 entry entry-window last) |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
521 (while list |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
522 (setq entry (car list)) |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
523 (setq entry-window (car entry)) |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
524 (if (and (windowp entry-window) |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
525 (or (and item (eq entry-window (selected-window))) |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
526 (not (window-live-p entry-window)))) |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
527 ;; Remove that entry. |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
528 (if last |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
529 (setcdr last (cdr list)) |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
530 (setq view-return-to-alist |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
531 (cdr view-return-to-alist))) |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
532 ;; Leave entry alone. |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
533 (setq last entry)) |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
534 (setq list (cdr list))))) |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
535 ;; Add ITEM. |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
536 (when item |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
537 (setq view-return-to-alist |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
538 (cons item view-return-to-alist))))) |
18250 | 539 |
86004
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
540 ;;;###autoload |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
541 (defun view-mode-enter (&optional return-to exit-action) |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
542 "Enter View mode and set up exit from view mode depending on optional arguments. |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
543 RETURN-TO non-nil means add RETURN-TO as an element to the buffer |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
544 local alist `view-return-to-alist'. Save EXIT-ACTION in buffer |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
545 local variable `view-exit-action'. It should be either nil or a |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
546 function that takes a buffer as argument. This function will be |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
547 called by `view-mode-exit'. |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
548 |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
549 RETURN-TO is either nil, meaning do nothing when exiting view |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
550 mode, or must have the format (WINDOW OLD-WINDOW . OLD-BUF-INFO). |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
551 WINDOW is the window used for viewing. OLD-WINDOW is nil or the |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
552 window to select after viewing. OLD-BUF-INFO tells what to do |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
553 with WINDOW when exiting. It is one of: |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
554 1) nil Do nothing. |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
555 2) t Delete WINDOW or, if it is the only window and |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
556 `view-remove-frame-by-deleting' is non-nil, its |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
557 frame. |
18250 | 558 3) (OLD-BUFF START POINT) Display buffer OLD-BUFF with displayed text |
86004
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
559 starting at START and point at POINT in WINDOW. |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
560 4) quit-window Do `quit-window' in WINDOW. |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
561 5) keep-frame Like case 2) but do not delete the frame. |
44 | 562 |
86004
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
563 For a list of all View commands, type H or h while viewing. |
4119
7b1b2a8d05f2
Doc fixes; some args renamed.
Richard M. Stallman <rms@gnu.org>
parents:
3450
diff
changeset
|
564 |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
565 This function runs the normal hook `view-mode-hook'." |
86004
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
566 (when return-to |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
567 (let ((entry (assq (car return-to) view-return-to-alist))) |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
568 (if entry |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
569 (setcdr entry (cdr return-to)) |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
570 (setq view-return-to-alist (cons return-to view-return-to-alist))))) |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
571 (when exit-action |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
572 (setq view-exit-action exit-action)) |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
573 |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
574 (unless view-mode |
18250 | 575 (view-mode-enable) |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
576 (force-mode-line-update) |
67203
78e1225a40a2
(view-inhibit-help-message): New defcustom.
Romain Francoise <romain@orebokech.com>
parents:
66488
diff
changeset
|
577 (unless view-inhibit-help-message |
78e1225a40a2
(view-inhibit-help-message): New defcustom.
Romain Francoise <romain@orebokech.com>
parents:
66488
diff
changeset
|
578 (message "%s" |
78e1225a40a2
(view-inhibit-help-message): New defcustom.
Romain Francoise <romain@orebokech.com>
parents:
66488
diff
changeset
|
579 (substitute-command-keys "\ |
78e1225a40a2
(view-inhibit-help-message): New defcustom.
Romain Francoise <romain@orebokech.com>
parents:
66488
diff
changeset
|
580 View mode: type \\[help-command] for help, \\[describe-mode] for commands, \\[View-quit] to quit."))))) |
50786
01b16e9a75fb
(Helper-return-blurb): Add defvar. (Also rearrange defuns.)
Richard M. Stallman <rms@gnu.org>
parents:
50634
diff
changeset
|
581 |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
582 (defun view-mode-exit (&optional return-to-alist exit-action all-win) |
21772
95df64150c8a
(view-mode-exit): Don't alter view-return-to-alist.
Richard M. Stallman <rms@gnu.org>
parents:
21678
diff
changeset
|
583 "Exit View mode in various ways, depending on optional arguments. |
86004
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
584 RETURN-TO-ALIST, EXIT-ACTION and ALL-WIN determine what to do |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
585 after exit. EXIT-ACTION is nil or a function that is called with |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
586 current buffer as argument. |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
587 |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
588 RETURN-TO-ALIST is an alist that, for some of the windows |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
589 displaying the current buffer, maintains information on what to |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
590 do when exiting those windows. If ALL-WIN is non-nil or the |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
591 variable `view-exits-all-viewing-windows' is non-nil, |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
592 view-mode-exit attempts to restore all windows showing the |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
593 current buffer to their old state. Otherwise, only the selected |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
594 window is affected (provided it is on RETURN-TO-ALIST). |
18448
7cf9cdba062d
Changed some documentation.
Richard M. Stallman <rms@gnu.org>
parents:
18335
diff
changeset
|
595 |
86004
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
596 Elements of RETURN-TO-ALIST must have the format |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
597 (WINDOW OLD-WINDOW . OLD-BUF-INFO) where |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
598 |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
599 WINDOW is a window displaying the current buffer and OLD-WINDOW |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
600 is either nil or a window to select after viewing. OLD-BUF-INFO |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
601 provides information on what to do with WINDOW and may be one of: |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
602 1) nil Do nothing. |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
603 2) t Delete WINDOW and, if it is the only window and |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
604 `view-remove-frame-by-deleting' is non-nil, its |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
605 frame. |
18250 | 606 3) (OLD-BUF START POINT) Display buffer OLD-BUF with displayed text |
86004
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
607 starting at START and point at POINT in WINDOW. |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
608 4) quit-window Do `quit-window' in WINDOW. |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
609 5) keep-frame Like case 2) but do not delete the frame. |
18448
7cf9cdba062d
Changed some documentation.
Richard M. Stallman <rms@gnu.org>
parents:
18335
diff
changeset
|
610 |
86004
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
611 If one of the WINDOW in RETURN-TO-ALIST is the selected window |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
612 and the corresponding OLD-WINDOW is a live window, then select |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
613 OLD-WINDOW." |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
614 (when view-mode ; Only do something if in view mode. |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
615 (setq all-win |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
616 (and return-to-alist |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
617 (or all-win view-exits-all-viewing-windows))) |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
618 (let* ((buffer (current-buffer)) |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
619 window notlost |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
620 (sel-old (assq (selected-window) return-to-alist)) |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
621 (alist (cond |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
622 (all-win ; Try to restore all windows. |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
623 (append return-to-alist nil)) ; Copy. |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
624 (sel-old ; Only selected window. |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
625 (list sel-old)))) |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
626 (old-window (if sel-old (car (cdr sel-old))))) |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
627 (if all-win ; Follow chains of old-windows. |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
628 (let ((c (length alist)) a) |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
629 (while (and (> c 0) ; Safety if mutually refering windows. |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
630 (or (not (window-live-p old-window)) |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
631 (eq buffer (window-buffer old-window))) |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
632 (setq a (assq old-window alist))) |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
633 (setq c (1- c)) |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
634 (setq old-window (car (cdr a)))) |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
635 (if (or (zerop c) (not (window-live-p old-window))) |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
636 (setq old-window (selected-window))))) |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
637 (unless view-no-disable-on-exit |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
638 (view-mode-disable)) |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
639 (while alist ; Restore windows with info. |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
640 (setq notlost nil) |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
641 (when (and (window-live-p (setq window (car (car alist)))) |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
642 (eq buffer (window-buffer window))) |
86004
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
643 (let ((frame (window-frame window)) |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
644 (old-buf-info (cdr (cdr (car alist))))) |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
645 (if all-win (select-window window)) |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
646 (cond |
105822
59656f4a5cda
(view-mode-exit): If OLD-BUF is dead bury the buffer
Andreas Schwab <schwab@linux-m68k.org>
parents:
105170
diff
changeset
|
647 ((consp old-buf-info) ; Case 3. |
59656f4a5cda
(view-mode-exit): If OLD-BUF is dead bury the buffer
Andreas Schwab <schwab@linux-m68k.org>
parents:
105170
diff
changeset
|
648 (if (buffer-live-p (car old-buf-info)) |
59656f4a5cda
(view-mode-exit): If OLD-BUF is dead bury the buffer
Andreas Schwab <schwab@linux-m68k.org>
parents:
105170
diff
changeset
|
649 (progn |
59656f4a5cda
(view-mode-exit): If OLD-BUF is dead bury the buffer
Andreas Schwab <schwab@linux-m68k.org>
parents:
105170
diff
changeset
|
650 (set-window-buffer window (car old-buf-info)) ; old-buf |
59656f4a5cda
(view-mode-exit): If OLD-BUF is dead bury the buffer
Andreas Schwab <schwab@linux-m68k.org>
parents:
105170
diff
changeset
|
651 (set-window-start window (car (cdr old-buf-info))) |
59656f4a5cda
(view-mode-exit): If OLD-BUF is dead bury the buffer
Andreas Schwab <schwab@linux-m68k.org>
parents:
105170
diff
changeset
|
652 (set-window-point window (car (cdr (cdr old-buf-info))))) |
59656f4a5cda
(view-mode-exit): If OLD-BUF is dead bury the buffer
Andreas Schwab <schwab@linux-m68k.org>
parents:
105170
diff
changeset
|
653 (bury-buffer))) |
86004
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
654 ((eq old-buf-info 'quit-window) |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
655 (quit-window)) ; Case 4. |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
656 (old-buf-info ; Case 2 or 5. |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
657 (cond |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
658 ((not (one-window-p t)) ; Not only window. |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
659 (delete-window)) |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
660 ((eq old-buf-info 'keep-frame) ; Case 5. |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
661 (bury-buffer)) |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
662 ((not (eq frame (next-frame))) ; Case 2 and only window. |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
663 ;; Not the only frame, so can safely be removed. |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
664 (if view-remove-frame-by-deleting |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
665 (delete-frame frame) |
105170 | 666 (setq notlost t) ; Keep the window. See below. |
86004
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
667 (iconify-frame frame)))))))) |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
668 ;; If a frame is removed by iconifying it, the window is not |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
669 ;; really lost. In this case we keep the entry in |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
670 ;; `view-return-to-alist' so that if the user deiconifies the |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
671 ;; frame and then hits q, the frame is iconified again. |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
672 (unless notlost |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
673 (with-current-buffer buffer |
27544
4e3e1730232c
Some changes in documentation. Removed some trailing
Gerd Moellmann <gerd@gnu.org>
parents:
25219
diff
changeset
|
674 (setq view-return-to-alist |
86004
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
675 (delete (car alist) view-return-to-alist)))) |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
676 (setq alist (cdr alist))) |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
677 (when (window-live-p old-window) |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
678 ;; old-window is still alive => select it. |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
679 (select-window old-window)) |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
680 (when exit-action |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
681 ;; Don't do that: If the user wants to quit the *Help* buffer a |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
682 ;; second time it won't have any effect. |
96229
f0fef621a168
Fix up comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
683 ;;(setq view-exit-action nil) |
86004
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
684 (funcall exit-action buffer)) |
7c2160a058cb
(view-remove-frame-by-deleting): Change default value to t.
Martin Rudalics <rudalics@gmx.at>
parents:
78893
diff
changeset
|
685 (force-mode-line-update)))) |
50786
01b16e9a75fb
(Helper-return-blurb): Add defvar. (Also rearrange defuns.)
Richard M. Stallman <rms@gnu.org>
parents:
50634
diff
changeset
|
686 |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
687 (defun View-exit () |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
688 "Exit View mode but stay in current buffer." |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
689 (interactive) |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
690 (view-mode-exit)) |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
691 |
18335
6f48844ce1a9
(view-mode): Add autoload cookie to this variable.
Kenichi Handa <handa@m17n.org>
parents:
18271
diff
changeset
|
692 ;;;###autoload |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
693 (defun View-exit-and-edit () |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
694 "Exit View mode and make the current buffer editable." |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
695 (interactive) |
22337
ce89ab9c000e
(View-exit-and-edit): Bind view-no-disable-on-exit to nil.
Karl Heuer <kwzh@gnu.org>
parents:
21772
diff
changeset
|
696 (let ((view-old-buffer-read-only nil) |
ce89ab9c000e
(View-exit-and-edit): Bind view-no-disable-on-exit to nil.
Karl Heuer <kwzh@gnu.org>
parents:
21772
diff
changeset
|
697 (view-no-disable-on-exit nil)) |
18448
7cf9cdba062d
Changed some documentation.
Richard M. Stallman <rms@gnu.org>
parents:
18335
diff
changeset
|
698 (view-mode-exit))) |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
699 |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
700 (defun View-leave () |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
701 "Quit View mode and maybe switch buffers, but don't kill this buffer." |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
702 (interactive) |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
703 (view-mode-exit view-return-to-alist)) |
44 | 704 |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
705 (defun View-quit () |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
706 "Quit View mode, trying to restore window and buffer to previous state. |
18250 | 707 Maybe kill this buffer. Try to restore selected window to previous state |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
708 and go to previous buffer or window." |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
709 (interactive) |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
710 (view-mode-exit view-return-to-alist view-exit-action)) |
44 | 711 |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
712 (defun View-quit-all () |
18250 | 713 "Quit View mode, trying to restore windows and buffers to previous state. |
714 Maybe kill current buffer. Try to restore all windows viewing buffer to | |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
715 previous state and go to previous buffer or window." |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
716 (interactive) |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
717 (view-mode-exit view-return-to-alist view-exit-action t)) |
44 | 718 |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
719 (defun View-kill-and-leave () |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
720 "Quit View mode, kill current buffer and return to previous buffer." |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
721 (interactive) |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
722 (view-mode-exit view-return-to-alist (or view-exit-action 'kill-buffer) t)) |
50786
01b16e9a75fb
(Helper-return-blurb): Add defvar. (Also rearrange defuns.)
Richard M. Stallman <rms@gnu.org>
parents:
50634
diff
changeset
|
723 |
44 | 724 |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
725 ;;; Some help routines. |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
726 |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
727 (defun view-window-size () |
103297
1120e729d920
* view.el (view-window-size): Use window-line-height to find window height.
Chong Yidong <cyd@stupidchicken.com>
parents:
103295
diff
changeset
|
728 ;; Return the height of the current window, excluding the mode line. |
1120e729d920
* view.el (view-window-size): Use window-line-height to find window height.
Chong Yidong <cyd@stupidchicken.com>
parents:
103295
diff
changeset
|
729 ;; Using `window-line-height' accounts for variable-height fonts. |
1120e729d920
* view.el (view-window-size): Use window-line-height to find window height.
Chong Yidong <cyd@stupidchicken.com>
parents:
103295
diff
changeset
|
730 (let ((h (window-line-height -1))) |
1120e729d920
* view.el (view-window-size): Use window-line-height to find window height.
Chong Yidong <cyd@stupidchicken.com>
parents:
103295
diff
changeset
|
731 (if h |
1120e729d920
* view.el (view-window-size): Use window-line-height to find window height.
Chong Yidong <cyd@stupidchicken.com>
parents:
103295
diff
changeset
|
732 (1+ (nth 1 h)) |
1120e729d920
* view.el (view-window-size): Use window-line-height to find window height.
Chong Yidong <cyd@stupidchicken.com>
parents:
103295
diff
changeset
|
733 ;; This should not happen, but if `window-line-height' returns |
1120e729d920
* view.el (view-window-size): Use window-line-height to find window height.
Chong Yidong <cyd@stupidchicken.com>
parents:
103295
diff
changeset
|
734 ;; nil, fall back on `window-height'. |
1120e729d920
* view.el (view-window-size): Use window-line-height to find window height.
Chong Yidong <cyd@stupidchicken.com>
parents:
103295
diff
changeset
|
735 (1- (window-height))))) |
6330
3badf836d51d
(view-mode): Run view-mode-hook as well as view-hook.
Richard M. Stallman <rms@gnu.org>
parents:
5123
diff
changeset
|
736 |
96229
f0fef621a168
Fix up comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
737 ;; (defun view-last-command (&optional who what) |
f0fef621a168
Fix up comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
738 ;; (setq view-last-command-entry this-command) |
f0fef621a168
Fix up comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
739 ;; (setq view-last-command who) |
f0fef621a168
Fix up comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
740 ;; (setq view-last-command-argument what)) |
44 | 741 |
96229
f0fef621a168
Fix up comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
742 ;; (defun View-repeat-last-command () |
f0fef621a168
Fix up comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
743 ;; "Repeat last command issued in View mode." |
f0fef621a168
Fix up comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
744 ;; (interactive) |
f0fef621a168
Fix up comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
745 ;; (if (and view-last-command |
f0fef621a168
Fix up comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
746 ;; (eq view-last-command-entry last-command)) |
f0fef621a168
Fix up comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
747 ;; (funcall view-last-command view-last-command-argument)) |
f0fef621a168
Fix up comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
748 ;; (setq this-command view-last-command-entry)) |
44 | 749 |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
750 (defun view-recenter () |
103295
578359a0fca6
* view.el (view-recenter): Allow recenter to compute window height
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
751 ;; Recenter point in window and redisplay normally. |
578359a0fca6
* view.el (view-recenter): Allow recenter to compute window height
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
752 (recenter '(1))) |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
753 |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
754 (defun view-page-size-default (lines) |
103297
1120e729d920
* view.el (view-window-size): Use window-line-height to find window height.
Chong Yidong <cyd@stupidchicken.com>
parents:
103295
diff
changeset
|
755 ;; If LINES is nil, 0, or larger than `view-window-size', return nil. |
1120e729d920
* view.el (view-window-size): Use window-line-height to find window height.
Chong Yidong <cyd@stupidchicken.com>
parents:
103295
diff
changeset
|
756 ;; Otherwise, return LINES. |
1120e729d920
* view.el (view-window-size): Use window-line-height to find window height.
Chong Yidong <cyd@stupidchicken.com>
parents:
103295
diff
changeset
|
757 (and lines |
1120e729d920
* view.el (view-window-size): Use window-line-height to find window height.
Chong Yidong <cyd@stupidchicken.com>
parents:
103295
diff
changeset
|
758 (not (zerop (setq lines (prefix-numeric-value lines)))) |
1120e729d920
* view.el (view-window-size): Use window-line-height to find window height.
Chong Yidong <cyd@stupidchicken.com>
parents:
103295
diff
changeset
|
759 (<= (abs lines) |
1120e729d920
* view.el (view-window-size): Use window-line-height to find window height.
Chong Yidong <cyd@stupidchicken.com>
parents:
103295
diff
changeset
|
760 (abs (- (view-window-size) next-screen-context-lines))) |
1120e729d920
* view.el (view-window-size): Use window-line-height to find window height.
Chong Yidong <cyd@stupidchicken.com>
parents:
103295
diff
changeset
|
761 (abs lines))) |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
762 |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
763 (defun view-set-half-page-size-default (lines) |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
764 ;; Get and maybe set half page size. |
57521
3ac03a07be63
(view-mode-enable): Set view-page-size and view-half-page-size to nil.
Richard M. Stallman <rms@gnu.org>
parents:
55014
diff
changeset
|
765 (if (not lines) (or view-half-page-size |
3ac03a07be63
(view-mode-enable): Set view-page-size and view-half-page-size to nil.
Richard M. Stallman <rms@gnu.org>
parents:
55014
diff
changeset
|
766 (/ (view-window-size) 2)) |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
767 (setq view-half-page-size |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
768 (if (zerop (setq lines (prefix-numeric-value lines))) |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
769 (/ (view-window-size) 2) |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
770 (view-page-size-default lines))))) |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
771 |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
772 |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
773 ;;; Commands for moving around in the buffer. |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
774 |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
775 (defun View-goto-percent (&optional percent) |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
776 "Move to end (or prefix PERCENT) of buffer in View mode. |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
777 Display is centered at point. |
18250 | 778 Also set the mark at the position where point was." |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
779 (interactive "P") |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
780 (push-mark) |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
781 (goto-char |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
782 (if percent |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
783 (+ (point-min) |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
784 (floor (* (- (point-max) (point-min)) 0.01 |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
785 (max 0 (min 100 (prefix-numeric-value percent)))))) |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
786 (point-max))) |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
787 (view-recenter)) |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
788 |
96229
f0fef621a168
Fix up comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
789 ;; (defun View-goto-line-last (&optional line) |
f0fef621a168
Fix up comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
790 ;; "Move to last (or prefix LINE) line in View mode. |
f0fef621a168
Fix up comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
791 ;; Display is centered at LINE. |
f0fef621a168
Fix up comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
792 ;; Sets mark at starting position and pushes mark ring." |
f0fef621a168
Fix up comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
793 ;; (interactive "P") |
f0fef621a168
Fix up comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
794 ;; (push-mark) |
f0fef621a168
Fix up comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
795 ;; (if line (goto-line (prefix-numeric-value line)) |
f0fef621a168
Fix up comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
796 ;; (goto-char (point-max)) |
f0fef621a168
Fix up comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
797 ;; (beginning-of-line)) |
f0fef621a168
Fix up comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
798 ;; (view-recenter)) |
49597
e88404e8f2cf
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49439
diff
changeset
|
799 |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
800 (defun View-goto-line (&optional line) |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
801 "Move to first (or prefix LINE) line in View mode. |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
802 Display is centered at LINE. |
18250 | 803 Also set the mark at the position where point was." |
44 | 804 (interactive "p") |
805 (push-mark) | |
104543
da8b3e61b182
Use forward-line rather than goto-line.
Glenn Morris <rgm@gnu.org>
parents:
104076
diff
changeset
|
806 (goto-char (point-min)) |
da8b3e61b182
Use forward-line rather than goto-line.
Glenn Morris <rgm@gnu.org>
parents:
104076
diff
changeset
|
807 (forward-line (1- line)) |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
808 (view-recenter)) |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
809 |
50786
01b16e9a75fb
(Helper-return-blurb): Add defvar. (Also rearrange defuns.)
Richard M. Stallman <rms@gnu.org>
parents:
50634
diff
changeset
|
810 (defun View-back-to-mark (&optional ignore) |
01b16e9a75fb
(Helper-return-blurb): Add defvar. (Also rearrange defuns.)
Richard M. Stallman <rms@gnu.org>
parents:
50634
diff
changeset
|
811 "Return to last mark set in View mode, else beginning of file. |
01b16e9a75fb
(Helper-return-blurb): Add defvar. (Also rearrange defuns.)
Richard M. Stallman <rms@gnu.org>
parents:
50634
diff
changeset
|
812 Display that line at the center of the window. |
01b16e9a75fb
(Helper-return-blurb): Add defvar. (Also rearrange defuns.)
Richard M. Stallman <rms@gnu.org>
parents:
50634
diff
changeset
|
813 This command pops the mark ring, so that successive |
01b16e9a75fb
(Helper-return-blurb): Add defvar. (Also rearrange defuns.)
Richard M. Stallman <rms@gnu.org>
parents:
50634
diff
changeset
|
814 invocations return to earlier marks." |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
815 (interactive) |
50786
01b16e9a75fb
(Helper-return-blurb): Add defvar. (Also rearrange defuns.)
Richard M. Stallman <rms@gnu.org>
parents:
50634
diff
changeset
|
816 (goto-char (or (mark t) (point-min))) |
01b16e9a75fb
(Helper-return-blurb): Add defvar. (Also rearrange defuns.)
Richard M. Stallman <rms@gnu.org>
parents:
50634
diff
changeset
|
817 (pop-mark) |
01b16e9a75fb
(Helper-return-blurb): Add defvar. (Also rearrange defuns.)
Richard M. Stallman <rms@gnu.org>
parents:
50634
diff
changeset
|
818 (view-recenter)) |
01b16e9a75fb
(Helper-return-blurb): Add defvar. (Also rearrange defuns.)
Richard M. Stallman <rms@gnu.org>
parents:
50634
diff
changeset
|
819 |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
820 (defun view-scroll-lines (lines backward default maxdefault) |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
821 ;; This function does the job for all the scrolling commands. |
103297
1120e729d920
* view.el (view-window-size): Use window-line-height to find window height.
Chong Yidong <cyd@stupidchicken.com>
parents:
103295
diff
changeset
|
822 ;; Scroll forward LINES lines. If BACKWARD is non-nil, scroll backwards. |
1120e729d920
* view.el (view-window-size): Use window-line-height to find window height.
Chong Yidong <cyd@stupidchicken.com>
parents:
103295
diff
changeset
|
823 ;; If LINES is negative scroll in the other direction. |
1120e729d920
* view.el (view-window-size): Use window-line-height to find window height.
Chong Yidong <cyd@stupidchicken.com>
parents:
103295
diff
changeset
|
824 ;; If LINES is 0 or nil, scroll DEFAULT lines (if DEFAULT is nil, scroll |
105170 | 825 ;; by one page). If MAXDEFAULT is non-nil, scroll no more than a window. |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
826 (if (or (null lines) (zerop (setq lines (prefix-numeric-value lines)))) |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
827 (setq lines default)) |
103297
1120e729d920
* view.el (view-window-size): Use window-line-height to find window height.
Chong Yidong <cyd@stupidchicken.com>
parents:
103295
diff
changeset
|
828 (when (and lines (< lines 0)) |
1120e729d920
* view.el (view-window-size): Use window-line-height to find window height.
Chong Yidong <cyd@stupidchicken.com>
parents:
103295
diff
changeset
|
829 (setq backward (not backward) lines (- lines))) |
1120e729d920
* view.el (view-window-size): Use window-line-height to find window height.
Chong Yidong <cyd@stupidchicken.com>
parents:
103295
diff
changeset
|
830 (when (and maxdefault lines (> lines (view-window-size))) |
1120e729d920
* view.el (view-window-size): Use window-line-height to find window height.
Chong Yidong <cyd@stupidchicken.com>
parents:
103295
diff
changeset
|
831 (setq lines nil)) |
1120e729d920
* view.el (view-window-size): Use window-line-height to find window height.
Chong Yidong <cyd@stupidchicken.com>
parents:
103295
diff
changeset
|
832 (cond (backward (scroll-down lines)) |
1120e729d920
* view.el (view-window-size): Use window-line-height to find window height.
Chong Yidong <cyd@stupidchicken.com>
parents:
103295
diff
changeset
|
833 ((view-really-at-end) |
1120e729d920
* view.el (view-window-size): Use window-line-height to find window height.
Chong Yidong <cyd@stupidchicken.com>
parents:
103295
diff
changeset
|
834 (if view-scroll-auto-exit |
1120e729d920
* view.el (view-window-size): Use window-line-height to find window height.
Chong Yidong <cyd@stupidchicken.com>
parents:
103295
diff
changeset
|
835 (View-quit) |
1120e729d920
* view.el (view-window-size): Use window-line-height to find window height.
Chong Yidong <cyd@stupidchicken.com>
parents:
103295
diff
changeset
|
836 (ding) |
1120e729d920
* view.el (view-window-size): Use window-line-height to find window height.
Chong Yidong <cyd@stupidchicken.com>
parents:
103295
diff
changeset
|
837 (view-end-message))) |
1120e729d920
* view.el (view-window-size): Use window-line-height to find window height.
Chong Yidong <cyd@stupidchicken.com>
parents:
103295
diff
changeset
|
838 (t (scroll-up lines) |
1120e729d920
* view.el (view-window-size): Use window-line-height to find window height.
Chong Yidong <cyd@stupidchicken.com>
parents:
103295
diff
changeset
|
839 (if (view-really-at-end) (view-end-message))))) |
44 | 840 |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
841 (defun view-really-at-end () |
18250 | 842 ;; Return true if buffer end visible. Maybe revert buffer and test. |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
843 (and (pos-visible-in-window-p (point-max)) |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
844 (let ((buf (current-buffer)) |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
845 (bufname (buffer-name)) |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
846 (file (buffer-file-name))) |
21678
acaff8b34667
(view-really-at-end): Return true when at end and not
Andreas Schwab <schwab@suse.de>
parents:
21187
diff
changeset
|
847 (or (not view-try-extend-at-buffer-end) |
acaff8b34667
(view-really-at-end): Return true when at end and not
Andreas Schwab <schwab@suse.de>
parents:
21187
diff
changeset
|
848 (null file) |
acaff8b34667
(view-really-at-end): Return true when at end and not
Andreas Schwab <schwab@suse.de>
parents:
21187
diff
changeset
|
849 (verify-visited-file-modtime buf) |
acaff8b34667
(view-really-at-end): Return true when at end and not
Andreas Schwab <schwab@suse.de>
parents:
21187
diff
changeset
|
850 (not (file-exists-p file)) |
acaff8b34667
(view-really-at-end): Return true when at end and not
Andreas Schwab <schwab@suse.de>
parents:
21187
diff
changeset
|
851 (when (buffer-modified-p buf) |
acaff8b34667
(view-really-at-end): Return true when at end and not
Andreas Schwab <schwab@suse.de>
parents:
21187
diff
changeset
|
852 (setq file (file-name-nondirectory file)) |
acaff8b34667
(view-really-at-end): Return true when at end and not
Andreas Schwab <schwab@suse.de>
parents:
21187
diff
changeset
|
853 (not (yes-or-no-p |
acaff8b34667
(view-really-at-end): Return true when at end and not
Andreas Schwab <schwab@suse.de>
parents:
21187
diff
changeset
|
854 (format |
acaff8b34667
(view-really-at-end): Return true when at end and not
Andreas Schwab <schwab@suse.de>
parents:
21187
diff
changeset
|
855 "File %s changed on disk. Discard your edits%s? " |
acaff8b34667
(view-really-at-end): Return true when at end and not
Andreas Schwab <schwab@suse.de>
parents:
21187
diff
changeset
|
856 file |
acaff8b34667
(view-really-at-end): Return true when at end and not
Andreas Schwab <schwab@suse.de>
parents:
21187
diff
changeset
|
857 (if (string= bufname file) "" |
acaff8b34667
(view-really-at-end): Return true when at end and not
Andreas Schwab <schwab@suse.de>
parents:
21187
diff
changeset
|
858 (concat " in " bufname)))))) |
acaff8b34667
(view-really-at-end): Return true when at end and not
Andreas Schwab <schwab@suse.de>
parents:
21187
diff
changeset
|
859 (progn |
acaff8b34667
(view-really-at-end): Return true when at end and not
Andreas Schwab <schwab@suse.de>
parents:
21187
diff
changeset
|
860 (revert-buffer t t t) |
acaff8b34667
(view-really-at-end): Return true when at end and not
Andreas Schwab <schwab@suse.de>
parents:
21187
diff
changeset
|
861 (pos-visible-in-window-p (point-max))))))) |
44 | 862 |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
863 (defun view-end-message () |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
864 ;; Tell that we are at end of buffer. |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
865 (goto-char (point-max)) |
19841
d7a4b38557f3
(view-end-message): Don't mention q if it really do anything.
Richard M. Stallman <rms@gnu.org>
parents:
19229
diff
changeset
|
866 (if view-return-to-alist |
d7a4b38557f3
(view-end-message): Don't mention q if it really do anything.
Richard M. Stallman <rms@gnu.org>
parents:
19229
diff
changeset
|
867 (message "End of buffer. Type %s to quit viewing." |
d7a4b38557f3
(view-end-message): Don't mention q if it really do anything.
Richard M. Stallman <rms@gnu.org>
parents:
19229
diff
changeset
|
868 (substitute-command-keys |
d7a4b38557f3
(view-end-message): Don't mention q if it really do anything.
Richard M. Stallman <rms@gnu.org>
parents:
19229
diff
changeset
|
869 (if view-scroll-auto-exit "\\[View-scroll-page-forward]" |
d7a4b38557f3
(view-end-message): Don't mention q if it really do anything.
Richard M. Stallman <rms@gnu.org>
parents:
19229
diff
changeset
|
870 "\\[View-quit]"))) |
d7a4b38557f3
(view-end-message): Don't mention q if it really do anything.
Richard M. Stallman <rms@gnu.org>
parents:
19229
diff
changeset
|
871 (message "End of buffer"))) |
50786
01b16e9a75fb
(Helper-return-blurb): Add defvar. (Also rearrange defuns.)
Richard M. Stallman <rms@gnu.org>
parents:
50634
diff
changeset
|
872 |
01b16e9a75fb
(Helper-return-blurb): Add defvar. (Also rearrange defuns.)
Richard M. Stallman <rms@gnu.org>
parents:
50634
diff
changeset
|
873 (defun View-scroll-to-buffer-end () |
01b16e9a75fb
(Helper-return-blurb): Add defvar. (Also rearrange defuns.)
Richard M. Stallman <rms@gnu.org>
parents:
50634
diff
changeset
|
874 "Scroll backward or forward so that buffer end is at last line of window." |
01b16e9a75fb
(Helper-return-blurb): Add defvar. (Also rearrange defuns.)
Richard M. Stallman <rms@gnu.org>
parents:
50634
diff
changeset
|
875 (interactive) |
01b16e9a75fb
(Helper-return-blurb): Add defvar. (Also rearrange defuns.)
Richard M. Stallman <rms@gnu.org>
parents:
50634
diff
changeset
|
876 (let ((p (if (pos-visible-in-window-p (point-max)) (point)))) |
01b16e9a75fb
(Helper-return-blurb): Add defvar. (Also rearrange defuns.)
Richard M. Stallman <rms@gnu.org>
parents:
50634
diff
changeset
|
877 (goto-char (point-max)) |
01b16e9a75fb
(Helper-return-blurb): Add defvar. (Also rearrange defuns.)
Richard M. Stallman <rms@gnu.org>
parents:
50634
diff
changeset
|
878 (recenter -1) |
01b16e9a75fb
(Helper-return-blurb): Add defvar. (Also rearrange defuns.)
Richard M. Stallman <rms@gnu.org>
parents:
50634
diff
changeset
|
879 (and p (goto-char p)))) |
44 | 880 |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
881 (defun View-scroll-page-forward (&optional lines) |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
882 "Scroll \"page size\" or prefix LINES lines forward in View mode. |
18250 | 883 Exit if end of text is visible and `view-scroll-auto-exit' is non-nil. |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
884 \"page size\" is whole window full, or number of lines set by |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
885 \\[View-scroll-page-forward-set-page-size] or |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
886 \\[View-scroll-page-backward-set-page-size]. |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
887 If LINES is more than a window-full, only the last window-full is shown." |
44 | 888 (interactive "P") |
57521
3ac03a07be63
(view-mode-enable): Set view-page-size and view-half-page-size to nil.
Richard M. Stallman <rms@gnu.org>
parents:
55014
diff
changeset
|
889 (view-scroll-lines lines nil (view-page-size-default view-page-size) nil)) |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
890 |
27544
4e3e1730232c
Some changes in documentation. Removed some trailing
Gerd Moellmann <gerd@gnu.org>
parents:
25219
diff
changeset
|
891 (defun View-scroll-page-backward (&optional lines) |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
892 "Scroll \"page size\" or prefix LINES lines backward in View mode. |
18250 | 893 See also `View-scroll-page-forward'." |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
894 (interactive "P") |
57521
3ac03a07be63
(view-mode-enable): Set view-page-size and view-half-page-size to nil.
Richard M. Stallman <rms@gnu.org>
parents:
55014
diff
changeset
|
895 (view-scroll-lines lines t (view-page-size-default view-page-size) nil)) |
49597
e88404e8f2cf
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49439
diff
changeset
|
896 |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
897 (defun View-scroll-page-forward-set-page-size (&optional lines) |
18250 | 898 "Scroll forward LINES lines in View mode, setting the \"page size\". |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
899 This is the number of lines which \\[View-scroll-page-forward] and |
18448
7cf9cdba062d
Changed some documentation.
Richard M. Stallman <rms@gnu.org>
parents:
18335
diff
changeset
|
900 \\[View-scroll-page-backward] scroll by default. |
7cf9cdba062d
Changed some documentation.
Richard M. Stallman <rms@gnu.org>
parents:
18335
diff
changeset
|
901 If LINES is omitted or = 0, sets \"page size\" to window height and |
7cf9cdba062d
Changed some documentation.
Richard M. Stallman <rms@gnu.org>
parents:
18335
diff
changeset
|
902 scrolls forward that much, otherwise scrolls forward LINES lines and sets |
7cf9cdba062d
Changed some documentation.
Richard M. Stallman <rms@gnu.org>
parents:
18335
diff
changeset
|
903 \"page size\" to the minimum of window height and the absolute value of LINES. |
18250 | 904 See also `View-scroll-page-forward'." |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
905 (interactive "P") |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
906 (view-scroll-lines lines nil |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
907 (setq view-page-size (view-page-size-default lines)) |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
908 nil)) |
13168 | 909 |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
910 (defun View-scroll-page-backward-set-page-size (&optional lines) |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
911 "Scroll backward prefix LINES lines in View mode, setting the \"page size\". |
18250 | 912 See also `View-scroll-page-forward-set-page-size'." |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
913 (interactive "P") |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
914 (view-scroll-lines lines t |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
915 (setq view-page-size (view-page-size-default lines)) |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
916 nil)) |
13168 | 917 |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
918 (defun View-scroll-line-forward (&optional lines) |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
919 "Scroll forward one line (or prefix LINES lines) in View mode. |
105170 | 920 See also `View-scroll-page-forward', but note that scrolling is limited |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
921 to minimum of LINES and one window-full." |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
922 (interactive "P") |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
923 (view-scroll-lines lines nil 1 t)) |
44 | 924 |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
925 (defun View-scroll-line-backward (&optional lines) |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
926 "Scroll backward one line (or prefix LINES lines) in View mode. |
18250 | 927 See also `View-scroll-line-forward'." |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
928 (interactive "P") |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
929 (view-scroll-lines lines t 1 t)) |
13168 | 930 |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
931 (defun View-scroll-half-page-forward (&optional lines) |
18250 | 932 "Scroll forward a \"half page\" (or prefix LINES) lines in View mode. |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
933 If LINES is not omitted, the \"half page size\" is set to the minimum of |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
934 window height and the absolute value of LINES. |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
935 LINES=0 resets \"half page size\" to half window height." |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
936 (interactive "P") |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
937 (view-scroll-lines lines nil (view-set-half-page-size-default lines) t)) |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
938 |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
939 (defun View-scroll-half-page-backward (&optional lines) |
18250 | 940 "Scroll backward a \"half page\" (or prefix LINES) lines in View mode. |
941 See also `View-scroll-half-page-forward'." | |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
942 (interactive "P") |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
943 (view-scroll-lines lines t (view-set-half-page-size-default lines) t)) |
44 | 944 |
18250 | 945 (defun View-revert-buffer-scroll-page-forward (&optional lines) |
946 "Scroll forward, reverting buffer if needed, in View mode. | |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
947 If buffer has not been changed and the corresponding file is newer, first |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
948 revert the buffer, then scroll. |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
949 This command is useful if you are viewing a changing file. |
18250 | 950 |
951 The prefix argument LINES says how many lines to scroll. | |
952 If you don't specify a prefix argument, it uses the number of lines set by | |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
953 \\[View-scroll-page-forward-set-page-size] or |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
954 \\[View-scroll-page-backward-set-page-size]. |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
955 If LINES is more than a window-full, only the last window-full is shown." |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
956 (interactive "P") |
23987
a3199b854cf2
(View-revert-buffer-scroll-page-forward): Bind
Andreas Schwab <schwab@suse.de>
parents:
22337
diff
changeset
|
957 (let ((view-scroll-auto-exit nil) |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
958 (view-try-extend-at-buffer-end t)) |
66488
448f6238d8ed
(View-revert-buffer-scroll-page-forward): Use
Andreas Schwab <schwab@suse.de>
parents:
64762
diff
changeset
|
959 (view-scroll-lines lines nil (view-page-size-default view-page-size) nil))) |
50786
01b16e9a75fb
(Helper-return-blurb): Add defvar. (Also rearrange defuns.)
Richard M. Stallman <rms@gnu.org>
parents:
50634
diff
changeset
|
960 |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
961 (defun View-search-regexp-forward (n regexp) |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
962 "Search forward for first (or prefix Nth) occurrence of REGEXP in View mode. |
18448
7cf9cdba062d
Changed some documentation.
Richard M. Stallman <rms@gnu.org>
parents:
18335
diff
changeset
|
963 |
7cf9cdba062d
Changed some documentation.
Richard M. Stallman <rms@gnu.org>
parents:
18335
diff
changeset
|
964 Displays line found at center of window. Sets mark at starting position and |
7cf9cdba062d
Changed some documentation.
Richard M. Stallman <rms@gnu.org>
parents:
18335
diff
changeset
|
965 pushes mark ring. |
7cf9cdba062d
Changed some documentation.
Richard M. Stallman <rms@gnu.org>
parents:
18335
diff
changeset
|
966 |
7cf9cdba062d
Changed some documentation.
Richard M. Stallman <rms@gnu.org>
parents:
18335
diff
changeset
|
967 Characters @ and ! are special at the beginning of REGEXP. They modify |
7cf9cdba062d
Changed some documentation.
Richard M. Stallman <rms@gnu.org>
parents:
18335
diff
changeset
|
968 the search rather than become part of the pattern searched for. |
7cf9cdba062d
Changed some documentation.
Richard M. Stallman <rms@gnu.org>
parents:
18335
diff
changeset
|
969 @ means search all the buffer i.e. start search at the beginning of buffer. |
7cf9cdba062d
Changed some documentation.
Richard M. Stallman <rms@gnu.org>
parents:
18335
diff
changeset
|
970 ! means search for a line that contains no match for the pattern. |
7cf9cdba062d
Changed some documentation.
Richard M. Stallman <rms@gnu.org>
parents:
18335
diff
changeset
|
971 If REGEXP is empty or only consist of these control characters, then |
7cf9cdba062d
Changed some documentation.
Richard M. Stallman <rms@gnu.org>
parents:
18335
diff
changeset
|
972 an earlier remembered REGEXP is used, otherwise REGEXP is remembered |
7cf9cdba062d
Changed some documentation.
Richard M. Stallman <rms@gnu.org>
parents:
18335
diff
changeset
|
973 for use by later search commands. |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
974 |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
975 The variable `view-highlight-face' controls the face that is used |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
976 for highlighting the match that is found." |
27544
4e3e1730232c
Some changes in documentation. Removed some trailing
Gerd Moellmann <gerd@gnu.org>
parents:
25219
diff
changeset
|
977 (interactive "p\nsSearch forward (regexp): ") |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
978 (view-search n regexp)) |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
979 |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
980 (defun View-search-regexp-backward (n regexp) |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
981 "Search backward for first (or prefix Nth) occurrence of REGEXP in View mode. |
18448
7cf9cdba062d
Changed some documentation.
Richard M. Stallman <rms@gnu.org>
parents:
18335
diff
changeset
|
982 |
7cf9cdba062d
Changed some documentation.
Richard M. Stallman <rms@gnu.org>
parents:
18335
diff
changeset
|
983 Displays line found at center of window. Sets mark at starting position and |
7cf9cdba062d
Changed some documentation.
Richard M. Stallman <rms@gnu.org>
parents:
18335
diff
changeset
|
984 pushes mark ring. |
7cf9cdba062d
Changed some documentation.
Richard M. Stallman <rms@gnu.org>
parents:
18335
diff
changeset
|
985 |
7cf9cdba062d
Changed some documentation.
Richard M. Stallman <rms@gnu.org>
parents:
18335
diff
changeset
|
986 Characters @ and ! are special at the beginning of REGEXP. They modify |
7cf9cdba062d
Changed some documentation.
Richard M. Stallman <rms@gnu.org>
parents:
18335
diff
changeset
|
987 the search rather than become part of the pattern searched for. |
7cf9cdba062d
Changed some documentation.
Richard M. Stallman <rms@gnu.org>
parents:
18335
diff
changeset
|
988 @ means search all the buffer i.e. start search at the end of buffer. |
7cf9cdba062d
Changed some documentation.
Richard M. Stallman <rms@gnu.org>
parents:
18335
diff
changeset
|
989 ! means search for a line that contains no match for the pattern. |
7cf9cdba062d
Changed some documentation.
Richard M. Stallman <rms@gnu.org>
parents:
18335
diff
changeset
|
990 If REGEXP is empty or only consist of these control characters, then |
7cf9cdba062d
Changed some documentation.
Richard M. Stallman <rms@gnu.org>
parents:
18335
diff
changeset
|
991 an earlier remembered REGEXP is used, otherwise REGEXP is remembered |
7cf9cdba062d
Changed some documentation.
Richard M. Stallman <rms@gnu.org>
parents:
18335
diff
changeset
|
992 for use by later search commands. |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
993 |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
994 The variable `view-highlight-face' controls the face that is used |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
995 for highlighting the match that is found." |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
996 (interactive "p\nsSearch backward (regexp): ") |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
997 (view-search (- n) regexp)) |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
998 |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
999 (defun View-search-last-regexp-forward (n) "\ |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
1000 Search forward for first (or prefix Nth) instance of last regexp in View mode. |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
1001 Displays line found at center of window. Sets mark at starting position and |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
1002 pushes mark ring. |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
1003 |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
1004 The variable `view-highlight-face' controls the face that is used |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
1005 for highlighting the match that is found." |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
1006 (interactive "p") |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
1007 (view-search n nil)) |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
1008 |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
1009 (defun View-search-last-regexp-backward (n) "\ |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
1010 Search backward for first (or prefix Nth) instance of last regexp in View mode. |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
1011 Displays line found at center of window. Sets mark at starting position and |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
1012 pushes mark ring. |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
1013 |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
1014 The variable `view-highlight-face' controls the face that is used |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
1015 for highlighting the match that is found." |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
1016 (interactive "p") |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
1017 (view-search (- n) nil)) |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
1018 |
44 | 1019 (defun view-search (times regexp) |
18448
7cf9cdba062d
Changed some documentation.
Richard M. Stallman <rms@gnu.org>
parents:
18335
diff
changeset
|
1020 ;; This function does the job for all the View-search- commands. |
105170 | 1021 ;; Search for the TIMESt match for REGEXP. If TIMES is negative |
1022 ;; search backwards. If REGEXP is nil use `view-last-regexp'. | |
99382
f1a064081e2e
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
96229
diff
changeset
|
1023 ;; Characters "!" and "@" have a special meaning at the beginning of |
20072
92d2c2e3b3f3
Some changes in comments and documentation.
Karl Heuer <kwzh@gnu.org>
parents:
19841
diff
changeset
|
1024 ;; REGEXP and are removed from REGEXP before the search "!" means |
92d2c2e3b3f3
Some changes in comments and documentation.
Karl Heuer <kwzh@gnu.org>
parents:
19841
diff
changeset
|
1025 ;; search for lines with no match for REGEXP. "@" means search in |
92d2c2e3b3f3
Some changes in comments and documentation.
Karl Heuer <kwzh@gnu.org>
parents:
19841
diff
changeset
|
1026 ;; the whole buffer, don't start searching from the present point. |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
1027 (let (where no end ln) |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
1028 (cond |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
1029 ((and regexp (> (length regexp) 0) |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
1030 (or (not (memq (string-to-char regexp) '(?! ?@))) |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
1031 (progn |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
1032 (if (member (substring regexp 0 2) '("!@" "@!")) |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
1033 (setq end t no t ln 2) |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
1034 (setq no (not (setq end (eq ?@ (string-to-char regexp)))) |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
1035 ln 1)) |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
1036 (> (length (setq regexp (substring regexp ln))) 0)))) |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
1037 (setq view-last-regexp (if no (list regexp) regexp))) |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
1038 ((consp view-last-regexp) |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
1039 (setq regexp (car view-last-regexp)) |
20072
92d2c2e3b3f3
Some changes in comments and documentation.
Karl Heuer <kwzh@gnu.org>
parents:
19841
diff
changeset
|
1040 (unless (setq no (not no)) (setq view-last-regexp regexp))) |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
1041 (view-last-regexp (setq regexp view-last-regexp) |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
1042 (if no (setq view-last-regexp (list regexp)))) |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
1043 (t (error "No previous View-mode search"))) |
44 | 1044 (save-excursion |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
1045 (if end (goto-char (if (< times 0) (point-max) (point-min))) |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
1046 (move-to-window-line (if (< times 0) 0 -1))) |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
1047 (if (if no (view-search-no-match-lines times regexp) |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
1048 (re-search-forward regexp nil t times)) |
44 | 1049 (setq where (point)))) |
1050 (if where | |
1051 (progn | |
1052 (push-mark) | |
1053 (goto-char where) | |
13122
05bae277596e
(View-search-regexp-forward, View-search-regexp-backward):
Richard M. Stallman <rms@gnu.org>
parents:
13078
diff
changeset
|
1054 (if view-overlay |
05bae277596e
(View-search-regexp-forward, View-search-regexp-backward):
Richard M. Stallman <rms@gnu.org>
parents:
13078
diff
changeset
|
1055 (move-overlay view-overlay (match-beginning 0) (match-end 0)) |
05bae277596e
(View-search-regexp-forward, View-search-regexp-backward):
Richard M. Stallman <rms@gnu.org>
parents:
13078
diff
changeset
|
1056 (setq view-overlay |
05bae277596e
(View-search-regexp-forward, View-search-regexp-backward):
Richard M. Stallman <rms@gnu.org>
parents:
13078
diff
changeset
|
1057 (make-overlay (match-beginning 0) (match-end 0)))) |
13167
c378e215f4d0
(view-highlight-face): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
13158
diff
changeset
|
1058 (overlay-put view-overlay 'face view-highlight-face) |
44 | 1059 (beginning-of-line) |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
1060 (view-recenter)) |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
1061 (message "Can't find occurrence %d of %s%s" |
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
1062 times (if no "no " "") regexp) |
44 | 1063 (sit-for 4)))) |
1064 | |
78890
77e66005aa88
(view-search-no-match-lines): Add a doc string. Rewrite to simplify
Glenn Morris <rgm@gnu.org>
parents:
78492
diff
changeset
|
1065 ;; This is the dumb approach, looking at each line. The original |
77e66005aa88
(view-search-no-match-lines): Add a doc string. Rewrite to simplify
Glenn Morris <rgm@gnu.org>
parents:
78492
diff
changeset
|
1066 ;; version of this function looked like it might have been trying to |
77e66005aa88
(view-search-no-match-lines): Add a doc string. Rewrite to simplify
Glenn Morris <rgm@gnu.org>
parents:
78492
diff
changeset
|
1067 ;; do something clever, but not succeeding: |
77e66005aa88
(view-search-no-match-lines): Add a doc string. Rewrite to simplify
Glenn Morris <rgm@gnu.org>
parents:
78492
diff
changeset
|
1068 ;; http://lists.gnu.org/archive/html/bug-gnu-emacs/2007-09/msg00073.html |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
1069 (defun view-search-no-match-lines (times regexp) |
78890
77e66005aa88
(view-search-no-match-lines): Add a doc string. Rewrite to simplify
Glenn Morris <rgm@gnu.org>
parents:
78492
diff
changeset
|
1070 "Search for the TIMESth occurrence of a line with no match for REGEXP. |
77e66005aa88
(view-search-no-match-lines): Add a doc string. Rewrite to simplify
Glenn Morris <rgm@gnu.org>
parents:
78492
diff
changeset
|
1071 If such a line is found, return non-nil and set the match-data to that line. |
77e66005aa88
(view-search-no-match-lines): Add a doc string. Rewrite to simplify
Glenn Morris <rgm@gnu.org>
parents:
78492
diff
changeset
|
1072 If TIMES is negative, search backwards." |
78893
f8144f59d4b3
(view-search-no-match-lines): Fix previous change (went wrong if
Glenn Morris <rgm@gnu.org>
parents:
78890
diff
changeset
|
1073 (let ((step (if (>= times 0) 1 |
f8144f59d4b3
(view-search-no-match-lines): Fix previous change (went wrong if
Glenn Morris <rgm@gnu.org>
parents:
78890
diff
changeset
|
1074 (setq times (- times)) |
f8144f59d4b3
(view-search-no-match-lines): Fix previous change (went wrong if
Glenn Morris <rgm@gnu.org>
parents:
78890
diff
changeset
|
1075 -1))) |
78890
77e66005aa88
(view-search-no-match-lines): Add a doc string. Rewrite to simplify
Glenn Morris <rgm@gnu.org>
parents:
78492
diff
changeset
|
1076 ;; Note that we do not check the current line. |
77e66005aa88
(view-search-no-match-lines): Add a doc string. Rewrite to simplify
Glenn Morris <rgm@gnu.org>
parents:
78492
diff
changeset
|
1077 (while (and (> times 0) |
77e66005aa88
(view-search-no-match-lines): Add a doc string. Rewrite to simplify
Glenn Morris <rgm@gnu.org>
parents:
78492
diff
changeset
|
1078 (zerop (forward-line step))) |
78893
f8144f59d4b3
(view-search-no-match-lines): Fix previous change (went wrong if
Glenn Morris <rgm@gnu.org>
parents:
78890
diff
changeset
|
1079 ;; (forward-line 1) returns 0 on moving within the last line. |
f8144f59d4b3
(view-search-no-match-lines): Fix previous change (went wrong if
Glenn Morris <rgm@gnu.org>
parents:
78890
diff
changeset
|
1080 (if (eobp) |
f8144f59d4b3
(view-search-no-match-lines): Fix previous change (went wrong if
Glenn Morris <rgm@gnu.org>
parents:
78890
diff
changeset
|
1081 (setq times -1) |
f8144f59d4b3
(view-search-no-match-lines): Fix previous change (went wrong if
Glenn Morris <rgm@gnu.org>
parents:
78890
diff
changeset
|
1082 (or (re-search-forward regexp (line-end-position) t) |
f8144f59d4b3
(view-search-no-match-lines): Fix previous change (went wrong if
Glenn Morris <rgm@gnu.org>
parents:
78890
diff
changeset
|
1083 (setq times (1- times)))))) |
f8144f59d4b3
(view-search-no-match-lines): Fix previous change (went wrong if
Glenn Morris <rgm@gnu.org>
parents:
78890
diff
changeset
|
1084 (and (zerop times) |
f8144f59d4b3
(view-search-no-match-lines): Fix previous change (went wrong if
Glenn Morris <rgm@gnu.org>
parents:
78890
diff
changeset
|
1085 (looking-at ".*"))) |
18249
cb7e72b9a09d
Make view mode more similar to `less'.
Richard M. Stallman <rms@gnu.org>
parents:
15737
diff
changeset
|
1086 |
584 | 1087 (provide 'view) |
1088 | |
93975
1e3a407766b9
Fix up comment convention on the arch-tag lines.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91465
diff
changeset
|
1089 ;; arch-tag: 6d0ace36-1d12-4de3-8de3-1fa3231636d7 |
657
fec3f9a1e3e5
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
584
diff
changeset
|
1090 ;;; view.el ends here |