Mercurial > hg > xemacs-beta
annotate lisp/paragraphs.el @ 5412:6a8c6c6f6c8e
Convert to GPLv3 or later from plain text GPLv2 or later.
author | Mats Lidell <matsl@xemacs.org> |
---|---|
date | Sun, 24 Oct 2010 00:24:04 +0200 |
parents | 308d34e9f07d |
children | ac37a5f7e5be |
rev | line source |
---|---|
2549 | 1 ;;; paragraphs.el --- paragraph and sentence parsing |
428 | 2 |
2549 | 3 ;; Copyright (C) 1985, 86, 87, 91, 94, 95, 96, 1997, 1999, 2000, 2001 |
4 ;; Free Software Foundation, Inc. | |
428 | 5 |
6 ;; Maintainer: FSF | |
7 ;; Keywords: wp, dumped | |
8 | |
9 ;; This file is part of XEmacs. | |
10 | |
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
5229
diff
changeset
|
11 ;; XEmacs is free software: you can redistribute it and/or modify it |
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
5229
diff
changeset
|
12 ;; under the terms of the GNU General Public License as published by the |
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
5229
diff
changeset
|
13 ;; Free Software Foundation, either version 3 of the License, or (at your |
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
5229
diff
changeset
|
14 ;; option) any later version. |
428 | 15 |
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
5229
diff
changeset
|
16 ;; XEmacs is distributed in the hope that it will be useful, but WITHOUT |
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
5229
diff
changeset
|
17 ;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
5229
diff
changeset
|
18 ;; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
5229
diff
changeset
|
19 ;; for more details. |
428 | 20 |
21 ;; You should have received a copy of the GNU General Public License | |
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
5229
diff
changeset
|
22 ;; along with XEmacs. If not, see <http://www.gnu.org/licenses/>. |
428 | 23 |
2549 | 24 ;;; Synched up with: FSF 21.3. |
428 | 25 |
26 ;;; Commentary: | |
27 | |
28 ;; This file is dumped with XEmacs. | |
29 | |
30 ;; This package provides the paragraph-oriented commands documented in the | |
31 ;; XEmacs Reference Manual. | |
32 | |
33 ;; 06/11/1997 - Use char-(after|before) instead of | |
34 ;; (following|preceding)-char. -slb | |
35 | |
36 ;;; Code: | |
37 | |
2549 | 38 (defgroup paragraphs nil |
39 "Paragraph and sentence parsing." | |
40 :group 'editing) | |
428 | 41 |
2549 | 42 (define-minor-mode use-hard-newlines |
428 | 43 "Minor mode to distinguish hard and soft newlines. |
44 When active, the functions `newline' and `open-line' add the | |
45 text-property `hard' to newlines that they insert, and a line is | |
46 only considered as a candidate to match `paragraph-start' or | |
47 `paragraph-separate' if it follows a hard newline. | |
48 | |
49 Prefix argument says to turn mode on if positive, off if negative. | |
50 When the mode is turned on, if there are newlines in the buffer but no hard | |
2549 | 51 newlines, ask the user whether to mark as hard any newlines preceeding a |
428 | 52 `paragraph-start' line. From a program, second arg INSERT specifies whether |
53 to do this; it can be `never' to change nothing, t or `always' to force | |
2549 | 54 marking, `guess' to try to do the right thing with no questions, nil |
428 | 55 or anything else to ask the user. |
56 | |
57 Newlines not marked hard are called \"soft\", and are always internal | |
58 to paragraphs. The fill functions insert and delete only soft newlines." | |
2549 | 59 :group 'paragraphs |
60 :extra-args (insert) | |
61 (when use-hard-newlines | |
428 | 62 ;; Turn mode on |
63 ;; Intuit hard newlines -- | |
64 ;; mark as hard any newlines preceding a paragraph-start line. | |
65 (if (or (eq insert t) (eq insert 'always) | |
66 (and (not (eq 'never insert)) | |
67 (not (text-property-any (point-min) (point-max) 'hard t)) | |
68 (save-excursion | |
69 (goto-char (point-min)) | |
70 (search-forward "\n" nil t)) | |
71 (or (eq insert 'guess) | |
72 (y-or-n-p "Make newlines between paragraphs hard? ")))) | |
73 (save-excursion | |
74 (goto-char (point-min)) | |
75 (while (search-forward "\n" nil t) | |
76 (let ((pos (point))) | |
77 (move-to-left-margin) | |
2549 | 78 (when (looking-at paragraph-start) |
79 (set-hard-newline-properties (1- pos) pos)) | |
80 ;; If paragraph-separate, newline after it is hard too. | |
81 (when (looking-at paragraph-separate) | |
82 (set-hard-newline-properties (1- pos) pos) | |
83 (end-of-line) | |
84 (unless (eobp) | |
85 (set-hard-newline-properties (point) (1+ (point))))))))))) | |
428 | 86 |
2549 | 87 (defcustom paragraph-start "\f\\|[ \t]*$" "\ |
428 | 88 *Regexp for beginning of a line that starts OR separates paragraphs. |
89 This regexp should match lines that separate paragraphs | |
90 and should also match lines that start a paragraph | |
91 \(and are part of that paragraph). | |
92 | |
93 This is matched against the text at the left margin, which is not necessarily | |
94 the beginning of the line, so it should never use \"^\" as an anchor. This | |
95 ensures that the paragraph functions will work equally well within a region | |
96 of text indented by a margin setting. | |
97 | |
98 The variable `paragraph-separate' specifies how to distinguish | |
99 lines that start paragraphs from lines that separate them. | |
100 | |
101 If the variable `use-hard-newlines' is non-nil, then only lines following a | |
2549 | 102 hard newline are considered to match." |
103 :group 'paragraphs | |
104 :type 'regexp) | |
428 | 105 |
106 ;; paragraph-start requires a hard newline, but paragraph-separate does not: | |
107 ;; It is assumed that paragraph-separate is distinctive enough to be believed | |
108 ;; whenever it occurs, while it is reasonable to set paragraph-start to | |
109 ;; something very minimal, even including "." (which makes every hard newline | |
110 ;; start a new paragraph). | |
111 | |
2549 | 112 (defcustom paragraph-separate "[ \t\f]*$" |
113 "*Regexp for beginning of a line that separates paragraphs. | |
450 | 114 If you change this, you may have to change `paragraph-start' also. |
115 | |
116 A line matching this is not part of any paragraph. | |
428 | 117 |
118 This is matched against the text at the left margin, which is not necessarily | |
119 the beginning of the line, so it should not use \"^\" as an anchor. This | |
120 ensures that the paragraph functions will work equally within a region of | |
2549 | 121 text indented by a margin setting." |
122 :group 'paragraphs | |
123 :type 'regexp) | |
124 | |
125 (defcustom sentence-end-double-space t | |
126 "*Non-nil means a single space does not end a sentence. | |
127 This is relevant for filling. See also `sentence-end-without-period' | |
128 and `colon-double-space'. | |
129 | |
130 This variable applies only to filling, not motion commands. To | |
131 change the behavior of motion commands, see `sentence-end'. | |
132 | |
133 If you change this, you should also change `sentence-end'. See Info | |
134 node `Sentences'." | |
135 :type 'boolean | |
136 :group 'fill) | |
428 | 137 |
2549 | 138 (defcustom sentence-end-without-period nil |
139 "*Non-nil means a sentence will end without a period. | |
140 For example, a sentence in Thai text ends with double space but | |
141 without a period." | |
142 :type 'boolean | |
143 :group 'fill) | |
144 | |
145 (defcustom sentence-end | |
5229
7d06a8bf47d2
Move #'purecopy from alloc.c to being an obsolete alias for #'identity
Aidan Kehoe <kehoea@parhasard.net>
parents:
4103
diff
changeset
|
146 ;; This is a bit stupid since it's not auto-updated when the |
7d06a8bf47d2
Move #'purecopy from alloc.c to being an obsolete alias for #'identity
Aidan Kehoe <kehoea@parhasard.net>
parents:
4103
diff
changeset
|
147 ;; other variables are changed, but it's still useful info. |
7d06a8bf47d2
Move #'purecopy from alloc.c to being an obsolete alias for #'identity
Aidan Kehoe <kehoea@parhasard.net>
parents:
4103
diff
changeset
|
148 (concat (if sentence-end-without-period "\\w \\|") |
7d06a8bf47d2
Move #'purecopy from alloc.c to being an obsolete alias for #'identity
Aidan Kehoe <kehoea@parhasard.net>
parents:
4103
diff
changeset
|
149 "[.?!" |
7d06a8bf47d2
Move #'purecopy from alloc.c to being an obsolete alias for #'identity
Aidan Kehoe <kehoea@parhasard.net>
parents:
4103
diff
changeset
|
150 (if (featurep 'mule) |
7d06a8bf47d2
Move #'purecopy from alloc.c to being an obsolete alias for #'identity
Aidan Kehoe <kehoea@parhasard.net>
parents:
4103
diff
changeset
|
151 (decode-coding-string "\033$B!#!%!)!*\033$A!##.#?#!\033$(0!$!%!)!*\033$(G!$!%!)!*\033(B" 'iso-2022-7bit) |
7d06a8bf47d2
Move #'purecopy from alloc.c to being an obsolete alias for #'identity
Aidan Kehoe <kehoea@parhasard.net>
parents:
4103
diff
changeset
|
152 "") |
7d06a8bf47d2
Move #'purecopy from alloc.c to being an obsolete alias for #'identity
Aidan Kehoe <kehoea@parhasard.net>
parents:
4103
diff
changeset
|
153 "][]\"')}]*" |
7d06a8bf47d2
Move #'purecopy from alloc.c to being an obsolete alias for #'identity
Aidan Kehoe <kehoea@parhasard.net>
parents:
4103
diff
changeset
|
154 (if sentence-end-double-space |
7d06a8bf47d2
Move #'purecopy from alloc.c to being an obsolete alias for #'identity
Aidan Kehoe <kehoea@parhasard.net>
parents:
4103
diff
changeset
|
155 "\\($\\| $\\|\t\\| \\)" "\\($\\|[\t ]\\)") |
7d06a8bf47d2
Move #'purecopy from alloc.c to being an obsolete alias for #'identity
Aidan Kehoe <kehoea@parhasard.net>
parents:
4103
diff
changeset
|
156 "[ \t\n]*") |
2549 | 157 "*Regexp describing the end of a sentence. |
158 The value includes the whitespace following the sentence. | |
428 | 159 All paragraph boundaries also end sentences, regardless. |
160 | |
2549 | 161 The default value specifies that in order to be recognized as the end |
162 of a sentence, the ending period, question mark, or exclamation point | |
163 must be followed by two spaces, unless it's inside some sort of quotes | |
164 or parenthesis. | |
165 | |
166 See also the variable `sentence-end-double-space', the variable | |
167 `sentence-end-without-period' and Info node `Sentences'." | |
168 :group 'paragraphs | |
169 :type 'regexp) | |
428 | 170 |
2549 | 171 (defcustom page-delimiter "^\014" |
172 "*Regexp describing line-beginnings that separate pages." | |
173 :group 'paragraphs | |
174 :type 'regexp) | |
428 | 175 |
2549 | 176 (defcustom paragraph-ignore-fill-prefix nil |
177 "*Non-nil means the paragraph commands are not affected by `fill-prefix'. | |
178 This is desirable in modes where blank lines are the paragraph delimiters." | |
179 :group 'paragraphs | |
180 :type 'boolean) | |
428 | 181 |
182 (defun forward-paragraph (&optional arg) | |
183 "Move forward to end of paragraph. | |
2549 | 184 With argument ARG, do it ARG times; |
185 a negative argument ARG = -N means move backward N paragraphs. | |
428 | 186 |
187 A line which `paragraph-start' matches either separates paragraphs | |
188 \(if `paragraph-separate' matches it also) or is the first line of a paragraph. | |
189 A paragraph end is the beginning of a line which is not part of the paragraph | |
2549 | 190 to which the end of the previous line belongs, or the end of the buffer. |
191 Returns the count of paragraphs left to move." | |
428 | 192 (interactive "_p") ; XEmacs |
193 (or arg (setq arg 1)) | |
2549 | 194 (let* ((opoint (point)) |
195 (fill-prefix-regexp | |
428 | 196 (and fill-prefix (not (equal fill-prefix "")) |
197 (not paragraph-ignore-fill-prefix) | |
198 (regexp-quote fill-prefix))) | |
199 ;; Remove ^ from paragraph-start and paragraph-sep if they are there. | |
200 ;; These regexps shouldn't be anchored, because we look for them | |
201 ;; starting at the left-margin. This allows paragraph commands to | |
202 ;; work normally with indented text. | |
203 ;; This hack will not find problem cases like "whatever\\|^something". | |
2549 | 204 (parstart (if (and (not (equal "" paragraph-start)) |
205 (equal ?^ (aref paragraph-start 0))) | |
206 (substring paragraph-start 1) | |
207 paragraph-start)) | |
208 (parsep (if (and (not (equal "" paragraph-separate)) | |
209 (equal ?^ (aref paragraph-separate 0))) | |
210 (substring paragraph-separate 1) | |
211 paragraph-separate)) | |
212 (parsep | |
428 | 213 (if fill-prefix-regexp |
2549 | 214 (concat parsep "\\|" |
428 | 215 fill-prefix-regexp "[ \t]*$") |
2549 | 216 parsep)) |
428 | 217 ;; This is used for searching. |
2549 | 218 (sp-parstart (concat "^[ \t]*\\(?:" parstart "\\|" parsep "\\)")) |
219 start found-start) | |
428 | 220 (while (and (< arg 0) (not (bobp))) |
2549 | 221 (if (and (not (looking-at parsep)) |
428 | 222 (re-search-backward "^\n" (max (1- (point)) (point-min)) t) |
2549 | 223 (looking-at parsep)) |
224 (setq arg (1+ arg)) | |
428 | 225 (setq start (point)) |
226 ;; Move back over paragraph-separating lines. | |
446 | 227 (backward-char 1) (beginning-of-line) |
428 | 228 (while (and (not (bobp)) |
229 (progn (move-to-left-margin) | |
2549 | 230 (looking-at parsep))) |
231 (forward-line -1)) | |
428 | 232 (if (bobp) |
233 nil | |
2549 | 234 (setq arg (1+ arg)) |
428 | 235 ;; Go to end of the previous (non-separating) line. |
236 (end-of-line) | |
237 ;; Search back for line that starts or separates paragraphs. | |
238 (if (if fill-prefix-regexp | |
2549 | 239 ;; There is a fill prefix; it overrides parstart. |
4103 | 240 (let nil ; (multiple-lines) |
428 | 241 (while (and (progn (beginning-of-line) (not (bobp))) |
242 (progn (move-to-left-margin) | |
2549 | 243 (not (looking-at parsep))) |
428 | 244 (looking-at fill-prefix-regexp)) |
4103 | 245 ; (unless (= (point) start) |
246 ; (setq multiple-lines t)) | |
428 | 247 (forward-line -1)) |
248 (move-to-left-margin) | |
2549 | 249 ;; This deleted code caused a long hanging-indent line |
250 ;; not to be filled together with the following lines. | |
251 ;; ;; Don't move back over a line before the paragraph | |
252 ;; ;; which doesn't start with fill-prefix | |
253 ;; ;; unless that is the only line we've moved over. | |
254 ;; (and (not (looking-at fill-prefix-regexp)) | |
255 ;; multiple-lines | |
256 ;; (forward-line 1)) | |
428 | 257 (not (bobp))) |
2549 | 258 (while (and (re-search-backward sp-parstart nil 1) |
259 (setq found-start t) | |
428 | 260 ;; Found a candidate, but need to check if it is a |
2549 | 261 ;; REAL parstart. |
428 | 262 (progn (setq start (point)) |
263 (move-to-left-margin) | |
2549 | 264 (not (looking-at parsep))) |
265 (not (and (looking-at parstart) | |
266 (or (not use-hard-newlines) | |
267 (get-text-property (1- start) 'hard) | |
268 (bobp))))) | |
269 (setq found-start nil) | |
428 | 270 (goto-char start)) |
2549 | 271 found-start) |
428 | 272 ;; Found one. |
273 (progn | |
274 ;; Move forward over paragraph separators. | |
275 ;; We know this cannot reach the place we started | |
276 ;; because we know we moved back over a non-separator. | |
277 (while (and (not (eobp)) | |
278 (progn (move-to-left-margin) | |
2549 | 279 (looking-at parsep))) |
428 | 280 (forward-line 1)) |
281 ;; If line before paragraph is just margin, back up to there. | |
282 (end-of-line 0) | |
283 (if (> (current-column) (current-left-margin)) | |
284 (forward-char 1) | |
285 (skip-chars-backward " \t") | |
286 (if (not (bolp)) | |
287 (forward-line 1)))) | |
288 ;; No starter or separator line => use buffer beg. | |
2549 | 289 (goto-char (point-min)))))) |
290 | |
428 | 291 (while (and (> arg 0) (not (eobp))) |
2549 | 292 ;; Move forward over separator lines... |
293 (while (and (not (eobp)) | |
294 (progn (move-to-left-margin) (not (eobp))) | |
295 (looking-at parsep)) | |
296 (forward-line 1)) | |
297 (unless (eobp) (setq arg (1- arg))) | |
298 ;; ... and one more line. | |
299 (forward-line 1) | |
428 | 300 (if fill-prefix-regexp |
2549 | 301 ;; There is a fill prefix; it overrides parstart. |
428 | 302 (while (and (not (eobp)) |
303 (progn (move-to-left-margin) (not (eobp))) | |
2549 | 304 (not (looking-at parsep)) |
428 | 305 (looking-at fill-prefix-regexp)) |
306 (forward-line 1)) | |
2549 | 307 (while (and (re-search-forward sp-parstart nil 1) |
428 | 308 (progn (setq start (match-beginning 0)) |
309 (goto-char start) | |
310 (not (eobp))) | |
311 (progn (move-to-left-margin) | |
2549 | 312 (not (looking-at parsep))) |
313 (or (not (looking-at parstart)) | |
428 | 314 (and use-hard-newlines |
315 (not (get-text-property (1- start) 'hard))))) | |
316 (forward-char 1)) | |
317 (if (< (point) (point-max)) | |
2549 | 318 (goto-char start)))) |
4103 | 319 (if-fboundp #'constrain-to-field |
320 (constrain-to-field nil opoint t) | |
321 (error | |
322 'void-function | |
323 "constrain-to-field not available; is xemacs-base installed?")) | |
2549 | 324 ;; Return the number of steps that could not be done. |
325 arg)) | |
428 | 326 |
327 (defun backward-paragraph (&optional arg) | |
328 "Move backward to start of paragraph. | |
2549 | 329 With argument ARG, do it ARG times; |
330 a negative argument ARG = -N means move forward N paragraphs. | |
428 | 331 |
332 A paragraph start is the beginning of a line which is a | |
333 `first-line-of-paragraph' or which is ordinary text and follows a | |
334 paragraph-separating line; except: if the first real line of a | |
335 paragraph is preceded by a blank line, the paragraph starts at that | |
336 blank line. | |
337 | |
338 See `forward-paragraph' for more information." | |
339 (interactive "_p") ; XEmacs | |
340 (or arg (setq arg 1)) | |
341 (forward-paragraph (- arg))) | |
342 | |
687 | 343 (defun mark-paragraph (&optional arg) |
428 | 344 "Put point at beginning of this paragraph, mark at end. |
687 | 345 The paragraph marked is the one that contains point or follows point. |
2549 | 346 |
347 With argument ARG, puts mark at end of a following paragraph, so that | |
348 the number of paragraphs marked equals ARG. | |
349 | |
350 If ARG is negative, point is put at end of this paragraph, mark is put | |
351 at beginning of this or a previous paragraph. | |
352 | |
353 If this command is repeated, it marks the next ARG paragraphs after (or | |
354 before, if arg is negative) the ones already marked." | |
687 | 355 (interactive "p") |
356 (unless arg (setq arg 1)) | |
357 (when (zerop arg) | |
358 (error "Cannot mark zero paragraphs")) | |
2549 | 359 (cond ((and (eq last-command this-command) (mark t)) |
360 (set-mark | |
361 (save-excursion | |
362 (goto-char (mark)) | |
363 (forward-paragraph arg) | |
364 (point)))) | |
365 (t | |
366 (forward-paragraph arg) | |
367 (push-mark nil t t) | |
368 (backward-paragraph arg)))) | |
428 | 369 |
370 (defun kill-paragraph (arg) | |
371 "Kill forward to end of paragraph. | |
372 With arg N, kill forward to Nth end of paragraph; | |
373 negative arg -N means kill backward to Nth start of paragraph." | |
374 (interactive "*p") ; XEmacs | |
375 (kill-region (point) (progn (forward-paragraph arg) (point)))) | |
376 | |
377 (defun backward-kill-paragraph (arg) | |
378 "Kill back to start of paragraph. | |
379 With arg N, kill back to Nth start of paragraph; | |
380 negative arg -N means kill forward to Nth end of paragraph." | |
381 (interactive "*p") ; XEmacs | |
382 (kill-region (point) (progn (backward-paragraph arg) (point)))) | |
383 | |
384 (defun transpose-paragraphs (arg) | |
385 "Interchange this (or next) paragraph with previous one." | |
386 (interactive "*p") | |
387 (transpose-subr 'forward-paragraph arg)) | |
388 | |
389 (defun start-of-paragraph-text () | |
390 (let ((opoint (point)) npoint) | |
391 (forward-paragraph -1) | |
392 (setq npoint (point)) | |
393 (skip-chars-forward " \t\n") | |
394 ;; If the range of blank lines found spans the original start point, | |
395 ;; try again from the beginning of it. | |
396 ;; Must be careful to avoid infinite loop | |
397 ;; when following a single return at start of buffer. | |
398 (if (and (>= (point) opoint) (< npoint opoint)) | |
399 (progn | |
400 (goto-char npoint) | |
401 (if (> npoint (point-min)) | |
402 (start-of-paragraph-text)))))) | |
403 | |
404 (defun end-of-paragraph-text () | |
405 (let ((opoint (point))) | |
406 (forward-paragraph 1) | |
446 | 407 (if (eq (char-before (point)) ?\n) (backward-char 1)) |
428 | 408 (if (<= (point) opoint) |
409 (progn | |
410 (forward-char 1) | |
411 (if (< (point) (point-max)) | |
412 (end-of-paragraph-text)))))) | |
413 | |
414 (defun forward-sentence (&optional arg) | |
415 "Move forward to next `sentence-end'. With argument, repeat. | |
416 With negative argument, move backward repeatedly to `sentence-beginning'. | |
417 | |
418 The variable `sentence-end' is a regular expression that matches ends of | |
450 | 419 sentences. A paragraph boundary also terminates a sentence." |
428 | 420 (interactive "_p") ; XEmacs |
421 (or arg (setq arg 1)) | |
2549 | 422 (let ((opoint (point))) |
423 (while (< arg 0) | |
424 (let ((pos (point)) | |
425 (par-beg (save-excursion (start-of-paragraph-text) (point)))) | |
426 (if (and (re-search-backward sentence-end par-beg t) | |
427 (or (< (match-end 0) pos) | |
428 (re-search-backward sentence-end par-beg t))) | |
429 (goto-char (match-end 0)) | |
430 (goto-char par-beg))) | |
431 (setq arg (1+ arg))) | |
432 (while (> arg 0) | |
433 (let ((par-end (save-excursion (end-of-paragraph-text) (point)))) | |
434 (if (re-search-forward sentence-end par-end t) | |
435 (skip-chars-backward " \t\n") | |
436 (goto-char par-end))) | |
437 (setq arg (1- arg))) | |
4103 | 438 (if-fboundp #'constrain-to-field |
439 (constrain-to-field nil opoint t) | |
440 (error | |
441 'void-function | |
442 "constrain-to-field not available; is xemacs-base installed?")))) | |
428 | 443 |
444 (defun backward-sentence (&optional arg) | |
445 "Move backward to start of sentence. With arg, do it arg times. | |
446 See `forward-sentence' for more information." | |
447 (interactive "_p") ; XEmacs | |
448 (or arg (setq arg 1)) | |
449 (forward-sentence (- arg))) | |
450 | |
451 (defun kill-sentence (&optional arg) | |
452 "Kill from point to end of sentence. | |
453 With arg, repeat; negative arg -N means kill back to Nth start of sentence." | |
454 (interactive "*p") ; XEmacs | |
455 (kill-region (point) (progn (forward-sentence arg) (point)))) | |
456 | |
457 (defun backward-kill-sentence (&optional arg) | |
458 "Kill back from point to start of sentence. | |
459 With arg, repeat, or kill forward to Nth end of sentence if negative arg -N." | |
460 (interactive "*p") ; XEmacs | |
461 (kill-region (point) (progn (backward-sentence arg) (point)))) | |
462 | |
463 (defun mark-end-of-sentence (arg) | |
2549 | 464 "Put mark at end of sentence. Arg works as in `forward-sentence'. |
465 If this command is repeated, it marks the next ARG sentences after the | |
466 ones already marked." | |
428 | 467 (interactive "p") |
468 ;; FSF Version: | |
2549 | 469 ; (push-mark |
470 ; (save-excursion | |
471 ; (if (and (eq last-command this-command) (mark t)) | |
472 ; (goto-char (mark))) | |
473 ; (forward-sentence arg) | |
474 ; (point)) | |
475 ; nil t)) | |
428 | 476 (mark-something 'mark-end-of-sentence 'forward-sentence arg)) |
477 | |
478 (defun mark-end-of-line (arg) | |
479 "Put mark at end of line. Arg works as in `end-of-line'." | |
480 (interactive "p") | |
481 (mark-something 'mark-end-of-line 'end-of-line arg)) | |
482 | |
483 (defun transpose-sentences (arg) | |
484 "Interchange this (next) and previous sentence." | |
485 (interactive "*p") | |
486 (transpose-subr 'forward-sentence arg)) | |
487 | |
2549 | 488 ;;; Local Variables: |
489 ;;; coding: iso-2022-7bit | |
490 ;;; End: | |
491 | |
428 | 492 ;;; paragraphs.el ends here |