# HG changeset patch # User Juri Linkov # Date 1082326083 0 # Node ID 4c4f4e6f6bbf3eabb0757529876d743ecd8722e4 # Parent f0e658f3bd2e5b6c693f1c2eb13f431a2693e1b5 (sentence-end) : New fun with default value taken from the variable `sentence-end'. (sentence-end) : 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'. diff -r f0e658f3bd2e -r 4c4f4e6f6bbf lisp/textmodes/paragraphs.el --- a/lisp/textmodes/paragraphs.el Sun Apr 18 20:04:24 2004 +0000 +++ b/lisp/textmodes/paragraphs.el Sun Apr 18 22:08:03 2004 +0000 @@ -120,49 +120,62 @@ This is relevant for filling. See also `sentence-end-without-period' and `colon-double-space'. -If you change this, you should also change `sentence-end'. See Info -node `Sentences'." +This value is used by the function `sentence-end' to construct the +regexp describing the end of a sentence, in case when the value of +the variable `sentence-end' is nil. See Info node `Sentences'." :type 'boolean :group 'fill) (defcustom sentence-end-without-period nil "*Non-nil means a sentence will end without a period. For example, a sentence in Thai text ends with double space but -without a period." +without a period. + +This value is used by the function `sentence-end' to construct the +regexp describing the end of a sentence, in case when the value of +the variable `sentence-end' is nil. See Info node `Sentences'." :type 'boolean :group 'fill) (defcustom sentence-end-without-space "$B!#!%!)!*$A!##.#?#!$(0!$!%!)!*$(G!$!%!)!*(B" "*String containing characters that end sentence without following spaces. -If you change this, you should also change `sentence-end'. See Info -node `Sentences'." + +This value is used by the function `sentence-end' to construct the +regexp describing the end of a sentence, in case when the value of +the variable `sentence-end' is nil. See Info node `Sentences'." :group 'paragraphs :type 'string) -(defcustom sentence-end - (purecopy - ;; This is a bit stupid since it's not auto-updated when the - ;; other variables are changes, but it's still useful info. - (concat (if sentence-end-without-period "\\w \\|") - "\\([.?!][]\"')}]*" - (if sentence-end-double-space - "\\($\\| $\\|\t\\| \\)" "\\($\\|[\t ]\\)") - "\\|[" sentence-end-without-space "]+\\)" - "[ \t\n]*")) +(defcustom sentence-end nil "*Regexp describing the end of a sentence. The value includes the whitespace following the sentence. All paragraph boundaries also end sentences, regardless. -The default value specifies that in order to be recognized as the end -of a sentence, the ending period, question mark, or exclamation point -must be followed by two spaces, unless it's inside some sort of quotes -or parenthesis. +The value nil means to use the default value defined by the +function `sentence-end'. You should always use this function +to obtain the value of this variable." + :group 'paragraphs + :type '(choice regexp (const :tag "Use default value" nil))) + +(defun sentence-end () + "Return the regexp describing the end of a sentence. -See also the variable `sentence-end-double-space', the variable -`sentence-end-without-period' and Info node `Sentences'." - :group 'paragraphs - :type 'regexp) +This function returns either the value of the variable `sentence-end' +if it is non-nil, or the default value constructed from the +variables `sentence-end-double-space', `sentence-end-without-period' +and `sentence-end-without-space'. The default value specifies +that in order to be recognized as the end of a sentence, the +ending period, question mark, or exclamation point must be +followed by two spaces, unless it's inside some sort of quotes or +parenthesis. See Info node `Sentences'." + (or sentence-end + (concat (if sentence-end-without-period "\\w \\|") + "\\([.?!][]\"')}]*" + (if sentence-end-double-space + "\\($\\| $\\|\t\\| \\)" "\\($\\|[\t ]\\)") + "\\|[" sentence-end-without-space "]+\\)" + "[ \t\n]*"))) (defcustom page-delimiter "^\014" "*Regexp describing line-beginnings that separate pages." @@ -411,7 +424,8 @@ sentences. Also, every paragraph boundary terminates sentences as well." (interactive "p") (or arg (setq arg 1)) - (let ((opoint (point))) + (let ((opoint (point)) + (sentence-end (sentence-end))) (while (< arg 0) (let ((pos (point)) (par-beg (save-excursion (start-of-paragraph-text) (point))))