all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#7240: 24.0.50; backward-sentence sometimes overshoots (and breaks doctor)
@ 2010-10-18 16:49 Wolfgang Jenkner
  2011-07-25 21:51 ` bug#7240: 24.0.50; [PATCH] " Wolfgang Jenkner
  0 siblings, 1 reply; 6+ messages in thread
From: Wolfgang Jenkner @ 2010-10-18 16:49 UTC (permalink / raw)
  To: 7240

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  <acm@muc.de>
+
+	* 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  <monnier@iro.umontreal.ca>
 
 	* 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  <wjenkner@inode.at>

	* 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))))





^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-09-24 17:30 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-10-18 16:49 bug#7240: 24.0.50; backward-sentence sometimes overshoots (and breaks doctor) Wolfgang Jenkner
2011-07-25 21:51 ` bug#7240: 24.0.50; [PATCH] " Wolfgang Jenkner
2011-09-22 18:13   ` Wolfgang Jenkner
2011-09-24 12:28     ` Richard Stallman
2011-09-24 14:03       ` Wolfgang Jenkner
2011-09-24 17:30         ` Richard Stallman

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.