aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuri Linkov2004-04-18 22:08:03 +0000
committerJuri Linkov2004-04-18 22:08:03 +0000
commit32e40471c90640963e37a53f04cb6c6f7e60b60b (patch)
treee9189ed814942b9190de593e7322404fc43628a8
parent455a2afc5fcca05595e428785142e9240b3a9da7 (diff)
downloademacs-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.el62
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."
120This is relevant for filling. See also `sentence-end-without-period' 120This is relevant for filling. See also `sentence-end-without-period'
121and `colon-double-space'. 121and `colon-double-space'.
122 122
123If you change this, you should also change `sentence-end'. See Info 123This value is used by the function `sentence-end' to construct the
124node `Sentences'." 124regexp describing the end of a sentence, in case when the value of
125the 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.
130For example, a sentence in Thai text ends with double space but 131For example, a sentence in Thai text ends with double space but
131without a period." 132without a period.
133
134This value is used by the function `sentence-end' to construct the
135regexp describing the end of a sentence, in case when the value of
136the 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.
138If you change this, you should also change `sentence-end'. See Info 143
139node `Sentences'." 144This value is used by the function `sentence-end' to construct the
145regexp describing the end of a sentence, in case when the value of
146the 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.
154The value includes the whitespace following the sentence. 152The value includes the whitespace following the sentence.
155All paragraph boundaries also end sentences, regardless. 153All paragraph boundaries also end sentences, regardless.
156 154
157The default value specifies that in order to be recognized as the end 155The value nil means to use the default value defined by the
158of a sentence, the ending period, question mark, or exclamation point 156function `sentence-end'. You should always use this function
159must be followed by two spaces, unless it's inside some sort of quotes 157to obtain the value of this variable."
160or parenthesis.
161
162See 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
164This function returns either the value of the variable `sentence-end'
165if it is non-nil, or the default value constructed from the
166variables `sentence-end-double-space', `sentence-end-without-period'
167and `sentence-end-without-space'. The default value specifies
168that in order to be recognized as the end of a sentence, the
169ending period, question mark, or exclamation point must be
170followed by two spaces, unless it's inside some sort of quotes or
171parenthesis. 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
411sentences. Also, every paragraph boundary terminates sentences as well." 424sentences. 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))))