Mercurial > emacs
annotate lisp/textmodes/paragraphs.el @ 107521:54f3a4d055ee
Document font-use-system-font.
* cmdargs.texi (Font X): Move most content to Fonts.
* frames.texi (Fonts): New node. Document font-use-system-font.
* emacs.texi (Top):
* xresources.texi (Table of Resources):
* mule.texi (Defining Fontsets, Charsets): Update xrefs.
| author | Chong Yidong <cyd@stupidchicken.com> |
|---|---|
| date | Sat, 20 Mar 2010 13:24:06 -0400 |
| parents | 38f0f81b2f1f |
| children | 280c8ae2476d 376148b31b5e |
| rev | line source |
|---|---|
|
38412
253f761ad37b
Some fixes to follow coding conventions in files maintained by FSF.
Pavel Jan?k <Pavel@Janik.cz>
parents:
37415
diff
changeset
|
1 ;;; paragraphs.el --- paragraph and sentence parsing |
|
659
505130d1ddf8
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
269
diff
changeset
|
2 |
|
64751
5b1a238fcbb4
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64084
diff
changeset
|
3 ;; Copyright (C) 1985, 1986, 1987, 1991, 1994, 1995, 1996, 1997, 1999, 2000, |
|
107143
38f0f81b2f1f
Improve docs of some transposition functions.
Glenn Morris <rgm@gnu.org>
parents:
106815
diff
changeset
|
4 ;; 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 |
|
38f0f81b2f1f
Improve docs of some transposition functions.
Glenn Morris <rgm@gnu.org>
parents:
106815
diff
changeset
|
5 ;; Free Software Foundation, Inc. |
| 845 | 6 |
|
789
71d052f72ac1
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
732
diff
changeset
|
7 ;; Maintainer: FSF |
|
814
38b2499cb3e9
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
804
diff
changeset
|
8 ;; Keywords: wp |
|
789
71d052f72ac1
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
732
diff
changeset
|
9 |
| 36 | 10 ;; This file is part of GNU Emacs. |
| 11 | |
|
94670
f4a69fedbd46
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94293
diff
changeset
|
12 ;; GNU Emacs is free software: you can redistribute it and/or modify |
| 36 | 13 ;; it under the terms of the GNU General Public License as published by |
|
94670
f4a69fedbd46
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94293
diff
changeset
|
14 ;; the Free Software Foundation, either version 3 of the License, or |
|
f4a69fedbd46
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94293
diff
changeset
|
15 ;; (at your option) any later version. |
| 36 | 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 | |
|
94670
f4a69fedbd46
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94293
diff
changeset
|
23 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
| 36 | 24 |
|
2308
f287613dfc28
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1462
diff
changeset
|
25 ;;; Commentary: |
|
f287613dfc28
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1462
diff
changeset
|
26 |
|
f287613dfc28
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1462
diff
changeset
|
27 ;; 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
|
28 ;; Emacs manual. |
|
f287613dfc28
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1462
diff
changeset
|
29 |
|
789
71d052f72ac1
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
732
diff
changeset
|
30 ;;; Code: |
| 36 | 31 |
| 19475 | 32 (defgroup paragraphs nil |
| 33 "Paragraph and sentence parsing." | |
| 34 :group 'editing) | |
| 35 | |
|
56941
e838a0739922
(use-hard-newlines): Make it into a permanent local.
Luc Teirlinck <teirllm@auburn.edu>
parents:
56084
diff
changeset
|
36 (put 'use-hard-newlines 'permanent-local t) |
|
40483
b7f7d0cc89fb
(use-hard-newlines): Use define-minor-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38715
diff
changeset
|
37 (define-minor-mode use-hard-newlines |
|
16019
99cc9a8dd157
(use-hard-newlines): New minor mode function.
Richard M. Stallman <rms@gnu.org>
parents:
14378
diff
changeset
|
38 "Minor mode to distinguish hard and soft newlines. |
|
99cc9a8dd157
(use-hard-newlines): New minor mode function.
Richard M. Stallman <rms@gnu.org>
parents:
14378
diff
changeset
|
39 When active, the functions `newline' and `open-line' add the |
|
99cc9a8dd157
(use-hard-newlines): New minor mode function.
Richard M. Stallman <rms@gnu.org>
parents:
14378
diff
changeset
|
40 text-property `hard' to newlines that they insert, and a line is |
|
10864
33769cbeb58e
(paragraph-start, paragraph-separate): Default values no longer start
Boris Goldowsky <boris@gnu.org>
parents:
10464
diff
changeset
|
41 only considered as a candidate to match `paragraph-start' or |
|
16019
99cc9a8dd157
(use-hard-newlines): New minor mode function.
Richard M. Stallman <rms@gnu.org>
parents:
14378
diff
changeset
|
42 `paragraph-separate' if it follows a hard newline. |
|
99cc9a8dd157
(use-hard-newlines): New minor mode function.
Richard M. Stallman <rms@gnu.org>
parents:
14378
diff
changeset
|
43 |
|
99cc9a8dd157
(use-hard-newlines): New minor mode function.
Richard M. Stallman <rms@gnu.org>
parents:
14378
diff
changeset
|
44 Prefix argument says to turn mode on if positive, off if negative. |
|
99cc9a8dd157
(use-hard-newlines): New minor mode function.
Richard M. Stallman <rms@gnu.org>
parents:
14378
diff
changeset
|
45 When the mode is turned on, if there are newlines in the buffer but no hard |
|
49599
5ade352e8d1c
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48401
diff
changeset
|
46 newlines, ask the user whether to mark as hard any newlines preceeding a |
|
16019
99cc9a8dd157
(use-hard-newlines): New minor mode function.
Richard M. Stallman <rms@gnu.org>
parents:
14378
diff
changeset
|
47 `paragraph-start' line. From a program, second arg INSERT specifies whether |
|
99cc9a8dd157
(use-hard-newlines): New minor mode function.
Richard M. Stallman <rms@gnu.org>
parents:
14378
diff
changeset
|
48 to do this; it can be `never' to change nothing, t or `always' to force |
|
49599
5ade352e8d1c
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48401
diff
changeset
|
49 marking, `guess' to try to do the right thing with no questions, nil |
|
16019
99cc9a8dd157
(use-hard-newlines): New minor mode function.
Richard M. Stallman <rms@gnu.org>
parents:
14378
diff
changeset
|
50 or anything else to ask the user. |
|
10864
33769cbeb58e
(paragraph-start, paragraph-separate): Default values no longer start
Boris Goldowsky <boris@gnu.org>
parents:
10464
diff
changeset
|
51 |
|
16019
99cc9a8dd157
(use-hard-newlines): New minor mode function.
Richard M. Stallman <rms@gnu.org>
parents:
14378
diff
changeset
|
52 Newlines not marked hard are called \"soft\", and are always internal |
|
99cc9a8dd157
(use-hard-newlines): New minor mode function.
Richard M. Stallman <rms@gnu.org>
parents:
14378
diff
changeset
|
53 to paragraphs. The fill functions insert and delete only soft newlines." |
|
48401
2928f718924e
(use-hard-newlines): Add group.
Markus Rost <rost@math.uni-bielefeld.de>
parents:
47829
diff
changeset
|
54 :group 'paragraphs |
|
40483
b7f7d0cc89fb
(use-hard-newlines): Use define-minor-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38715
diff
changeset
|
55 :extra-args (insert) |
|
b7f7d0cc89fb
(use-hard-newlines): Use define-minor-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38715
diff
changeset
|
56 (when use-hard-newlines |
|
16019
99cc9a8dd157
(use-hard-newlines): New minor mode function.
Richard M. Stallman <rms@gnu.org>
parents:
14378
diff
changeset
|
57 ;; Turn mode on |
|
99cc9a8dd157
(use-hard-newlines): New minor mode function.
Richard M. Stallman <rms@gnu.org>
parents:
14378
diff
changeset
|
58 ;; Intuit hard newlines -- |
|
99cc9a8dd157
(use-hard-newlines): New minor mode function.
Richard M. Stallman <rms@gnu.org>
parents:
14378
diff
changeset
|
59 ;; mark as hard any newlines preceding a paragraph-start line. |
|
99cc9a8dd157
(use-hard-newlines): New minor mode function.
Richard M. Stallman <rms@gnu.org>
parents:
14378
diff
changeset
|
60 (if (or (eq insert t) (eq insert 'always) |
|
99cc9a8dd157
(use-hard-newlines): New minor mode function.
Richard M. Stallman <rms@gnu.org>
parents:
14378
diff
changeset
|
61 (and (not (eq 'never insert)) |
|
99cc9a8dd157
(use-hard-newlines): New minor mode function.
Richard M. Stallman <rms@gnu.org>
parents:
14378
diff
changeset
|
62 (not (text-property-any (point-min) (point-max) 'hard t)) |
|
99cc9a8dd157
(use-hard-newlines): New minor mode function.
Richard M. Stallman <rms@gnu.org>
parents:
14378
diff
changeset
|
63 (save-excursion |
|
99cc9a8dd157
(use-hard-newlines): New minor mode function.
Richard M. Stallman <rms@gnu.org>
parents:
14378
diff
changeset
|
64 (goto-char (point-min)) |
|
99cc9a8dd157
(use-hard-newlines): New minor mode function.
Richard M. Stallman <rms@gnu.org>
parents:
14378
diff
changeset
|
65 (search-forward "\n" nil t)) |
|
99cc9a8dd157
(use-hard-newlines): New minor mode function.
Richard M. Stallman <rms@gnu.org>
parents:
14378
diff
changeset
|
66 (or (eq insert 'guess) |
|
99cc9a8dd157
(use-hard-newlines): New minor mode function.
Richard M. Stallman <rms@gnu.org>
parents:
14378
diff
changeset
|
67 (y-or-n-p "Make newlines between paragraphs hard? ")))) |
|
99cc9a8dd157
(use-hard-newlines): New minor mode function.
Richard M. Stallman <rms@gnu.org>
parents:
14378
diff
changeset
|
68 (save-excursion |
|
99cc9a8dd157
(use-hard-newlines): New minor mode function.
Richard M. Stallman <rms@gnu.org>
parents:
14378
diff
changeset
|
69 (goto-char (point-min)) |
|
99cc9a8dd157
(use-hard-newlines): New minor mode function.
Richard M. Stallman <rms@gnu.org>
parents:
14378
diff
changeset
|
70 (while (search-forward "\n" nil t) |
|
99cc9a8dd157
(use-hard-newlines): New minor mode function.
Richard M. Stallman <rms@gnu.org>
parents:
14378
diff
changeset
|
71 (let ((pos (point))) |
|
99cc9a8dd157
(use-hard-newlines): New minor mode function.
Richard M. Stallman <rms@gnu.org>
parents:
14378
diff
changeset
|
72 (move-to-left-margin) |
|
40483
b7f7d0cc89fb
(use-hard-newlines): Use define-minor-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38715
diff
changeset
|
73 (when (looking-at paragraph-start) |
|
b7f7d0cc89fb
(use-hard-newlines): Use define-minor-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38715
diff
changeset
|
74 (set-hard-newline-properties (1- pos) pos)) |
|
b7f7d0cc89fb
(use-hard-newlines): Use define-minor-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38715
diff
changeset
|
75 ;; If paragraph-separate, newline after it is hard too. |
|
b7f7d0cc89fb
(use-hard-newlines): Use define-minor-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38715
diff
changeset
|
76 (when (looking-at paragraph-separate) |
|
b7f7d0cc89fb
(use-hard-newlines): Use define-minor-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38715
diff
changeset
|
77 (set-hard-newline-properties (1- pos) pos) |
|
b7f7d0cc89fb
(use-hard-newlines): Use define-minor-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38715
diff
changeset
|
78 (end-of-line) |
|
b7f7d0cc89fb
(use-hard-newlines): Use define-minor-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38715
diff
changeset
|
79 (unless (eobp) |
|
b7f7d0cc89fb
(use-hard-newlines): Use define-minor-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38715
diff
changeset
|
80 (set-hard-newline-properties (point) (1+ (point))))))))))) |
|
10864
33769cbeb58e
(paragraph-start, paragraph-separate): Default values no longer start
Boris Goldowsky <boris@gnu.org>
parents:
10464
diff
changeset
|
81 |
|
40483
b7f7d0cc89fb
(use-hard-newlines): Use define-minor-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38715
diff
changeset
|
82 (defcustom paragraph-start "\f\\|[ \t]*$" "\ |
|
70270
925aeac78b9e
(sentence-end-without-space): Fix safety predicate.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
70221
diff
changeset
|
83 Regexp for beginning of a line that starts OR separates paragraphs. |
|
4585
04e78c728252
(paragraph-start): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
2828
diff
changeset
|
84 This regexp should match lines that separate paragraphs |
|
04e78c728252
(paragraph-start): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
2828
diff
changeset
|
85 and should also match lines that start a paragraph |
|
04e78c728252
(paragraph-start): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
2828
diff
changeset
|
86 \(and are part of that paragraph). |
|
10424
6bcb93cec6f8
(forward-paragraph): Notice use-hard-newlines value.
Richard M. Stallman <rms@gnu.org>
parents:
9169
diff
changeset
|
87 |
|
10864
33769cbeb58e
(paragraph-start, paragraph-separate): Default values no longer start
Boris Goldowsky <boris@gnu.org>
parents:
10464
diff
changeset
|
88 This is matched against the text at the left margin, which is not necessarily |
|
33769cbeb58e
(paragraph-start, paragraph-separate): Default values no longer start
Boris Goldowsky <boris@gnu.org>
parents:
10464
diff
changeset
|
89 the beginning of the line, so it should never use \"^\" as an anchor. This |
|
33769cbeb58e
(paragraph-start, paragraph-separate): Default values no longer start
Boris Goldowsky <boris@gnu.org>
parents:
10464
diff
changeset
|
90 ensures that the paragraph functions will work equally well within a region |
|
33769cbeb58e
(paragraph-start, paragraph-separate): Default values no longer start
Boris Goldowsky <boris@gnu.org>
parents:
10464
diff
changeset
|
91 of text indented by a margin setting. |
|
33769cbeb58e
(paragraph-start, paragraph-separate): Default values no longer start
Boris Goldowsky <boris@gnu.org>
parents:
10464
diff
changeset
|
92 |
|
4585
04e78c728252
(paragraph-start): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
2828
diff
changeset
|
93 The variable `paragraph-separate' specifies how to distinguish |
|
10424
6bcb93cec6f8
(forward-paragraph): Notice use-hard-newlines value.
Richard M. Stallman <rms@gnu.org>
parents:
9169
diff
changeset
|
94 lines that start paragraphs from lines that separate them. |
|
6bcb93cec6f8
(forward-paragraph): Notice use-hard-newlines value.
Richard M. Stallman <rms@gnu.org>
parents:
9169
diff
changeset
|
95 |
| 34655 | 96 If the variable `use-hard-newlines' is non-nil, then only lines following a |
| 19475 | 97 hard newline are considered to match." |
| 98 :group 'paragraphs | |
| 99 :type 'regexp) | |
|
92948
73a01bf5cb80
* faces.el (xw-defined-colors):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79719
diff
changeset
|
100 (put 'paragraph-start 'safe-local-variable 'stringp) |
| 264 | 101 |
|
10864
33769cbeb58e
(paragraph-start, paragraph-separate): Default values no longer start
Boris Goldowsky <boris@gnu.org>
parents:
10464
diff
changeset
|
102 ;; paragraph-start requires a hard newline, but paragraph-separate does not: |
|
33769cbeb58e
(paragraph-start, paragraph-separate): Default values no longer start
Boris Goldowsky <boris@gnu.org>
parents:
10464
diff
changeset
|
103 ;; It is assumed that paragraph-separate is distinctive enough to be believed |
|
33769cbeb58e
(paragraph-start, paragraph-separate): Default values no longer start
Boris Goldowsky <boris@gnu.org>
parents:
10464
diff
changeset
|
104 ;; whenever it occurs, while it is reasonable to set paragraph-start to |
|
33769cbeb58e
(paragraph-start, paragraph-separate): Default values no longer start
Boris Goldowsky <boris@gnu.org>
parents:
10464
diff
changeset
|
105 ;; something very minimal, even including "." (which makes every hard newline |
|
33769cbeb58e
(paragraph-start, paragraph-separate): Default values no longer start
Boris Goldowsky <boris@gnu.org>
parents:
10464
diff
changeset
|
106 ;; start a new paragraph). |
|
33769cbeb58e
(paragraph-start, paragraph-separate): Default values no longer start
Boris Goldowsky <boris@gnu.org>
parents:
10464
diff
changeset
|
107 |
| 19475 | 108 (defcustom paragraph-separate "[ \t\f]*$" |
|
70270
925aeac78b9e
(sentence-end-without-space): Fix safety predicate.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
70221
diff
changeset
|
109 "Regexp for beginning of a line that separates paragraphs. |
|
24309
92537e14b89b
(paragraph-separate): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
23245
diff
changeset
|
110 If you change this, you may have to change `paragraph-start' also. |
|
10424
6bcb93cec6f8
(forward-paragraph): Notice use-hard-newlines value.
Richard M. Stallman <rms@gnu.org>
parents:
9169
diff
changeset
|
111 |
|
10864
33769cbeb58e
(paragraph-start, paragraph-separate): Default values no longer start
Boris Goldowsky <boris@gnu.org>
parents:
10464
diff
changeset
|
112 This is matched against the text at the left margin, which is not necessarily |
|
33769cbeb58e
(paragraph-start, paragraph-separate): Default values no longer start
Boris Goldowsky <boris@gnu.org>
parents:
10464
diff
changeset
|
113 the beginning of the line, so it should not use \"^\" as an anchor. This |
|
33769cbeb58e
(paragraph-start, paragraph-separate): Default values no longer start
Boris Goldowsky <boris@gnu.org>
parents:
10464
diff
changeset
|
114 ensures that the paragraph functions will work equally within a region of |
| 19475 | 115 text indented by a margin setting." |
| 116 :group 'paragraphs | |
| 117 :type 'regexp) | |
|
92948
73a01bf5cb80
* faces.el (xw-defined-colors):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79719
diff
changeset
|
118 (put 'paragraph-separate 'safe-local-variable 'stringp) |
| 264 | 119 |
|
40485
ca833879aa7b
(sentence-end-double-space, sentence-end-without-period): Move from fill.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40483
diff
changeset
|
120 (defcustom sentence-end-double-space t |
|
70270
925aeac78b9e
(sentence-end-without-space): Fix safety predicate.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
70221
diff
changeset
|
121 "Non-nil means a single space does not end a sentence. |
|
40485
ca833879aa7b
(sentence-end-double-space, sentence-end-without-period): Move from fill.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40483
diff
changeset
|
122 This is relevant for filling. See also `sentence-end-without-period' |
|
ca833879aa7b
(sentence-end-double-space, sentence-end-without-period): Move from fill.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40483
diff
changeset
|
123 and `colon-double-space'. |
|
ca833879aa7b
(sentence-end-double-space, sentence-end-without-period): Move from fill.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40483
diff
changeset
|
124 |
|
54977
4c4f4e6f6bbf
(sentence-end) <function>: New fun with default value taken
Juri Linkov <juri@jurta.org>
parents:
54014
diff
changeset
|
125 This value is used by the function `sentence-end' to construct the |
|
57405
ba8ab430f898
(sentence-end-double-space)
Luc Teirlinck <teirllm@auburn.edu>
parents:
57282
diff
changeset
|
126 regexp describing the end of a sentence, when the value of the variable |
|
ba8ab430f898
(sentence-end-double-space)
Luc Teirlinck <teirllm@auburn.edu>
parents:
57282
diff
changeset
|
127 `sentence-end' is nil. See Info node `(elisp)Standard Regexps'." |
|
40485
ca833879aa7b
(sentence-end-double-space, sentence-end-without-period): Move from fill.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40483
diff
changeset
|
128 :type 'boolean |
|
ca833879aa7b
(sentence-end-double-space, sentence-end-without-period): Move from fill.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40483
diff
changeset
|
129 :group 'fill) |
|
92948
73a01bf5cb80
* faces.el (xw-defined-colors):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79719
diff
changeset
|
130 (put 'sentence-end-double-space 'safe-local-variable 'booleanp) |
|
40485
ca833879aa7b
(sentence-end-double-space, sentence-end-without-period): Move from fill.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40483
diff
changeset
|
131 |
|
ca833879aa7b
(sentence-end-double-space, sentence-end-without-period): Move from fill.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40483
diff
changeset
|
132 (defcustom sentence-end-without-period nil |
|
70270
925aeac78b9e
(sentence-end-without-space): Fix safety predicate.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
70221
diff
changeset
|
133 "Non-nil means a sentence will end without a period. |
|
40485
ca833879aa7b
(sentence-end-double-space, sentence-end-without-period): Move from fill.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40483
diff
changeset
|
134 For example, a sentence in Thai text ends with double space but |
|
54977
4c4f4e6f6bbf
(sentence-end) <function>: New fun with default value taken
Juri Linkov <juri@jurta.org>
parents:
54014
diff
changeset
|
135 without a period. |
|
4c4f4e6f6bbf
(sentence-end) <function>: New fun with default value taken
Juri Linkov <juri@jurta.org>
parents:
54014
diff
changeset
|
136 |
|
4c4f4e6f6bbf
(sentence-end) <function>: New fun with default value taken
Juri Linkov <juri@jurta.org>
parents:
54014
diff
changeset
|
137 This value is used by the function `sentence-end' to construct the |
|
57405
ba8ab430f898
(sentence-end-double-space)
Luc Teirlinck <teirllm@auburn.edu>
parents:
57282
diff
changeset
|
138 regexp describing the end of a sentence, when the value of the variable |
|
ba8ab430f898
(sentence-end-double-space)
Luc Teirlinck <teirllm@auburn.edu>
parents:
57282
diff
changeset
|
139 `sentence-end' is nil. See Info node `(elisp)Standard Regexps'." |
|
40485
ca833879aa7b
(sentence-end-double-space, sentence-end-without-period): Move from fill.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40483
diff
changeset
|
140 :type 'boolean |
|
ca833879aa7b
(sentence-end-double-space, sentence-end-without-period): Move from fill.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40483
diff
changeset
|
141 :group 'fill) |
|
92948
73a01bf5cb80
* faces.el (xw-defined-colors):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79719
diff
changeset
|
142 (put 'sentence-end-without-period 'safe-local-variable 'booleanp) |
|
40485
ca833879aa7b
(sentence-end-double-space, sentence-end-without-period): Move from fill.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40483
diff
changeset
|
143 |
|
53721
40f76024a6c1
(sentence-end-without-space): New variable.
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
144 (defcustom sentence-end-without-space |
|
104323
ffe0ad555039
Change to utf-8. Adjust coding cookie.
Kenichi Handa <handa@m17n.org>
parents:
101218
diff
changeset
|
145 "。.?!" |
|
70270
925aeac78b9e
(sentence-end-without-space): Fix safety predicate.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
70221
diff
changeset
|
146 "String of characters that end sentence without following spaces. |
|
54977
4c4f4e6f6bbf
(sentence-end) <function>: New fun with default value taken
Juri Linkov <juri@jurta.org>
parents:
54014
diff
changeset
|
147 |
|
4c4f4e6f6bbf
(sentence-end) <function>: New fun with default value taken
Juri Linkov <juri@jurta.org>
parents:
54014
diff
changeset
|
148 This value is used by the function `sentence-end' to construct the |
|
57405
ba8ab430f898
(sentence-end-double-space)
Luc Teirlinck <teirllm@auburn.edu>
parents:
57282
diff
changeset
|
149 regexp describing the end of a sentence, when the value of the variable |
|
ba8ab430f898
(sentence-end-double-space)
Luc Teirlinck <teirllm@auburn.edu>
parents:
57282
diff
changeset
|
150 `sentence-end' is nil. See Info node `(elisp)Standard Regexps'." |
|
53721
40f76024a6c1
(sentence-end-without-space): New variable.
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
151 :group 'paragraphs |
|
40f76024a6c1
(sentence-end-without-space): New variable.
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
152 :type 'string) |
|
92948
73a01bf5cb80
* faces.el (xw-defined-colors):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79719
diff
changeset
|
153 (put 'sentence-end-without-space 'safe-local-variable 'stringp) |
|
53721
40f76024a6c1
(sentence-end-without-space): New variable.
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
154 |
|
54977
4c4f4e6f6bbf
(sentence-end) <function>: New fun with default value taken
Juri Linkov <juri@jurta.org>
parents:
54014
diff
changeset
|
155 (defcustom sentence-end nil |
|
70270
925aeac78b9e
(sentence-end-without-space): Fix safety predicate.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
70221
diff
changeset
|
156 "Regexp describing the end of a sentence. |
| 37415 | 157 The value includes the whitespace following the sentence. |
|
2503
fb3509fdf8b7
Sat Apr 10 00:39:29 1993 Jim Blandy (jimb@totoro.cs.oberlin.edu)
Jim Blandy <jimb@redhat.com>
parents:
2308
diff
changeset
|
158 All paragraph boundaries also end sentences, regardless. |
|
fb3509fdf8b7
Sat Apr 10 00:39:29 1993 Jim Blandy (jimb@totoro.cs.oberlin.edu)
Jim Blandy <jimb@redhat.com>
parents:
2308
diff
changeset
|
159 |
|
54977
4c4f4e6f6bbf
(sentence-end) <function>: New fun with default value taken
Juri Linkov <juri@jurta.org>
parents:
54014
diff
changeset
|
160 The value nil means to use the default value defined by the |
|
4c4f4e6f6bbf
(sentence-end) <function>: New fun with default value taken
Juri Linkov <juri@jurta.org>
parents:
54014
diff
changeset
|
161 function `sentence-end'. You should always use this function |
|
4c4f4e6f6bbf
(sentence-end) <function>: New fun with default value taken
Juri Linkov <juri@jurta.org>
parents:
54014
diff
changeset
|
162 to obtain the value of this variable." |
|
4c4f4e6f6bbf
(sentence-end) <function>: New fun with default value taken
Juri Linkov <juri@jurta.org>
parents:
54014
diff
changeset
|
163 :group 'paragraphs |
|
4c4f4e6f6bbf
(sentence-end) <function>: New fun with default value taken
Juri Linkov <juri@jurta.org>
parents:
54014
diff
changeset
|
164 :type '(choice regexp (const :tag "Use default value" nil))) |
|
92948
73a01bf5cb80
* faces.el (xw-defined-colors):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79719
diff
changeset
|
165 (put 'sentence-end 'safe-local-variable 'string-or-null-p) |
|
54977
4c4f4e6f6bbf
(sentence-end) <function>: New fun with default value taken
Juri Linkov <juri@jurta.org>
parents:
54014
diff
changeset
|
166 |
|
104323
ffe0ad555039
Change to utf-8. Adjust coding cookie.
Kenichi Handa <handa@m17n.org>
parents:
101218
diff
changeset
|
167 (defcustom sentence-end-base "[.?!][]\"'”)}]*" |
|
70270
925aeac78b9e
(sentence-end-without-space): Fix safety predicate.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
70221
diff
changeset
|
168 "Regexp matching the basic end of a sentence, not including following space." |
|
66292
15de85d4b7fe
(sentence-end-base): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
64751
diff
changeset
|
169 :group 'paragraphs |
|
15de85d4b7fe
(sentence-end-base): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
64751
diff
changeset
|
170 :type 'string |
|
15de85d4b7fe
(sentence-end-base): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
64751
diff
changeset
|
171 :version "22.1") |
|
92948
73a01bf5cb80
* faces.el (xw-defined-colors):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79719
diff
changeset
|
172 (put 'sentence-end-base 'safe-local-variable 'stringp) |
|
66292
15de85d4b7fe
(sentence-end-base): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
64751
diff
changeset
|
173 |
|
54977
4c4f4e6f6bbf
(sentence-end) <function>: New fun with default value taken
Juri Linkov <juri@jurta.org>
parents:
54014
diff
changeset
|
174 (defun sentence-end () |
|
4c4f4e6f6bbf
(sentence-end) <function>: New fun with default value taken
Juri Linkov <juri@jurta.org>
parents:
54014
diff
changeset
|
175 "Return the regexp describing the end of a sentence. |
| 24472 | 176 |
|
54977
4c4f4e6f6bbf
(sentence-end) <function>: New fun with default value taken
Juri Linkov <juri@jurta.org>
parents:
54014
diff
changeset
|
177 This function returns either the value of the variable `sentence-end' |
|
4c4f4e6f6bbf
(sentence-end) <function>: New fun with default value taken
Juri Linkov <juri@jurta.org>
parents:
54014
diff
changeset
|
178 if it is non-nil, or the default value constructed from the |
|
66292
15de85d4b7fe
(sentence-end-base): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
64751
diff
changeset
|
179 variables `sentence-end-base', `sentence-end-double-space', |
|
15de85d4b7fe
(sentence-end-base): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
64751
diff
changeset
|
180 `sentence-end-without-period' and `sentence-end-without-space'. |
|
15de85d4b7fe
(sentence-end-base): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
64751
diff
changeset
|
181 |
|
15de85d4b7fe
(sentence-end-base): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
64751
diff
changeset
|
182 The default value specifies that in order to be recognized as the |
|
15de85d4b7fe
(sentence-end-base): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
64751
diff
changeset
|
183 end of a sentence, the ending period, question mark, or exclamation point |
|
15de85d4b7fe
(sentence-end-base): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
64751
diff
changeset
|
184 must be followed by two spaces, with perhaps some closing delimiters |
|
15de85d4b7fe
(sentence-end-base): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
64751
diff
changeset
|
185 in between. See Info node `(elisp)Standard Regexps'." |
|
54977
4c4f4e6f6bbf
(sentence-end) <function>: New fun with default value taken
Juri Linkov <juri@jurta.org>
parents:
54014
diff
changeset
|
186 (or sentence-end |
|
101218
854925519fc6
(sentence-end): Accept non-break space.
Richard M. Stallman <rms@gnu.org>
parents:
101137
diff
changeset
|
187 ;; We accept non-break space along with space. |
|
854925519fc6
(sentence-end): Accept non-break space.
Richard M. Stallman <rms@gnu.org>
parents:
101137
diff
changeset
|
188 (concat (if sentence-end-without-period "\\w[ \u00a0][ \u00a0]\\|") |
|
66292
15de85d4b7fe
(sentence-end-base): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
64751
diff
changeset
|
189 "\\(" |
|
15de85d4b7fe
(sentence-end-base): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
64751
diff
changeset
|
190 sentence-end-base |
|
54977
4c4f4e6f6bbf
(sentence-end) <function>: New fun with default value taken
Juri Linkov <juri@jurta.org>
parents:
54014
diff
changeset
|
191 (if sentence-end-double-space |
|
101218
854925519fc6
(sentence-end): Accept non-break space.
Richard M. Stallman <rms@gnu.org>
parents:
101137
diff
changeset
|
192 "\\($\\|[ \u00a0]$\\|\t\\|[ \u00a0][ \u00a0]\\)" "\\($\\|[\t \u00a0]\\)") |
|
66292
15de85d4b7fe
(sentence-end-base): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
64751
diff
changeset
|
193 "\\|[" sentence-end-without-space "]+" |
|
15de85d4b7fe
(sentence-end-base): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
64751
diff
changeset
|
194 "\\)" |
|
101218
854925519fc6
(sentence-end): Accept non-break space.
Richard M. Stallman <rms@gnu.org>
parents:
101137
diff
changeset
|
195 "[ \u00a0\t\n]*"))) |
| 264 | 196 |
| 19475 | 197 (defcustom page-delimiter "^\014" |
|
70270
925aeac78b9e
(sentence-end-without-space): Fix safety predicate.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
70221
diff
changeset
|
198 "Regexp describing line-beginnings that separate pages." |
| 19475 | 199 :group 'paragraphs |
| 200 :type 'regexp) | |
|
92948
73a01bf5cb80
* faces.el (xw-defined-colors):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79719
diff
changeset
|
201 (put 'page-delimiter 'safe-local-variable 'stringp) |
| 264 | 202 |
| 19475 | 203 (defcustom paragraph-ignore-fill-prefix nil |
|
70270
925aeac78b9e
(sentence-end-without-space): Fix safety predicate.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
70221
diff
changeset
|
204 "Non-nil means the paragraph commands are not affected by `fill-prefix'. |
| 19475 | 205 This is desirable in modes where blank lines are the paragraph delimiters." |
| 206 :group 'paragraphs | |
| 207 :type 'boolean) | |
|
92948
73a01bf5cb80
* faces.el (xw-defined-colors):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79719
diff
changeset
|
208 (put 'paragraph-ignore-fill-prefix 'safe-local-variable 'booleanp) |
| 264 | 209 |
| 36 | 210 (defun forward-paragraph (&optional arg) |
| 211 "Move forward to end of paragraph. | |
|
16757
e1c2e9a44236
(forward-paragraph, backward-paragraph): Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents:
16687
diff
changeset
|
212 With argument ARG, do it ARG times; |
|
e1c2e9a44236
(forward-paragraph, backward-paragraph): Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents:
16687
diff
changeset
|
213 a negative argument ARG = -N means move backward N paragraphs. |
| 36 | 214 |
| 215 A line which `paragraph-start' matches either separates paragraphs | |
| 216 \(if `paragraph-separate' matches it also) or is the first line of a paragraph. | |
| 217 A paragraph end is the beginning of a line which is not part of the paragraph | |
|
47829
353dae5e0134
(forward-paragraph): Keep track of remaining paragraphs to skip more carefully.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47750
diff
changeset
|
218 to which the end of the previous line belongs, or the end of the buffer. |
|
353dae5e0134
(forward-paragraph): Keep track of remaining paragraphs to skip more carefully.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47750
diff
changeset
|
219 Returns the count of paragraphs left to move." |
|
93550
d4564d8c8835
(forward-paragraph, backward-paragraph, forward-sentence,
Chong Yidong <cyd@stupidchicken.com>
parents:
92948
diff
changeset
|
220 (interactive "^p") |
| 36 | 221 (or arg (setq arg 1)) |
|
26055
cf5dd9e8bf79
(forward-sentence, forward-paragraph):
Gerd Moellmann <gerd@gnu.org>
parents:
25551
diff
changeset
|
222 (let* ((opoint (point)) |
|
cf5dd9e8bf79
(forward-sentence, forward-paragraph):
Gerd Moellmann <gerd@gnu.org>
parents:
25551
diff
changeset
|
223 (fill-prefix-regexp |
| 36 | 224 (and fill-prefix (not (equal fill-prefix "")) |
| 225 (not paragraph-ignore-fill-prefix) | |
| 226 (regexp-quote fill-prefix))) | |
|
10864
33769cbeb58e
(paragraph-start, paragraph-separate): Default values no longer start
Boris Goldowsky <boris@gnu.org>
parents:
10464
diff
changeset
|
227 ;; Remove ^ from paragraph-start and paragraph-sep if they are there. |
|
33769cbeb58e
(paragraph-start, paragraph-separate): Default values no longer start
Boris Goldowsky <boris@gnu.org>
parents:
10464
diff
changeset
|
228 ;; These regexps shouldn't be anchored, because we look for them |
|
33769cbeb58e
(paragraph-start, paragraph-separate): Default values no longer start
Boris Goldowsky <boris@gnu.org>
parents:
10464
diff
changeset
|
229 ;; starting at the left-margin. This allows paragraph commands to |
|
33769cbeb58e
(paragraph-start, paragraph-separate): Default values no longer start
Boris Goldowsky <boris@gnu.org>
parents:
10464
diff
changeset
|
230 ;; work normally with indented text. |
|
33769cbeb58e
(paragraph-start, paragraph-separate): Default values no longer start
Boris Goldowsky <boris@gnu.org>
parents:
10464
diff
changeset
|
231 ;; This hack will not find problem cases like "whatever\\|^something". |
|
40485
ca833879aa7b
(sentence-end-double-space, sentence-end-without-period): Move from fill.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40483
diff
changeset
|
232 (parstart (if (and (not (equal "" paragraph-start)) |
|
ca833879aa7b
(sentence-end-double-space, sentence-end-without-period): Move from fill.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40483
diff
changeset
|
233 (equal ?^ (aref paragraph-start 0))) |
|
ca833879aa7b
(sentence-end-double-space, sentence-end-without-period): Move from fill.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40483
diff
changeset
|
234 (substring paragraph-start 1) |
|
ca833879aa7b
(sentence-end-double-space, sentence-end-without-period): Move from fill.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40483
diff
changeset
|
235 paragraph-start)) |
|
ca833879aa7b
(sentence-end-double-space, sentence-end-without-period): Move from fill.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40483
diff
changeset
|
236 (parsep (if (and (not (equal "" paragraph-separate)) |
|
ca833879aa7b
(sentence-end-double-space, sentence-end-without-period): Move from fill.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40483
diff
changeset
|
237 (equal ?^ (aref paragraph-separate 0))) |
|
ca833879aa7b
(sentence-end-double-space, sentence-end-without-period): Move from fill.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40483
diff
changeset
|
238 (substring paragraph-separate 1) |
|
ca833879aa7b
(sentence-end-double-space, sentence-end-without-period): Move from fill.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40483
diff
changeset
|
239 paragraph-separate)) |
|
ca833879aa7b
(sentence-end-double-space, sentence-end-without-period): Move from fill.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40483
diff
changeset
|
240 (parsep |
| 36 | 241 (if fill-prefix-regexp |
|
40485
ca833879aa7b
(sentence-end-double-space, sentence-end-without-period): Move from fill.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40483
diff
changeset
|
242 (concat parsep "\\|" |
| 36 | 243 fill-prefix-regexp "[ \t]*$") |
|
40485
ca833879aa7b
(sentence-end-double-space, sentence-end-without-period): Move from fill.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40483
diff
changeset
|
244 parsep)) |
|
10864
33769cbeb58e
(paragraph-start, paragraph-separate): Default values no longer start
Boris Goldowsky <boris@gnu.org>
parents:
10464
diff
changeset
|
245 ;; This is used for searching. |
|
40485
ca833879aa7b
(sentence-end-double-space, sentence-end-without-period): Move from fill.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40483
diff
changeset
|
246 (sp-parstart (concat "^[ \t]*\\(?:" parstart "\\|" parsep "\\)")) |
|
22953
fbeacfb09096
(forward-paragraph): Fix the logic for handling beginning of buffer
Richard M. Stallman <rms@gnu.org>
parents:
19527
diff
changeset
|
247 start found-start) |
|
5608
c4c662362d39
(forward-paragraph): If moving back we find nothing
Richard M. Stallman <rms@gnu.org>
parents:
4585
diff
changeset
|
248 (while (and (< arg 0) (not (bobp))) |
|
40485
ca833879aa7b
(sentence-end-double-space, sentence-end-without-period): Move from fill.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40483
diff
changeset
|
249 (if (and (not (looking-at parsep)) |
|
10424
6bcb93cec6f8
(forward-paragraph): Notice use-hard-newlines value.
Richard M. Stallman <rms@gnu.org>
parents:
9169
diff
changeset
|
250 (re-search-backward "^\n" (max (1- (point)) (point-min)) t) |
|
40485
ca833879aa7b
(sentence-end-double-space, sentence-end-without-period): Move from fill.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40483
diff
changeset
|
251 (looking-at parsep)) |
|
47829
353dae5e0134
(forward-paragraph): Keep track of remaining paragraphs to skip more carefully.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47750
diff
changeset
|
252 (setq arg (1+ arg)) |
|
12717
8e153c7bbd90
(forward-paragraph): Don't move back over a line
Richard M. Stallman <rms@gnu.org>
parents:
11235
diff
changeset
|
253 (setq start (point)) |
|
5608
c4c662362d39
(forward-paragraph): If moving back we find nothing
Richard M. Stallman <rms@gnu.org>
parents:
4585
diff
changeset
|
254 ;; Move back over paragraph-separating lines. |
| 36 | 255 (forward-char -1) (beginning-of-line) |
|
10424
6bcb93cec6f8
(forward-paragraph): Notice use-hard-newlines value.
Richard M. Stallman <rms@gnu.org>
parents:
9169
diff
changeset
|
256 (while (and (not (bobp)) |
|
10864
33769cbeb58e
(paragraph-start, paragraph-separate): Default values no longer start
Boris Goldowsky <boris@gnu.org>
parents:
10464
diff
changeset
|
257 (progn (move-to-left-margin) |
|
40485
ca833879aa7b
(sentence-end-double-space, sentence-end-without-period): Move from fill.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40483
diff
changeset
|
258 (looking-at parsep))) |
| 34655 | 259 (forward-line -1)) |
|
5608
c4c662362d39
(forward-paragraph): If moving back we find nothing
Richard M. Stallman <rms@gnu.org>
parents:
4585
diff
changeset
|
260 (if (bobp) |
|
c4c662362d39
(forward-paragraph): If moving back we find nothing
Richard M. Stallman <rms@gnu.org>
parents:
4585
diff
changeset
|
261 nil |
|
47829
353dae5e0134
(forward-paragraph): Keep track of remaining paragraphs to skip more carefully.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47750
diff
changeset
|
262 (setq arg (1+ arg)) |
|
5608
c4c662362d39
(forward-paragraph): If moving back we find nothing
Richard M. Stallman <rms@gnu.org>
parents:
4585
diff
changeset
|
263 ;; Go to end of the previous (non-separating) line. |
|
c4c662362d39
(forward-paragraph): If moving back we find nothing
Richard M. Stallman <rms@gnu.org>
parents:
4585
diff
changeset
|
264 (end-of-line) |
|
c4c662362d39
(forward-paragraph): If moving back we find nothing
Richard M. Stallman <rms@gnu.org>
parents:
4585
diff
changeset
|
265 ;; Search back for line that starts or separates paragraphs. |
|
c4c662362d39
(forward-paragraph): If moving back we find nothing
Richard M. Stallman <rms@gnu.org>
parents:
4585
diff
changeset
|
266 (if (if fill-prefix-regexp |
|
40485
ca833879aa7b
(sentence-end-double-space, sentence-end-without-period): Move from fill.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40483
diff
changeset
|
267 ;; There is a fill prefix; it overrides parstart. |
|
12717
8e153c7bbd90
(forward-paragraph): Don't move back over a line
Richard M. Stallman <rms@gnu.org>
parents:
11235
diff
changeset
|
268 (let (multiple-lines) |
|
10864
33769cbeb58e
(paragraph-start, paragraph-separate): Default values no longer start
Boris Goldowsky <boris@gnu.org>
parents:
10464
diff
changeset
|
269 (while (and (progn (beginning-of-line) (not (bobp))) |
|
33769cbeb58e
(paragraph-start, paragraph-separate): Default values no longer start
Boris Goldowsky <boris@gnu.org>
parents:
10464
diff
changeset
|
270 (progn (move-to-left-margin) |
|
40485
ca833879aa7b
(sentence-end-double-space, sentence-end-without-period): Move from fill.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40483
diff
changeset
|
271 (not (looking-at parsep))) |
|
10864
33769cbeb58e
(paragraph-start, paragraph-separate): Default values no longer start
Boris Goldowsky <boris@gnu.org>
parents:
10464
diff
changeset
|
272 (looking-at fill-prefix-regexp)) |
| 34655 | 273 (unless (= (point) start) |
| 274 (setq multiple-lines t)) | |
|
10864
33769cbeb58e
(paragraph-start, paragraph-separate): Default values no longer start
Boris Goldowsky <boris@gnu.org>
parents:
10464
diff
changeset
|
275 (forward-line -1)) |
|
12717
8e153c7bbd90
(forward-paragraph): Don't move back over a line
Richard M. Stallman <rms@gnu.org>
parents:
11235
diff
changeset
|
276 (move-to-left-margin) |
|
40485
ca833879aa7b
(sentence-end-double-space, sentence-end-without-period): Move from fill.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40483
diff
changeset
|
277 ;; This deleted code caused a long hanging-indent line |
|
ca833879aa7b
(sentence-end-double-space, sentence-end-without-period): Move from fill.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40483
diff
changeset
|
278 ;; not to be filled together with the following lines. |
|
ca833879aa7b
(sentence-end-double-space, sentence-end-without-period): Move from fill.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40483
diff
changeset
|
279 ;; ;; Don't move back over a line before the paragraph |
|
ca833879aa7b
(sentence-end-double-space, sentence-end-without-period): Move from fill.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40483
diff
changeset
|
280 ;; ;; which doesn't start with fill-prefix |
|
ca833879aa7b
(sentence-end-double-space, sentence-end-without-period): Move from fill.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40483
diff
changeset
|
281 ;; ;; unless that is the only line we've moved over. |
|
ca833879aa7b
(sentence-end-double-space, sentence-end-without-period): Move from fill.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40483
diff
changeset
|
282 ;; (and (not (looking-at fill-prefix-regexp)) |
|
ca833879aa7b
(sentence-end-double-space, sentence-end-without-period): Move from fill.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40483
diff
changeset
|
283 ;; multiple-lines |
|
ca833879aa7b
(sentence-end-double-space, sentence-end-without-period): Move from fill.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40483
diff
changeset
|
284 ;; (forward-line 1)) |
|
12717
8e153c7bbd90
(forward-paragraph): Don't move back over a line
Richard M. Stallman <rms@gnu.org>
parents:
11235
diff
changeset
|
285 (not (bobp))) |
|
40485
ca833879aa7b
(sentence-end-double-space, sentence-end-without-period): Move from fill.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40483
diff
changeset
|
286 (while (and (re-search-backward sp-parstart nil 1) |
|
22953
fbeacfb09096
(forward-paragraph): Fix the logic for handling beginning of buffer
Richard M. Stallman <rms@gnu.org>
parents:
19527
diff
changeset
|
287 (setq found-start t) |
|
10864
33769cbeb58e
(paragraph-start, paragraph-separate): Default values no longer start
Boris Goldowsky <boris@gnu.org>
parents:
10464
diff
changeset
|
288 ;; Found a candidate, but need to check if it is a |
|
40485
ca833879aa7b
(sentence-end-double-space, sentence-end-without-period): Move from fill.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40483
diff
changeset
|
289 ;; REAL parstart. |
|
10864
33769cbeb58e
(paragraph-start, paragraph-separate): Default values no longer start
Boris Goldowsky <boris@gnu.org>
parents:
10464
diff
changeset
|
290 (progn (setq start (point)) |
|
33769cbeb58e
(paragraph-start, paragraph-separate): Default values no longer start
Boris Goldowsky <boris@gnu.org>
parents:
10464
diff
changeset
|
291 (move-to-left-margin) |
|
40485
ca833879aa7b
(sentence-end-double-space, sentence-end-without-period): Move from fill.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40483
diff
changeset
|
292 (not (looking-at parsep))) |
|
ca833879aa7b
(sentence-end-double-space, sentence-end-without-period): Move from fill.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40483
diff
changeset
|
293 (not (and (looking-at parstart) |
|
ca833879aa7b
(sentence-end-double-space, sentence-end-without-period): Move from fill.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40483
diff
changeset
|
294 (or (not use-hard-newlines) |
|
57282
a35c6f55300f
(forward-paragraph): Avoid args-out-of-range error when point winds up
Luc Teirlinck <teirllm@auburn.edu>
parents:
56941
diff
changeset
|
295 (bobp) |
|
a35c6f55300f
(forward-paragraph): Avoid args-out-of-range error when point winds up
Luc Teirlinck <teirllm@auburn.edu>
parents:
56941
diff
changeset
|
296 (get-text-property |
|
a35c6f55300f
(forward-paragraph): Avoid args-out-of-range error when point winds up
Luc Teirlinck <teirllm@auburn.edu>
parents:
56941
diff
changeset
|
297 (1- start) 'hard))))) |
|
22953
fbeacfb09096
(forward-paragraph): Fix the logic for handling beginning of buffer
Richard M. Stallman <rms@gnu.org>
parents:
19527
diff
changeset
|
298 (setq found-start nil) |
|
10864
33769cbeb58e
(paragraph-start, paragraph-separate): Default values no longer start
Boris Goldowsky <boris@gnu.org>
parents:
10464
diff
changeset
|
299 (goto-char start)) |
|
22953
fbeacfb09096
(forward-paragraph): Fix the logic for handling beginning of buffer
Richard M. Stallman <rms@gnu.org>
parents:
19527
diff
changeset
|
300 found-start) |
|
47829
353dae5e0134
(forward-paragraph): Keep track of remaining paragraphs to skip more carefully.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47750
diff
changeset
|
301 ;; Found one. |
|
353dae5e0134
(forward-paragraph): Keep track of remaining paragraphs to skip more carefully.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47750
diff
changeset
|
302 (progn |
|
5608
c4c662362d39
(forward-paragraph): If moving back we find nothing
Richard M. Stallman <rms@gnu.org>
parents:
4585
diff
changeset
|
303 ;; Move forward over paragraph separators. |
|
c4c662362d39
(forward-paragraph): If moving back we find nothing
Richard M. Stallman <rms@gnu.org>
parents:
4585
diff
changeset
|
304 ;; We know this cannot reach the place we started |
|
c4c662362d39
(forward-paragraph): If moving back we find nothing
Richard M. Stallman <rms@gnu.org>
parents:
4585
diff
changeset
|
305 ;; because we know we moved back over a non-separator. |
|
10864
33769cbeb58e
(paragraph-start, paragraph-separate): Default values no longer start
Boris Goldowsky <boris@gnu.org>
parents:
10464
diff
changeset
|
306 (while (and (not (eobp)) |
|
33769cbeb58e
(paragraph-start, paragraph-separate): Default values no longer start
Boris Goldowsky <boris@gnu.org>
parents:
10464
diff
changeset
|
307 (progn (move-to-left-margin) |
|
40485
ca833879aa7b
(sentence-end-double-space, sentence-end-without-period): Move from fill.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40483
diff
changeset
|
308 (looking-at parsep))) |
|
5608
c4c662362d39
(forward-paragraph): If moving back we find nothing
Richard M. Stallman <rms@gnu.org>
parents:
4585
diff
changeset
|
309 (forward-line 1)) |
|
10864
33769cbeb58e
(paragraph-start, paragraph-separate): Default values no longer start
Boris Goldowsky <boris@gnu.org>
parents:
10464
diff
changeset
|
310 ;; If line before paragraph is just margin, back up to there. |
|
33769cbeb58e
(paragraph-start, paragraph-separate): Default values no longer start
Boris Goldowsky <boris@gnu.org>
parents:
10464
diff
changeset
|
311 (end-of-line 0) |
|
33769cbeb58e
(paragraph-start, paragraph-separate): Default values no longer start
Boris Goldowsky <boris@gnu.org>
parents:
10464
diff
changeset
|
312 (if (> (current-column) (current-left-margin)) |
|
33769cbeb58e
(paragraph-start, paragraph-separate): Default values no longer start
Boris Goldowsky <boris@gnu.org>
parents:
10464
diff
changeset
|
313 (forward-char 1) |
|
33769cbeb58e
(paragraph-start, paragraph-separate): Default values no longer start
Boris Goldowsky <boris@gnu.org>
parents:
10464
diff
changeset
|
314 (skip-chars-backward " \t") |
|
33769cbeb58e
(paragraph-start, paragraph-separate): Default values no longer start
Boris Goldowsky <boris@gnu.org>
parents:
10464
diff
changeset
|
315 (if (not (bolp)) |
|
33769cbeb58e
(paragraph-start, paragraph-separate): Default values no longer start
Boris Goldowsky <boris@gnu.org>
parents:
10464
diff
changeset
|
316 (forward-line 1)))) |
|
5608
c4c662362d39
(forward-paragraph): If moving back we find nothing
Richard M. Stallman <rms@gnu.org>
parents:
4585
diff
changeset
|
317 ;; No starter or separator line => use buffer beg. |
|
47829
353dae5e0134
(forward-paragraph): Keep track of remaining paragraphs to skip more carefully.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47750
diff
changeset
|
318 (goto-char (point-min)))))) |
|
40485
ca833879aa7b
(sentence-end-double-space, sentence-end-without-period): Move from fill.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40483
diff
changeset
|
319 |
|
5608
c4c662362d39
(forward-paragraph): If moving back we find nothing
Richard M. Stallman <rms@gnu.org>
parents:
4585
diff
changeset
|
320 (while (and (> arg 0) (not (eobp))) |
|
47829
353dae5e0134
(forward-paragraph): Keep track of remaining paragraphs to skip more carefully.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47750
diff
changeset
|
321 ;; Move forward over separator lines... |
|
353dae5e0134
(forward-paragraph): Keep track of remaining paragraphs to skip more carefully.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47750
diff
changeset
|
322 (while (and (not (eobp)) |
|
353dae5e0134
(forward-paragraph): Keep track of remaining paragraphs to skip more carefully.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47750
diff
changeset
|
323 (progn (move-to-left-margin) (not (eobp))) |
|
353dae5e0134
(forward-paragraph): Keep track of remaining paragraphs to skip more carefully.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47750
diff
changeset
|
324 (looking-at parsep)) |
|
353dae5e0134
(forward-paragraph): Keep track of remaining paragraphs to skip more carefully.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47750
diff
changeset
|
325 (forward-line 1)) |
|
353dae5e0134
(forward-paragraph): Keep track of remaining paragraphs to skip more carefully.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47750
diff
changeset
|
326 (unless (eobp) (setq arg (1- arg))) |
|
353dae5e0134
(forward-paragraph): Keep track of remaining paragraphs to skip more carefully.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47750
diff
changeset
|
327 ;; ... and one more line. |
|
353dae5e0134
(forward-paragraph): Keep track of remaining paragraphs to skip more carefully.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47750
diff
changeset
|
328 (forward-line 1) |
| 36 | 329 (if fill-prefix-regexp |
|
40485
ca833879aa7b
(sentence-end-double-space, sentence-end-without-period): Move from fill.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40483
diff
changeset
|
330 ;; There is a fill prefix; it overrides parstart. |
| 36 | 331 (while (and (not (eobp)) |
|
10864
33769cbeb58e
(paragraph-start, paragraph-separate): Default values no longer start
Boris Goldowsky <boris@gnu.org>
parents:
10464
diff
changeset
|
332 (progn (move-to-left-margin) (not (eobp))) |
|
40485
ca833879aa7b
(sentence-end-double-space, sentence-end-without-period): Move from fill.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40483
diff
changeset
|
333 (not (looking-at parsep)) |
| 36 | 334 (looking-at fill-prefix-regexp)) |
| 335 (forward-line 1)) | |
|
40485
ca833879aa7b
(sentence-end-double-space, sentence-end-without-period): Move from fill.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40483
diff
changeset
|
336 (while (and (re-search-forward sp-parstart nil 1) |
|
10864
33769cbeb58e
(paragraph-start, paragraph-separate): Default values no longer start
Boris Goldowsky <boris@gnu.org>
parents:
10464
diff
changeset
|
337 (progn (setq start (match-beginning 0)) |
|
33769cbeb58e
(paragraph-start, paragraph-separate): Default values no longer start
Boris Goldowsky <boris@gnu.org>
parents:
10464
diff
changeset
|
338 (goto-char start) |
|
12804
1619fcabdb99
(forward-paragraph): Don't overlook a paragraph-start
Richard M. Stallman <rms@gnu.org>
parents:
12717
diff
changeset
|
339 (not (eobp))) |
|
1619fcabdb99
(forward-paragraph): Don't overlook a paragraph-start
Richard M. Stallman <rms@gnu.org>
parents:
12717
diff
changeset
|
340 (progn (move-to-left-margin) |
|
40485
ca833879aa7b
(sentence-end-double-space, sentence-end-without-period): Move from fill.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40483
diff
changeset
|
341 (not (looking-at parsep))) |
|
ca833879aa7b
(sentence-end-double-space, sentence-end-without-period): Move from fill.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40483
diff
changeset
|
342 (or (not (looking-at parstart)) |
|
10864
33769cbeb58e
(paragraph-start, paragraph-separate): Default values no longer start
Boris Goldowsky <boris@gnu.org>
parents:
10464
diff
changeset
|
343 (and use-hard-newlines |
|
33769cbeb58e
(paragraph-start, paragraph-separate): Default values no longer start
Boris Goldowsky <boris@gnu.org>
parents:
10464
diff
changeset
|
344 (not (get-text-property (1- start) 'hard))))) |
|
10424
6bcb93cec6f8
(forward-paragraph): Notice use-hard-newlines value.
Richard M. Stallman <rms@gnu.org>
parents:
9169
diff
changeset
|
345 (forward-char 1)) |
|
6bcb93cec6f8
(forward-paragraph): Notice use-hard-newlines value.
Richard M. Stallman <rms@gnu.org>
parents:
9169
diff
changeset
|
346 (if (< (point) (point-max)) |
|
47829
353dae5e0134
(forward-paragraph): Keep track of remaining paragraphs to skip more carefully.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47750
diff
changeset
|
347 (goto-char start)))) |
|
47750
75f4a9fc7b34
(forward-paragraph): Return the steps left.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43384
diff
changeset
|
348 (constrain-to-field nil opoint t) |
|
75f4a9fc7b34
(forward-paragraph): Return the steps left.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43384
diff
changeset
|
349 ;; Return the number of steps that could not be done. |
|
75f4a9fc7b34
(forward-paragraph): Return the steps left.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43384
diff
changeset
|
350 arg)) |
| 36 | 351 |
| 352 (defun backward-paragraph (&optional arg) | |
| 353 "Move backward to start of paragraph. | |
|
16757
e1c2e9a44236
(forward-paragraph, backward-paragraph): Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents:
16687
diff
changeset
|
354 With argument ARG, do it ARG times; |
|
e1c2e9a44236
(forward-paragraph, backward-paragraph): Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents:
16687
diff
changeset
|
355 a negative argument ARG = -N means move forward N paragraphs. |
| 36 | 356 |
| 237 | 357 A paragraph start is the beginning of a line which is a |
|
80507
65aec0fc638d
Docstring change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79719
diff
changeset
|
358 `paragraph-start' or which is ordinary text and follows a |
|
65aec0fc638d
Docstring change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79719
diff
changeset
|
359 `paragraph-separate'ing line; except: if the first real line of a |
| 237 | 360 paragraph is preceded by a blank line, the paragraph starts at that |
| 361 blank line. | |
| 362 | |
| 363 See `forward-paragraph' for more information." | |
|
93550
d4564d8c8835
(forward-paragraph, backward-paragraph, forward-sentence,
Chong Yidong <cyd@stupidchicken.com>
parents:
92948
diff
changeset
|
364 (interactive "^p") |
| 36 | 365 (or arg (setq arg 1)) |
| 366 (forward-paragraph (- arg))) | |
| 367 | |
|
59179
4b5e5c2f1ee0
(mark-paragraph): New arg ALLOW-EXTEND
Richard M. Stallman <rms@gnu.org>
parents:
58919
diff
changeset
|
368 (defun mark-paragraph (&optional arg allow-extend) |
| 36 | 369 "Put point at beginning of this paragraph, mark at end. |
|
41709
df0a6a02b580
(mark-paragraph): Clarify doc. Clarify
Kai Gro?johann <kgrossjo@eu.uu.net>
parents:
40485
diff
changeset
|
370 The paragraph marked is the one that contains point or follows point. |
|
df0a6a02b580
(mark-paragraph): Clarify doc. Clarify
Kai Gro?johann <kgrossjo@eu.uu.net>
parents:
40485
diff
changeset
|
371 |
|
df0a6a02b580
(mark-paragraph): Clarify doc. Clarify
Kai Gro?johann <kgrossjo@eu.uu.net>
parents:
40485
diff
changeset
|
372 With argument ARG, puts mark at end of a following paragraph, so that |
|
df0a6a02b580
(mark-paragraph): Clarify doc. Clarify
Kai Gro?johann <kgrossjo@eu.uu.net>
parents:
40485
diff
changeset
|
373 the number of paragraphs marked equals ARG. |
|
df0a6a02b580
(mark-paragraph): Clarify doc. Clarify
Kai Gro?johann <kgrossjo@eu.uu.net>
parents:
40485
diff
changeset
|
374 |
|
df0a6a02b580
(mark-paragraph): Clarify doc. Clarify
Kai Gro?johann <kgrossjo@eu.uu.net>
parents:
40485
diff
changeset
|
375 If ARG is negative, point is put at end of this paragraph, mark is put |
|
43301
898b4b31410f
* lisp/simple.el (mark-word): Mark more if repeated.
Kai Gro?johann <kgrossjo@eu.uu.net>
parents:
41709
diff
changeset
|
376 at beginning of this or a previous paragraph. |
|
898b4b31410f
* lisp/simple.el (mark-word): Mark more if repeated.
Kai Gro?johann <kgrossjo@eu.uu.net>
parents:
41709
diff
changeset
|
377 |
|
59179
4b5e5c2f1ee0
(mark-paragraph): New arg ALLOW-EXTEND
Richard M. Stallman <rms@gnu.org>
parents:
58919
diff
changeset
|
378 Interactively, if this command is repeated |
|
64751
5b1a238fcbb4
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64084
diff
changeset
|
379 or (in Transient Mark mode) if the mark is active, |
|
59179
4b5e5c2f1ee0
(mark-paragraph): New arg ALLOW-EXTEND
Richard M. Stallman <rms@gnu.org>
parents:
58919
diff
changeset
|
380 it marks the next ARG paragraphs after the ones already marked." |
|
4b5e5c2f1ee0
(mark-paragraph): New arg ALLOW-EXTEND
Richard M. Stallman <rms@gnu.org>
parents:
58919
diff
changeset
|
381 (interactive "p\np") |
|
43384
cc3ba2d0d471
* emacs-lisp/lisp.el (mark-defun): Don't leave multiple marks
Kai Gro?johann <kgrossjo@eu.uu.net>
parents:
43301
diff
changeset
|
382 (unless arg (setq arg 1)) |
|
cc3ba2d0d471
* emacs-lisp/lisp.el (mark-defun): Don't leave multiple marks
Kai Gro?johann <kgrossjo@eu.uu.net>
parents:
43301
diff
changeset
|
383 (when (zerop arg) |
|
cc3ba2d0d471
* emacs-lisp/lisp.el (mark-defun): Don't leave multiple marks
Kai Gro?johann <kgrossjo@eu.uu.net>
parents:
43301
diff
changeset
|
384 (error "Cannot mark zero paragraphs")) |
|
59179
4b5e5c2f1ee0
(mark-paragraph): New arg ALLOW-EXTEND
Richard M. Stallman <rms@gnu.org>
parents:
58919
diff
changeset
|
385 (cond ((and allow-extend |
|
4b5e5c2f1ee0
(mark-paragraph): New arg ALLOW-EXTEND
Richard M. Stallman <rms@gnu.org>
parents:
58919
diff
changeset
|
386 (or (and (eq last-command this-command) (mark t)) |
|
4b5e5c2f1ee0
(mark-paragraph): New arg ALLOW-EXTEND
Richard M. Stallman <rms@gnu.org>
parents:
58919
diff
changeset
|
387 (and transient-mark-mode mark-active))) |
|
43384
cc3ba2d0d471
* emacs-lisp/lisp.el (mark-defun): Don't leave multiple marks
Kai Gro?johann <kgrossjo@eu.uu.net>
parents:
43301
diff
changeset
|
388 (set-mark |
|
cc3ba2d0d471
* emacs-lisp/lisp.el (mark-defun): Don't leave multiple marks
Kai Gro?johann <kgrossjo@eu.uu.net>
parents:
43301
diff
changeset
|
389 (save-excursion |
|
cc3ba2d0d471
* emacs-lisp/lisp.el (mark-defun): Don't leave multiple marks
Kai Gro?johann <kgrossjo@eu.uu.net>
parents:
43301
diff
changeset
|
390 (goto-char (mark)) |
|
cc3ba2d0d471
* emacs-lisp/lisp.el (mark-defun): Don't leave multiple marks
Kai Gro?johann <kgrossjo@eu.uu.net>
parents:
43301
diff
changeset
|
391 (forward-paragraph arg) |
|
cc3ba2d0d471
* emacs-lisp/lisp.el (mark-defun): Don't leave multiple marks
Kai Gro?johann <kgrossjo@eu.uu.net>
parents:
43301
diff
changeset
|
392 (point)))) |
|
cc3ba2d0d471
* emacs-lisp/lisp.el (mark-defun): Don't leave multiple marks
Kai Gro?johann <kgrossjo@eu.uu.net>
parents:
43301
diff
changeset
|
393 (t |
|
cc3ba2d0d471
* emacs-lisp/lisp.el (mark-defun): Don't leave multiple marks
Kai Gro?johann <kgrossjo@eu.uu.net>
parents:
43301
diff
changeset
|
394 (forward-paragraph arg) |
|
cc3ba2d0d471
* emacs-lisp/lisp.el (mark-defun): Don't leave multiple marks
Kai Gro?johann <kgrossjo@eu.uu.net>
parents:
43301
diff
changeset
|
395 (push-mark nil t t) |
|
cc3ba2d0d471
* emacs-lisp/lisp.el (mark-defun): Don't leave multiple marks
Kai Gro?johann <kgrossjo@eu.uu.net>
parents:
43301
diff
changeset
|
396 (backward-paragraph arg)))) |
| 36 | 397 |
| 398 (defun kill-paragraph (arg) | |
| 399 "Kill forward to end of paragraph. | |
| 400 With arg N, kill forward to Nth end of paragraph; | |
| 401 negative arg -N means kill backward to Nth start of paragraph." | |
|
27837
46fedf13d52e
(kill-paragraph, backward-kill-paragraph)
Dave Love <fx@gnu.org>
parents:
26055
diff
changeset
|
402 (interactive "p") |
|
7064
19a84bb30e9e
(kill-paragraph): Don't use save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
5653
diff
changeset
|
403 (kill-region (point) (progn (forward-paragraph arg) (point)))) |
| 36 | 404 |
| 405 (defun backward-kill-paragraph (arg) | |
| 406 "Kill back to start of paragraph. | |
| 407 With arg N, kill back to Nth start of paragraph; | |
| 408 negative arg -N means kill forward to Nth end of paragraph." | |
|
27837
46fedf13d52e
(kill-paragraph, backward-kill-paragraph)
Dave Love <fx@gnu.org>
parents:
26055
diff
changeset
|
409 (interactive "p") |
|
26055
cf5dd9e8bf79
(forward-sentence, forward-paragraph):
Gerd Moellmann <gerd@gnu.org>
parents:
25551
diff
changeset
|
410 (kill-region (point) (progn (backward-paragraph arg) (point)))) |
| 36 | 411 |
| 412 (defun transpose-paragraphs (arg) | |
|
107143
38f0f81b2f1f
Improve docs of some transposition functions.
Glenn Morris <rgm@gnu.org>
parents:
106815
diff
changeset
|
413 "Interchange the current paragraph with the next one. |
|
38f0f81b2f1f
Improve docs of some transposition functions.
Glenn Morris <rgm@gnu.org>
parents:
106815
diff
changeset
|
414 With prefix argument ARG a non-zero integer, moves the current |
|
38f0f81b2f1f
Improve docs of some transposition functions.
Glenn Morris <rgm@gnu.org>
parents:
106815
diff
changeset
|
415 paragraph past ARG paragraphs, leaving point after the current paragraph. |
|
38f0f81b2f1f
Improve docs of some transposition functions.
Glenn Morris <rgm@gnu.org>
parents:
106815
diff
changeset
|
416 If ARG is positive, moves the current paragraph forwards, if |
|
38f0f81b2f1f
Improve docs of some transposition functions.
Glenn Morris <rgm@gnu.org>
parents:
106815
diff
changeset
|
417 ARG is negative moves it backwards. If ARG is zero, exchanges |
|
38f0f81b2f1f
Improve docs of some transposition functions.
Glenn Morris <rgm@gnu.org>
parents:
106815
diff
changeset
|
418 the current paragraph with the one containing the mark." |
| 36 | 419 (interactive "*p") |
| 420 (transpose-subr 'forward-paragraph arg)) | |
| 421 | |
| 422 (defun start-of-paragraph-text () | |
| 423 (let ((opoint (point)) npoint) | |
| 424 (forward-paragraph -1) | |
| 425 (setq npoint (point)) | |
| 426 (skip-chars-forward " \t\n") | |
| 68 | 427 ;; If the range of blank lines found spans the original start point, |
| 428 ;; try again from the beginning of it. | |
| 429 ;; Must be careful to avoid infinite loop | |
| 430 ;; when following a single return at start of buffer. | |
| 431 (if (and (>= (point) opoint) (< npoint opoint)) | |
| 36 | 432 (progn |
| 433 (goto-char npoint) | |
| 434 (if (> npoint (point-min)) | |
| 435 (start-of-paragraph-text)))))) | |
| 436 | |
| 437 (defun end-of-paragraph-text () | |
| 438 (let ((opoint (point))) | |
| 439 (forward-paragraph 1) | |
| 440 (if (eq (preceding-char) ?\n) (forward-char -1)) | |
| 441 (if (<= (point) opoint) | |
| 442 (progn | |
| 443 (forward-char 1) | |
| 444 (if (< (point) (point-max)) | |
| 445 (end-of-paragraph-text)))))) | |
| 446 | |
| 447 (defun forward-sentence (&optional arg) | |
|
79458
6659094e0d7d
(forward-sentence): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
78225
diff
changeset
|
448 "Move forward to next end of sentence. With argument, repeat. |
|
6659094e0d7d
(forward-sentence): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
78225
diff
changeset
|
449 With negative argument, move backward repeatedly to start of sentence. |
| 36 | 450 |
| 237 | 451 The variable `sentence-end' is a regular expression that matches ends of |
| 452 sentences. Also, every paragraph boundary terminates sentences as well." | |
|
93550
d4564d8c8835
(forward-paragraph, backward-paragraph, forward-sentence,
Chong Yidong <cyd@stupidchicken.com>
parents:
92948
diff
changeset
|
453 (interactive "^p") |
| 36 | 454 (or arg (setq arg 1)) |
|
54977
4c4f4e6f6bbf
(sentence-end) <function>: New fun with default value taken
Juri Linkov <juri@jurta.org>
parents:
54014
diff
changeset
|
455 (let ((opoint (point)) |
|
4c4f4e6f6bbf
(sentence-end) <function>: New fun with default value taken
Juri Linkov <juri@jurta.org>
parents:
54014
diff
changeset
|
456 (sentence-end (sentence-end))) |
|
26055
cf5dd9e8bf79
(forward-sentence, forward-paragraph):
Gerd Moellmann <gerd@gnu.org>
parents:
25551
diff
changeset
|
457 (while (< arg 0) |
|
38715
06ad87abb7a4
(forward-sentence): Avoid building
Gerd Moellmann <gerd@gnu.org>
parents:
38412
diff
changeset
|
458 (let ((pos (point)) |
|
101137
8da5cd0a4dd8
(forward-sentence): Change limit of
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
100908
diff
changeset
|
459 ;; We used to use (start-of-paragraph-text), but this can |
|
8da5cd0a4dd8
(forward-sentence): Change limit of
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
100908
diff
changeset
|
460 ;; prevent sentence-end from matching if it is anchored at |
|
8da5cd0a4dd8
(forward-sentence): Change limit of
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
100908
diff
changeset
|
461 ;; BOL and the paragraph starts indented. |
|
8da5cd0a4dd8
(forward-sentence): Change limit of
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
100908
diff
changeset
|
462 (par-beg (save-excursion (backward-paragraph) (point)))) |
|
38715
06ad87abb7a4
(forward-sentence): Avoid building
Gerd Moellmann <gerd@gnu.org>
parents:
38412
diff
changeset
|
463 (if (and (re-search-backward sentence-end par-beg t) |
|
06ad87abb7a4
(forward-sentence): Avoid building
Gerd Moellmann <gerd@gnu.org>
parents:
38412
diff
changeset
|
464 (or (< (match-end 0) pos) |
|
06ad87abb7a4
(forward-sentence): Avoid building
Gerd Moellmann <gerd@gnu.org>
parents:
38412
diff
changeset
|
465 (re-search-backward sentence-end par-beg t))) |
|
06ad87abb7a4
(forward-sentence): Avoid building
Gerd Moellmann <gerd@gnu.org>
parents:
38412
diff
changeset
|
466 (goto-char (match-end 0)) |
|
26055
cf5dd9e8bf79
(forward-sentence, forward-paragraph):
Gerd Moellmann <gerd@gnu.org>
parents:
25551
diff
changeset
|
467 (goto-char par-beg))) |
|
cf5dd9e8bf79
(forward-sentence, forward-paragraph):
Gerd Moellmann <gerd@gnu.org>
parents:
25551
diff
changeset
|
468 (setq arg (1+ arg))) |
|
cf5dd9e8bf79
(forward-sentence, forward-paragraph):
Gerd Moellmann <gerd@gnu.org>
parents:
25551
diff
changeset
|
469 (while (> arg 0) |
|
cf5dd9e8bf79
(forward-sentence, forward-paragraph):
Gerd Moellmann <gerd@gnu.org>
parents:
25551
diff
changeset
|
470 (let ((par-end (save-excursion (end-of-paragraph-text) (point)))) |
|
cf5dd9e8bf79
(forward-sentence, forward-paragraph):
Gerd Moellmann <gerd@gnu.org>
parents:
25551
diff
changeset
|
471 (if (re-search-forward sentence-end par-end t) |
|
cf5dd9e8bf79
(forward-sentence, forward-paragraph):
Gerd Moellmann <gerd@gnu.org>
parents:
25551
diff
changeset
|
472 (skip-chars-backward " \t\n") |
|
cf5dd9e8bf79
(forward-sentence, forward-paragraph):
Gerd Moellmann <gerd@gnu.org>
parents:
25551
diff
changeset
|
473 (goto-char par-end))) |
|
cf5dd9e8bf79
(forward-sentence, forward-paragraph):
Gerd Moellmann <gerd@gnu.org>
parents:
25551
diff
changeset
|
474 (setq arg (1- arg))) |
|
cf5dd9e8bf79
(forward-sentence, forward-paragraph):
Gerd Moellmann <gerd@gnu.org>
parents:
25551
diff
changeset
|
475 (constrain-to-field nil opoint t))) |
| 36 | 476 |
|
51159
7d324048f346
(repunctuate-sentences): New function.
Richard M. Stallman <rms@gnu.org>
parents:
49949
diff
changeset
|
477 (defun repunctuate-sentences () |
|
7d324048f346
(repunctuate-sentences): New function.
Richard M. Stallman <rms@gnu.org>
parents:
49949
diff
changeset
|
478 "Put two spaces at the end of sentences from point to the end of buffer. |
|
7d324048f346
(repunctuate-sentences): New function.
Richard M. Stallman <rms@gnu.org>
parents:
49949
diff
changeset
|
479 It works using `query-replace-regexp'." |
|
54014
6296b1d1ae51
* net/telnet.el (telnet-interrupt-subjob): Move doc string to the correct place.
Eli Zaretskii <eliz@is.elta.co.il>
parents:
53721
diff
changeset
|
480 (interactive) |
|
51159
7d324048f346
(repunctuate-sentences): New function.
Richard M. Stallman <rms@gnu.org>
parents:
49949
diff
changeset
|
481 (query-replace-regexp "\\([]\"')]?\\)\\([.?!]\\)\\([]\"')]?\\) +" |
|
7d324048f346
(repunctuate-sentences): New function.
Richard M. Stallman <rms@gnu.org>
parents:
49949
diff
changeset
|
482 "\\1\\2\\3 ")) |
|
7d324048f346
(repunctuate-sentences): New function.
Richard M. Stallman <rms@gnu.org>
parents:
49949
diff
changeset
|
483 |
|
7d324048f346
(repunctuate-sentences): New function.
Richard M. Stallman <rms@gnu.org>
parents:
49949
diff
changeset
|
484 |
| 36 | 485 (defun backward-sentence (&optional arg) |
| 486 "Move backward to start of sentence. With arg, do it arg times. | |
| 237 | 487 See `forward-sentence' for more information." |
|
93550
d4564d8c8835
(forward-paragraph, backward-paragraph, forward-sentence,
Chong Yidong <cyd@stupidchicken.com>
parents:
92948
diff
changeset
|
488 (interactive "^p") |
| 36 | 489 (or arg (setq arg 1)) |
| 490 (forward-sentence (- arg))) | |
| 491 | |
| 492 (defun kill-sentence (&optional arg) | |
| 493 "Kill from point to end of sentence. | |
| 494 With arg, repeat; negative arg -N means kill back to Nth start of sentence." | |
|
27837
46fedf13d52e
(kill-paragraph, backward-kill-paragraph)
Dave Love <fx@gnu.org>
parents:
26055
diff
changeset
|
495 (interactive "p") |
|
7064
19a84bb30e9e
(kill-paragraph): Don't use save-excursion.
Richard M. Stallman <rms@gnu.org>
parents:
5653
diff
changeset
|
496 (kill-region (point) (progn (forward-sentence arg) (point)))) |
| 36 | 497 |
| 498 (defun backward-kill-sentence (&optional arg) | |
| 499 "Kill back from point to start of sentence. | |
| 500 With arg, repeat, or kill forward to Nth end of sentence if negative arg -N." | |
|
27837
46fedf13d52e
(kill-paragraph, backward-kill-paragraph)
Dave Love <fx@gnu.org>
parents:
26055
diff
changeset
|
501 (interactive "p") |
|
26055
cf5dd9e8bf79
(forward-sentence, forward-paragraph):
Gerd Moellmann <gerd@gnu.org>
parents:
25551
diff
changeset
|
502 (kill-region (point) (progn (backward-sentence arg) (point)))) |
| 36 | 503 |
| 504 (defun mark-end-of-sentence (arg) | |
|
43301
898b4b31410f
* lisp/simple.el (mark-word): Mark more if repeated.
Kai Gro?johann <kgrossjo@eu.uu.net>
parents:
41709
diff
changeset
|
505 "Put mark at end of sentence. Arg works as in `forward-sentence'. |
|
898b4b31410f
* lisp/simple.el (mark-word): Mark more if repeated.
Kai Gro?johann <kgrossjo@eu.uu.net>
parents:
41709
diff
changeset
|
506 If this command is repeated, it marks the next ARG sentences after the |
|
898b4b31410f
* lisp/simple.el (mark-word): Mark more if repeated.
Kai Gro?johann <kgrossjo@eu.uu.net>
parents:
41709
diff
changeset
|
507 ones already marked." |
| 36 | 508 (interactive "p") |
| 509 (push-mark | |
|
43301
898b4b31410f
* lisp/simple.el (mark-word): Mark more if repeated.
Kai Gro?johann <kgrossjo@eu.uu.net>
parents:
41709
diff
changeset
|
510 (save-excursion |
|
898b4b31410f
* lisp/simple.el (mark-word): Mark more if repeated.
Kai Gro?johann <kgrossjo@eu.uu.net>
parents:
41709
diff
changeset
|
511 (if (and (eq last-command this-command) (mark t)) |
|
898b4b31410f
* lisp/simple.el (mark-word): Mark more if repeated.
Kai Gro?johann <kgrossjo@eu.uu.net>
parents:
41709
diff
changeset
|
512 (goto-char (mark))) |
|
898b4b31410f
* lisp/simple.el (mark-word): Mark more if repeated.
Kai Gro?johann <kgrossjo@eu.uu.net>
parents:
41709
diff
changeset
|
513 (forward-sentence arg) |
|
898b4b31410f
* lisp/simple.el (mark-word): Mark more if repeated.
Kai Gro?johann <kgrossjo@eu.uu.net>
parents:
41709
diff
changeset
|
514 (point)) |
|
898b4b31410f
* lisp/simple.el (mark-word): Mark more if repeated.
Kai Gro?johann <kgrossjo@eu.uu.net>
parents:
41709
diff
changeset
|
515 nil t)) |
| 36 | 516 |
| 517 (defun transpose-sentences (arg) | |
|
107143
38f0f81b2f1f
Improve docs of some transposition functions.
Glenn Morris <rgm@gnu.org>
parents:
106815
diff
changeset
|
518 "Interchange the current sentence with the next one. |
|
38f0f81b2f1f
Improve docs of some transposition functions.
Glenn Morris <rgm@gnu.org>
parents:
106815
diff
changeset
|
519 With prefix argument ARG a non-zero integer, moves the current |
|
38f0f81b2f1f
Improve docs of some transposition functions.
Glenn Morris <rgm@gnu.org>
parents:
106815
diff
changeset
|
520 sentence past ARG sentences, leaving point after the current sentence. |
|
38f0f81b2f1f
Improve docs of some transposition functions.
Glenn Morris <rgm@gnu.org>
parents:
106815
diff
changeset
|
521 If ARG is positive, moves the current sentence forwards, if |
|
38f0f81b2f1f
Improve docs of some transposition functions.
Glenn Morris <rgm@gnu.org>
parents:
106815
diff
changeset
|
522 ARG is negative moves it backwards. If ARG is zero, exchanges |
|
38f0f81b2f1f
Improve docs of some transposition functions.
Glenn Morris <rgm@gnu.org>
parents:
106815
diff
changeset
|
523 the current sentence with the one containing the mark." |
| 36 | 524 (interactive "*p") |
| 525 (transpose-subr 'forward-sentence arg)) | |
|
659
505130d1ddf8
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
269
diff
changeset
|
526 |
|
66422
ee446efaafaf
(sentence-end-base): Use real chars, so as
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
66292
diff
changeset
|
527 ;; Local Variables: |
|
104323
ffe0ad555039
Change to utf-8. Adjust coding cookie.
Kenichi Handa <handa@m17n.org>
parents:
101218
diff
changeset
|
528 ;; coding: utf-8 |
|
66422
ee446efaafaf
(sentence-end-base): Use real chars, so as
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
66292
diff
changeset
|
529 ;; End: |
|
49949
098ddf9714e8
(sentence-end): Add Chinese and Japanese characters.
Kenichi Handa <handa@m17n.org>
parents:
49599
diff
changeset
|
530 |
|
66422
ee446efaafaf
(sentence-end-base): Use real chars, so as
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
66292
diff
changeset
|
531 ;; arch-tag: e727eb1a-527a-4464-b9d7-9d3ec0d1a575 |
|
659
505130d1ddf8
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
269
diff
changeset
|
532 ;;; paragraphs.el ends here |
