diff options
| author | Juri Linkov | 2004-04-18 22:08:03 +0000 |
|---|---|---|
| committer | Juri Linkov | 2004-04-18 22:08:03 +0000 |
| commit | 32e40471c90640963e37a53f04cb6c6f7e60b60b (patch) | |
| tree | e9189ed814942b9190de593e7322404fc43628a8 | |
| parent | 455a2afc5fcca05595e428785142e9240b3a9da7 (diff) | |
| download | emacs-32e40471c90640963e37a53f04cb6c6f7e60b60b.tar.gz emacs-32e40471c90640963e37a53f04cb6c6f7e60b60b.zip | |
(sentence-end) <function>: New fun with default value taken
from the variable `sentence-end'.
(sentence-end) <defcustom>: Set default to nil. Doc fix.
Add nil const to :type.
(sentence-end-without-period, sentence-end-double-space)
(sentence-end-without-space): Doc fix.
(forward-sentence): Use function `sentence-end' instead of
variable `sentence-end'.
| -rw-r--r-- | lisp/textmodes/paragraphs.el | 62 |
1 files changed, 38 insertions, 24 deletions
diff --git a/lisp/textmodes/paragraphs.el b/lisp/textmodes/paragraphs.el index f7595e24cb5..a86be8646c9 100644 --- a/lisp/textmodes/paragraphs.el +++ b/lisp/textmodes/paragraphs.el | |||
| @@ -120,49 +120,62 @@ text indented by a margin setting." | |||
| 120 | This is relevant for filling. See also `sentence-end-without-period' | 120 | This is relevant for filling. See also `sentence-end-without-period' |
| 121 | and `colon-double-space'. | 121 | and `colon-double-space'. |
| 122 | 122 | ||
| 123 | If you change this, you should also change `sentence-end'. See Info | 123 | This value is used by the function `sentence-end' to construct the |
| 124 | node `Sentences'." | 124 | regexp describing the end of a sentence, in case when the value of |
| 125 | the variable `sentence-end' is nil. See Info node `Sentences'." | ||
| 125 | :type 'boolean | 126 | :type 'boolean |
| 126 | :group 'fill) | 127 | :group 'fill) |
| 127 | 128 | ||
| 128 | (defcustom sentence-end-without-period nil | 129 | (defcustom sentence-end-without-period nil |
| 129 | "*Non-nil means a sentence will end without a period. | 130 | "*Non-nil means a sentence will end without a period. |
| 130 | For example, a sentence in Thai text ends with double space but | 131 | For example, a sentence in Thai text ends with double space but |
| 131 | without a period." | 132 | without a period. |
| 133 | |||
| 134 | This value is used by the function `sentence-end' to construct the | ||
| 135 | regexp describing the end of a sentence, in case when the value of | ||
| 136 | the variable `sentence-end' is nil. See Info node `Sentences'." | ||
| 132 | :type 'boolean | 137 | :type 'boolean |
| 133 | :group 'fill) | 138 | :group 'fill) |
| 134 | 139 | ||
| 135 | (defcustom sentence-end-without-space | 140 | (defcustom sentence-end-without-space |
| 136 | "$B!#!%!)!*$A!##.#?#!$(0!$!%!)!*$(G!$!%!)!*(B" | 141 | "$B!#!%!)!*$A!##.#?#!$(0!$!%!)!*$(G!$!%!)!*(B" |
| 137 | "*String containing characters that end sentence without following spaces. | 142 | "*String containing characters that end sentence without following spaces. |
| 138 | If you change this, you should also change `sentence-end'. See Info | 143 | |
| 139 | node `Sentences'." | 144 | This value is used by the function `sentence-end' to construct the |
| 145 | regexp describing the end of a sentence, in case when the value of | ||
| 146 | the variable `sentence-end' is nil. See Info node `Sentences'." | ||
| 140 | :group 'paragraphs | 147 | :group 'paragraphs |
| 141 | :type 'string) | 148 | :type 'string) |
| 142 | 149 | ||
| 143 | (defcustom sentence-end | 150 | (defcustom sentence-end nil |
| 144 | (purecopy | ||
| 145 | ;; This is a bit stupid since it's not auto-updated when the | ||
| 146 | ;; other variables are changes, but it's still useful info. | ||
| 147 | (concat (if sentence-end-without-period "\\w \\|") | ||
| 148 | "\\([.?!][]\"')}]*" | ||
| 149 | (if sentence-end-double-space | ||
| 150 | "\\($\\| $\\|\t\\| \\)" "\\($\\|[\t ]\\)") | ||
| 151 | "\\|[" sentence-end-without-space "]+\\)" | ||
| 152 | "[ \t\n]*")) | ||
| 153 | "*Regexp describing the end of a sentence. | 151 | "*Regexp describing the end of a sentence. |
| 154 | The value includes the whitespace following the sentence. | 152 | The value includes the whitespace following the sentence. |
| 155 | All paragraph boundaries also end sentences, regardless. | 153 | All paragraph boundaries also end sentences, regardless. |
| 156 | 154 | ||
| 157 | The default value specifies that in order to be recognized as the end | 155 | The value nil means to use the default value defined by the |
| 158 | of a sentence, the ending period, question mark, or exclamation point | 156 | function `sentence-end'. You should always use this function |
| 159 | must be followed by two spaces, unless it's inside some sort of quotes | 157 | to obtain the value of this variable." |
| 160 | or parenthesis. | ||
| 161 | |||
| 162 | See also the variable `sentence-end-double-space', the variable | ||
| 163 | `sentence-end-without-period' and Info node `Sentences'." | ||
| 164 | :group 'paragraphs | 158 | :group 'paragraphs |
| 165 | :type 'regexp) | 159 | :type '(choice regexp (const :tag "Use default value" nil))) |
| 160 | |||
| 161 | (defun sentence-end () | ||
| 162 | "Return the regexp describing the end of a sentence. | ||
| 163 | |||
| 164 | This function returns either the value of the variable `sentence-end' | ||
| 165 | if it is non-nil, or the default value constructed from the | ||
| 166 | variables `sentence-end-double-space', `sentence-end-without-period' | ||
| 167 | and `sentence-end-without-space'. The default value specifies | ||
| 168 | that in order to be recognized as the end of a sentence, the | ||
| 169 | ending period, question mark, or exclamation point must be | ||
| 170 | followed by two spaces, unless it's inside some sort of quotes or | ||
| 171 | parenthesis. See Info node `Sentences'." | ||
| 172 | (or sentence-end | ||
| 173 | (concat (if sentence-end-without-period "\\w \\|") | ||
| 174 | "\\([.?!][]\"')}]*" | ||
| 175 | (if sentence-end-double-space | ||
| 176 | "\\($\\| $\\|\t\\| \\)" "\\($\\|[\t ]\\)") | ||
| 177 | "\\|[" sentence-end-without-space "]+\\)" | ||
| 178 | "[ \t\n]*"))) | ||
| 166 | 179 | ||
| 167 | (defcustom page-delimiter "^\014" | 180 | (defcustom page-delimiter "^\014" |
| 168 | "*Regexp describing line-beginnings that separate pages." | 181 | "*Regexp describing line-beginnings that separate pages." |
| @@ -411,7 +424,8 @@ The variable `sentence-end' is a regular expression that matches ends of | |||
| 411 | sentences. Also, every paragraph boundary terminates sentences as well." | 424 | sentences. Also, every paragraph boundary terminates sentences as well." |
| 412 | (interactive "p") | 425 | (interactive "p") |
| 413 | (or arg (setq arg 1)) | 426 | (or arg (setq arg 1)) |
| 414 | (let ((opoint (point))) | 427 | (let ((opoint (point)) |
| 428 | (sentence-end (sentence-end))) | ||
| 415 | (while (< arg 0) | 429 | (while (< arg 0) |
| 416 | (let ((pos (point)) | 430 | (let ((pos (point)) |
| 417 | (par-beg (save-excursion (start-of-paragraph-text) (point)))) | 431 | (par-beg (save-excursion (start-of-paragraph-text) (point)))) |