bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#7240: 24.0.50; backward-sentence sometimes overshoots (and breaks do


From: Wolfgang Jenkner
Subject: bug#7240: 24.0.50; backward-sentence sometimes overshoots (and breaks doctor)
Date: Mon, 18 Oct 2010 18:49:42 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (berkeley-unix)

Create a buffer like this

---------- Buffer: foo ---------

This sentence follows a newline.
---------- Buffer: foo ---------

Set point somewhere after the first character of the second line and
type M-a (which runs backward-sentence).

Point is now at the beginning of the first line, but it should be at
the beginning of the second line (cf. (emacs)Top > Text > Sentences).

A somewhat amusing consequence of this bug is that the doctor has been
more clueless than usual for quite a while.

-------------------------- Buffer: *doctor* --------------------------
I am the psychotherapist.  Please, describe your problems.  Each time
you are finished talking, type RET twice.

Get lost!

Why do you say 
get lost?
-------------------------- Buffer: *doctor* --------------------------

Here speaks her real self again:

-------------------------- Buffer: *doctor* --------------------------
I am the psychotherapist.  Please, describe your problems.  Each time
you are finished talking, type RET twice.

Get lost!

My secretary will send you a bill.
-------------------------- Buffer: *doctor* --------------------------

The reason is this change

diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 2c81fc9..cdc35d6 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,8 @@
+2009-01-12  Alan Mackenzie  <address@hidden>
+
+       * textmodes/paragraphs.el (forward-sentence): Change limit of
+       re-search-backward to allow values of `sentence-end' anchored at BOL.
+
 2009-01-12  Stefan Monnier  <address@hidden>
 
        * tar-mode.el (tar-header-block-tokenize): Properly ignore the version
diff --git a/lisp/textmodes/paragraphs.el b/lisp/textmodes/paragraphs.el
index 937140b..1d4a274 100644
--- a/lisp/textmodes/paragraphs.el
+++ b/lisp/textmodes/paragraphs.el
@@ -449,7 +449,10 @@ sentences.  Also, every paragraph boundary terminates 
sentences as well."
         (sentence-end (sentence-end)))
     (while (< arg 0)
       (let ((pos (point))
-           (par-beg (save-excursion (start-of-paragraph-text) (point))))
+           ;; We used to use (start-of-paragraph-text), but this can
+           ;; prevent sentence-end from matching if it is anchored at
+           ;; BOL and the paragraph starts indented.
+           (par-beg (save-excursion (backward-paragraph) (point))))
        (if (and (re-search-backward sentence-end par-beg t)
                (or (< (match-end 0) pos)
                    (re-search-backward sentence-end par-beg t)))


I'm not sure that I understand the comment correctly but it seems to
describe a case where all text in a paragraph is actually preceded by
a sentence-end in the same paragraph, like

------ Buffer: bar ------
  Two leading spaces here
------ Buffer: bar ------

with

(set (make-local-variable 'sentence-end) "^ ")    ;one space
(set (make-local-variable 'paragraph-start) "  ") ;two spaces

If just reverting that change is not an option the following fix is
straightforward but not tested very much.

Note that this exposes a quirk in start-of-paragraph-text,
viz. repeating M-a at the beginning of the buffer foo above moves
point to the beginning of the second line.

2010-10-18  Wolfgang Jenkner  <address@hidden>

        * textmodes/paragraphs.el (forward-sentence): Fix moving backwards
        to the beginning of the first sentence in a paragraph.

diff --git a/lisp/textmodes/paragraphs.el b/lisp/textmodes/paragraphs.el
index 4f1bcef..bcbb3a3 100644
--- a/lisp/textmodes/paragraphs.el
+++ b/lisp/textmodes/paragraphs.el
@@ -465,7 +465,8 @@ sentences.  Also, every paragraph boundary terminates 
sentences as well."
                (or (< (match-end 0) pos)
                    (re-search-backward sentence-end par-beg t)))
           (goto-char (match-end 0))
-        (goto-char par-beg)))
+        (goto-char opoint)
+        (start-of-paragraph-text)))
       (setq arg (1+ arg)))
     (while (> arg 0)
       (let ((par-end (save-excursion (end-of-paragraph-text) (point))))





reply via email to

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