Mercurial > emacs
annotate lisp/textmodes/paragraphs.el @ 2498:0126ca788e99
* Makefile.in (clean mostlyclean): Missing right paren.
Change `configure' to a mixture of custom code and autoconf stuff.
autoconf can't derive all the information we need, but we'd really
like to be able to take advantage of some of its tests, and its
file-editing facilities.
* configure.in: Renamed from configure.
Quote the sections of shell script we want copied literally to
the configure script.
(compile): Initialize this to make the autoconf macros' code happy.
Use AC_PROG_CC, AC_CONST, and AC_RETSIGTYPE instead of writing out
code to do their jobs.
Use autoconf to produce Makefile and src/config.h.
Remove the Makefile-style comment that autoconf places at the top
of src/config.h.
(config_h_opts): Removed - no longer necessary.
* Makefile.in (configname): Renamed to configuration.
(CONFIG_CFLAGS): Renamed to DEFS.
(CC, DEFS, C_SWITCH_SYSTEM, version, configuration): Adjusted to
get values via autoload @cookies@.
(libsrc_libs): Get this from autoconf. We used to do nothing
about this.
(${SUBDIR}): Pass DEFS to submakes instead of CONFIG_CFLAGS.
* Makefile.in (src/paths.h, lib-src/Makefile, src/Makefile): Don't
echo the move-if-change command.
author | Jim Blandy <jimb@redhat.com> |
---|---|
date | Sat, 10 Apr 1993 06:01:49 +0000 |
parents | f287613dfc28 |
children | fb3509fdf8b7 |
rev | line source |
---|---|
659
505130d1ddf8
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
269
diff
changeset
|
1 ;;; paragraphs.el --- paragraph and sentence parsing. |
505130d1ddf8
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
269
diff
changeset
|
2 |
845 | 3 ;; Copyright (C) 1985, 86, 87, 1991 Free Software Foundation, Inc. |
4 | |
789
71d052f72ac1
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
732
diff
changeset
|
5 ;; Maintainer: FSF |
814
38b2499cb3e9
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
804
diff
changeset
|
6 ;; Keywords: wp |
789
71d052f72ac1
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
732
diff
changeset
|
7 |
36 | 8 ;; This file is part of GNU Emacs. |
9 | |
10 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
11 ;; it under the terms of the GNU General Public License as published by | |
804 | 12 ;; the Free Software Foundation; either version 2, or (at your option) |
36 | 13 ;; any later version. |
14 | |
15 ;; GNU Emacs is distributed in the hope that it will be useful, | |
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 ;; GNU General Public License for more details. | |
19 | |
20 ;; You should have received a copy of the GNU General Public License | |
21 ;; along with GNU Emacs; see the file COPYING. If not, write to | |
22 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | |
23 | |
2308
f287613dfc28
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1462
diff
changeset
|
24 ;;; Commentary: |
f287613dfc28
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1462
diff
changeset
|
25 |
f287613dfc28
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1462
diff
changeset
|
26 ;; This package provides the paragraph-oriented commands documented in the |
f287613dfc28
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1462
diff
changeset
|
27 ;; Emacs manual. |
f287613dfc28
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1462
diff
changeset
|
28 |
789
71d052f72ac1
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
732
diff
changeset
|
29 ;;; Code: |
36 | 30 |
269 | 31 (defconst paragraph-start "^[ \t\n\f]" "\ |
32 *Regexp for beginning of a line that starts OR separates paragraphs.") | |
264 | 33 |
269 | 34 (defconst paragraph-separate "^[ \t\f]*$" "\ |
35 *Regexp for beginning of a line that separates paragraphs. | |
36 If you change this, you may have to change paragraph-start also.") | |
264 | 37 |
269 | 38 (defconst sentence-end (purecopy "[.?!][]\"')}]*\\($\\| $\\|\t\\| \\)[ \t\n]*") "\ |
39 *Regexp describing the end of a sentence. | |
40 All paragraph boundaries also end sentences, regardless.") | |
264 | 41 |
269 | 42 (defconst page-delimiter "^\014" "\ |
43 *Regexp describing line-beginnings that separate pages.") | |
264 | 44 |
269 | 45 (defvar paragraph-ignore-fill-prefix nil "\ |
46 Non-nil means the paragraph commands are not affected by `fill-prefix'. | |
47 This is desirable in modes where blank lines are the paragraph delimiters.") | |
264 | 48 |
36 | 49 |
50 (defun forward-paragraph (&optional arg) | |
51 "Move forward to end of paragraph. | |
52 With arg N, do it N times; negative arg -N means move forward N paragraphs. | |
53 | |
54 A line which `paragraph-start' matches either separates paragraphs | |
55 \(if `paragraph-separate' matches it also) or is the first line of a paragraph. | |
56 A paragraph end is the beginning of a line which is not part of the paragraph | |
57 to which the end of the previous line belongs, or the end of the buffer." | |
58 (interactive "p") | |
59 (or arg (setq arg 1)) | |
60 (let* ((fill-prefix-regexp | |
61 (and fill-prefix (not (equal fill-prefix "")) | |
62 (not paragraph-ignore-fill-prefix) | |
63 (regexp-quote fill-prefix))) | |
64 (paragraph-separate | |
65 (if fill-prefix-regexp | |
66 (concat paragraph-separate "\\|^" | |
67 fill-prefix-regexp "[ \t]*$") | |
68 paragraph-separate))) | |
69 (while (< arg 0) | |
70 (if (and (not (looking-at paragraph-separate)) | |
71 (re-search-backward "^\n" (max (1- (point)) (point-min)) t)) | |
72 nil | |
73 (forward-char -1) (beginning-of-line) | |
74 (while (and (not (bobp)) (looking-at paragraph-separate)) | |
75 (forward-line -1)) | |
76 (end-of-line) | |
77 ;; Search back for line that starts or separates paragraphs. | |
78 (if (if fill-prefix-regexp | |
79 ;; There is a fill prefix; it overrides paragraph-start. | |
80 (progn | |
81 (while (progn (beginning-of-line) | |
82 (and (not (bobp)) | |
83 (not (looking-at paragraph-separate)) | |
84 (looking-at fill-prefix-regexp))) | |
85 (forward-line -1)) | |
86 (not (bobp))) | |
87 (re-search-backward paragraph-start nil t)) | |
88 ;; Found one. | |
89 (progn | |
90 (while (and (not (eobp)) (looking-at paragraph-separate)) | |
91 (forward-line 1)) | |
92 (if (eq (char-after (- (point) 2)) ?\n) | |
93 (forward-line -1))) | |
94 ;; No starter or separator line => use buffer beg. | |
95 (goto-char (point-min)))) | |
96 (setq arg (1+ arg))) | |
97 (while (> arg 0) | |
98 (beginning-of-line) | |
99 (while (prog1 (and (not (eobp)) | |
100 (looking-at paragraph-separate)) | |
101 (forward-line 1))) | |
102 (if fill-prefix-regexp | |
103 ;; There is a fill prefix; it overrides paragraph-start. | |
104 (while (and (not (eobp)) | |
105 (not (looking-at paragraph-separate)) | |
106 (looking-at fill-prefix-regexp)) | |
107 (forward-line 1)) | |
108 (if (re-search-forward paragraph-start nil t) | |
109 (goto-char (match-beginning 0)) | |
110 (goto-char (point-max)))) | |
111 (setq arg (1- arg))))) | |
112 | |
113 (defun backward-paragraph (&optional arg) | |
114 "Move backward to start of paragraph. | |
115 With arg N, do it N times; negative arg -N means move forward N paragraphs. | |
116 | |
237 | 117 A paragraph start is the beginning of a line which is a |
118 `first-line-of-paragraph' or which is ordinary text and follows a | |
119 paragraph-separating line; except: if the first real line of a | |
120 paragraph is preceded by a blank line, the paragraph starts at that | |
121 blank line. | |
122 | |
123 See `forward-paragraph' for more information." | |
36 | 124 (interactive "p") |
125 (or arg (setq arg 1)) | |
126 (forward-paragraph (- arg))) | |
127 | |
128 (defun mark-paragraph () | |
129 "Put point at beginning of this paragraph, mark at end. | |
130 The paragraph marked is the one that contains point or follows point." | |
131 (interactive) | |
132 (forward-paragraph 1) | |
133 (push-mark nil t) | |
134 (backward-paragraph 1)) | |
135 | |
136 (defun kill-paragraph (arg) | |
137 "Kill forward to end of paragraph. | |
138 With arg N, kill forward to Nth end of paragraph; | |
139 negative arg -N means kill backward to Nth start of paragraph." | |
237 | 140 (interactive "p") |
1435
4fef92b213f6
(kill-sentence, backward-kill-sentence):
Richard M. Stallman <rms@gnu.org>
parents:
845
diff
changeset
|
141 (kill-region (point) (save-excursion (forward-paragraph arg) (point)))) |
36 | 142 |
143 (defun backward-kill-paragraph (arg) | |
144 "Kill back to start of paragraph. | |
145 With arg N, kill back to Nth start of paragraph; | |
146 negative arg -N means kill forward to Nth end of paragraph." | |
237 | 147 (interactive "p") |
1435
4fef92b213f6
(kill-sentence, backward-kill-sentence):
Richard M. Stallman <rms@gnu.org>
parents:
845
diff
changeset
|
148 (kill-region (point) (save-excursion (backward-paragraph arg) (point)))) |
36 | 149 |
150 (defun transpose-paragraphs (arg) | |
151 "Interchange this (or next) paragraph with previous one." | |
152 (interactive "*p") | |
153 (transpose-subr 'forward-paragraph arg)) | |
154 | |
155 (defun start-of-paragraph-text () | |
156 (let ((opoint (point)) npoint) | |
157 (forward-paragraph -1) | |
158 (setq npoint (point)) | |
159 (skip-chars-forward " \t\n") | |
68 | 160 ;; If the range of blank lines found spans the original start point, |
161 ;; try again from the beginning of it. | |
162 ;; Must be careful to avoid infinite loop | |
163 ;; when following a single return at start of buffer. | |
164 (if (and (>= (point) opoint) (< npoint opoint)) | |
36 | 165 (progn |
166 (goto-char npoint) | |
167 (if (> npoint (point-min)) | |
168 (start-of-paragraph-text)))))) | |
169 | |
170 (defun end-of-paragraph-text () | |
171 (let ((opoint (point))) | |
172 (forward-paragraph 1) | |
173 (if (eq (preceding-char) ?\n) (forward-char -1)) | |
174 (if (<= (point) opoint) | |
175 (progn | |
176 (forward-char 1) | |
177 (if (< (point) (point-max)) | |
178 (end-of-paragraph-text)))))) | |
179 | |
180 (defun forward-sentence (&optional arg) | |
237 | 181 "Move forward to next`sentence-end'. With argument, repeat. |
182 With negative argument, move backward repeatedly to `sentence-beginning'. | |
36 | 183 |
237 | 184 The variable `sentence-end' is a regular expression that matches ends of |
185 sentences. Also, every paragraph boundary terminates sentences as well." | |
36 | 186 (interactive "p") |
187 (or arg (setq arg 1)) | |
188 (while (< arg 0) | |
189 (let ((par-beg (save-excursion (start-of-paragraph-text) (point)))) | |
190 (if (re-search-backward (concat sentence-end "[^ \t\n]") par-beg t) | |
191 (goto-char (1- (match-end 0))) | |
192 (goto-char par-beg))) | |
193 (setq arg (1+ arg))) | |
194 (while (> arg 0) | |
195 (let ((par-end (save-excursion (end-of-paragraph-text) (point)))) | |
196 (if (re-search-forward sentence-end par-end t) | |
197 (skip-chars-backward " \t\n") | |
198 (goto-char par-end))) | |
199 (setq arg (1- arg)))) | |
200 | |
201 (defun backward-sentence (&optional arg) | |
202 "Move backward to start of sentence. With arg, do it arg times. | |
237 | 203 See `forward-sentence' for more information." |
36 | 204 (interactive "p") |
205 (or arg (setq arg 1)) | |
206 (forward-sentence (- arg))) | |
207 | |
208 (defun kill-sentence (&optional arg) | |
209 "Kill from point to end of sentence. | |
210 With arg, repeat; negative arg -N means kill back to Nth start of sentence." | |
211 (interactive "*p") | |
1435
4fef92b213f6
(kill-sentence, backward-kill-sentence):
Richard M. Stallman <rms@gnu.org>
parents:
845
diff
changeset
|
212 (kill-region (point) (save-excursion (forward-sentence arg) (point)))) |
36 | 213 |
214 (defun backward-kill-sentence (&optional arg) | |
215 "Kill back from point to start of sentence. | |
216 With arg, repeat, or kill forward to Nth end of sentence if negative arg -N." | |
217 (interactive "*p") | |
1462
876e54ad6936
(backward-kill-sentence): Fix typo in last change.
Richard M. Stallman <rms@gnu.org>
parents:
1435
diff
changeset
|
218 (kill-region (point) (save-excursion (backward-sentence arg) (point)))) |
36 | 219 |
220 (defun mark-end-of-sentence (arg) | |
237 | 221 "Put mark at end of sentence. Arg works as in `forward-sentence'." |
36 | 222 (interactive "p") |
223 (push-mark | |
224 (save-excursion | |
225 (forward-sentence arg) | |
226 (point)))) | |
227 | |
228 (defun transpose-sentences (arg) | |
229 "Interchange this (next) and previous sentence." | |
230 (interactive "*p") | |
231 (transpose-subr 'forward-sentence arg)) | |
659
505130d1ddf8
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
269
diff
changeset
|
232 |
505130d1ddf8
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
269
diff
changeset
|
233 ;;; paragraphs.el ends here |