emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Mistakes in TUTORIAL.fr


From: Juri Linkov
Subject: Re: Mistakes in TUTORIAL.fr
Date: Sun, 11 Apr 2004 01:45:17 +0300
User-agent: Gnus/5.110002 (No Gnus v0.2) Emacs/21.3.50 (gnu/linux)

Juri Linkov <address@hidden> writes:
> Kenichi Handa <address@hidden> writes:
>> we may have to change sentence-end in the TUTORIAL.fr buffer.
>
> There is a better variable to do this: `sentence-end-double-space'.
> It could be set to nil in local variables.

In the previous post I mistakenly suggested to use
`sentence-end-double-space' instead of `sentence-end'.

Really, changing `sentence-end-double-space' does not affect the value
of `sentence-end' at all.  This is very confusing and inconvenient!

Why not to construct the value of `sentence-end' dynamically?

I propose the following patch:

Index: emacs/lisp/textmodes/paragraphs.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/textmodes/paragraphs.el,v
retrieving revision 1.69
diff -u -r1.69 paragraphs.el
--- emacs/lisp/textmodes/paragraphs.el  16 Feb 2004 19:34:25 -0000      1.69
+++ emacs/lisp/textmodes/paragraphs.el  10 Apr 2004 22:04:57 -0000
@@ -140,16 +140,17 @@
   :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]*"))
+(defun sentence-end ()
+  (if (and sentence-end (not (equal sentence-end "")))
+      sentence-end
+    (concat (if sentence-end-without-period "\\w  \\|")
+            "\\([.?!][]\"')}]*"
+            (if sentence-end-double-space
+                "\\($\\| $\\|\t\\|  \\)" "\\($\\|[\t ]\\)")
+            "\\|[" sentence-end-without-space "]+\\)"
+            "[ \t\n]*")))
+
+(defcustom sentence-end ""
   "*Regexp describing the end of a sentence.
 The value includes the whitespace following the sentence.
 All paragraph boundaries also end sentences, regardless.
@@ -411,7 +412,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))))
Index: emacs/lisp/textmodes/fill.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/textmodes/fill.el,v
retrieving revision 1.171
diff -u -r1.171 fill.el
--- emacs/lisp/textmodes/fill.el        4 Apr 2004 20:18:44 -0000       1.171
+++ emacs/lisp/textmodes/fill.el        11 Apr 2004 02:04:59 -0000
@@ -155,7 +155,7 @@
 and `sentence-end-without-period').
 Remove indentation from each line."
   (interactive "*r")
-  (let ((end-spc-re (concat "\\(" sentence-end "\\) *\\|  +")))
+  (let ((end-spc-re (concat "\\(" (sentence-end) "\\) *\\|  +")))
     (save-excursion
       (goto-char beg)
       ;; Nuke tabs; they get screwed up in a fill.
@@ -349,7 +349,7 @@
      (save-excursion
        (skip-chars-backward ". ")
        (and (looking-at "\\.")
-           (not (looking-at sentence-end))))
+           (not (looking-at (sentence-end)))))
      ;; Don't split a line if the rest would look like a new paragraph.
      (unless use-hard-newlines
        (save-excursion
@@ -424,10 +424,10 @@
   ;; loses on split abbrevs ("Mr.\nSmith")
   (let ((eol-double-space-re
         (cond
-         ((not colon-double-space) (concat sentence-end "$"))
+         ((not colon-double-space) (concat (sentence-end) "$"))
          ;; Try to add the : inside the `sentence-end' regexp.
-         ((string-match "\\[[^][]*\\(\\.\\)[^][]*\\]" sentence-end)
-          (concat (replace-match ".:" nil nil sentence-end 1) "$"))
+         ((string-match "\\[[^][]*\\(\\.\\)[^][]*\\]" (sentence-end))
+          (concat (replace-match ".:" nil nil (sentence-end) 1) "$"))
          ;; Can't find the right spot to insert the colon.
          (t "[.?!:][])}\"']*$")))
        (sentence-end-without-space-list
Index: emacs/lisp/progmodes/cc-cmds.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/progmodes/cc-cmds.el,v
retrieving revision 1.35
diff -u -r1.35 cc-cmds.el
--- emacs/lisp/progmodes/cc-cmds.el     16 Nov 2003 16:55:07 -0000      1.35
+++ emacs/lisp/progmodes/cc-cmds.el     11 Apr 2004 02:05:00 -0000
@@ -1488,7 +1488,7 @@
                                     (save-excursion
                                       (beginning-of-line)
                                       (or (not (re-search-backward
-                                                sentence-end
+                                                (sentence-end)
                                                 (c-point 'bopl)
                                                 t))
                                           (< (match-end 0)

-- 
Juri Linkov
http://www.jurta.org/emacs/





reply via email to

[Prev in Thread] Current Thread [Next in Thread]