unofficial mirror of bug-gnu-emacs@gnu.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

* bug#7240: 24.0.50; [PATCH] backward-sentence sometimes overshoots (and breaks doctor)
  2010-10-18 16:49 bug#7240: 24.0.50; backward-sentence sometimes overshoots (and breaks doctor) Wolfgang Jenkner
@ 2011-07-25 21:51 ` Wolfgang Jenkner
  2011-09-22 18:13   ` Wolfgang Jenkner
  0 siblings, 1 reply; 6+ messages in thread
From: Wolfgang Jenkner @ 2011-07-25 21:51 UTC (permalink / raw)
  To: 7240; +Cc: acm


Since there has been recent interest in this (merge with bug#9133), I'd
like to point out that there's actually a patch in my original report.
Perhaps the author of the change which caused the different behaviour is
in the best position to decide the matter, though, so I am CC'ing him
hereby :-)

Wolfgang





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

* bug#7240: 24.0.50; [PATCH] backward-sentence sometimes overshoots (and breaks doctor)
  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
  0 siblings, 1 reply; 6+ messages in thread
From: Wolfgang Jenkner @ 2011-09-22 18:13 UTC (permalink / raw)
  To: 7240


RMS's last change to backward-sentence leaves that command broken.

Create a buffer like this

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

  This sentence follows some spaces.
---------- 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 second line, but it should be at
the `T' (cf. (emacs)Top > Text > Sentences).

Obviously, I suggest reverting that change and applying my patch
instead.





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

* bug#7240: 24.0.50; [PATCH] backward-sentence sometimes overshoots (and breaks doctor)
  2011-09-22 18:13   ` Wolfgang Jenkner
@ 2011-09-24 12:28     ` Richard Stallman
  2011-09-24 14:03       ` Wolfgang Jenkner
  0 siblings, 1 reply; 6+ messages in thread
From: Richard Stallman @ 2011-09-24 12:28 UTC (permalink / raw)
  To: Wolfgang Jenkner; +Cc: 7240

Your patch would work correctly.  The reason I wanted to do it
differently was to avoid finding the start of the paragraph twice.

Does it work correctly now?

Thanks for making sure we fixed it.

-- 
Dr Richard Stallman
President, Free Software Foundation
51 Franklin St
Boston MA 02110
USA
www.fsf.org  www.gnu.org
Skype: No way! That's nonfree (freedom-denying) software.
  Use free telephony http://directory.fsf.org/category/tel/





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

* bug#7240: 24.0.50; [PATCH] backward-sentence sometimes overshoots (and breaks doctor)
  2011-09-24 12:28     ` Richard Stallman
@ 2011-09-24 14:03       ` Wolfgang Jenkner
  2011-09-24 17:30         ` Richard Stallman
  0 siblings, 1 reply; 6+ messages in thread
From: Wolfgang Jenkner @ 2011-09-24 14:03 UTC (permalink / raw)
  To: rms; +Cc: acm, 7240

Richard Stallman <rms@gnu.org> writes:

> Your patch would work correctly.  The reason I wanted to do it
> differently was to avoid finding the start of the paragraph twice.

Thank you very much for the explanation (and sorry if I was a bit too
blunt)!

I note that both you and Alan seem to think that backward-paragraph is
not always quite the right thing to use when moving backwards to
ahem... a paragraph beginning :-)

Wolfgang





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

* bug#7240: 24.0.50; [PATCH] backward-sentence sometimes overshoots (and breaks doctor)
  2011-09-24 14:03       ` Wolfgang Jenkner
@ 2011-09-24 17:30         ` Richard Stallman
  0 siblings, 0 replies; 6+ messages in thread
From: Richard Stallman @ 2011-09-24 17:30 UTC (permalink / raw)
  To: Wolfgang Jenkner; +Cc: acm, 7240

    I note that both you and Alan seem to think that backward-paragraph is
    not always quite the right thing to use when moving backwards to
    ahem... a paragraph beginning :-)

The point is that the paragraph beginning, in the usual sense,
is not the place to move to in this case.

-- 
Dr Richard Stallman
President, Free Software Foundation
51 Franklin St
Boston MA 02110
USA
www.fsf.org  www.gnu.org
Skype: No way! That's nonfree (freedom-denying) software.
  Use free telephony http://directory.fsf.org/category/tel/





^ permalink raw reply	[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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).