all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* PING!!!: [acm@muc.de: M-a casts anchored `sentence-end' adrift.]
@ 2008-07-29 20:29 Alan Mackenzie
  2008-07-29 22:03 ` Stefan Monnier
  0 siblings, 1 reply; 2+ messages in thread
From: Alan Mackenzie @ 2008-07-29 20:29 UTC (permalink / raw)
  To: Stefan Monnier, Chong Yidong, emacs-devel

Hi, Stefan, Yidong, everybody.

I've not yet hat an answer to this one, so forgive me reposting it.  A
minimal answer of 3 letters would be appreciated.  :-)

Looking at it, I think I could have been clearer.  So let me add this
sentence:

M-a fouls up at a beginning of paragraph when `sentence-end' is anchored
at BOL.

Thanks!

-- 
Alan Mackenzie (Nuremberg, Germany)


----- Forwarded message from Alan Mackenzie <acm@muc.de> -----

X-Spam-Checker-Version: SpamAssassin 3.2.0 (2007-05-01) on colin2.muc.de
X-Spam-Level: 
X-Spam-Status: No, score=0.0 required=5.0 tests=AWL,BAYES_50 autolearn=no
	version=3.2.0
Date: Mon, 7 Jul 2008 09:01:35 +0000
To: emacs-devel@gnu.org
X-Delivery-Agent: TMDA/1.1.5 (Fettercairn)
From: Alan Mackenzie <acm@muc.de>
X-Primary-Address: acm@muc.de
X-detected-kernel: by monty-python.gnu.org: FreeBSD 4.6-4.9
Subject: M-a casts anchored `sentence-end' adrift.
X-BeenThere: emacs-devel@gnu.org
X-Mailman-Version: 2.1.5
List-Id: "Emacs development discussions." <emacs-devel.gnu.org>
List-Unsubscribe: <http://lists.gnu.org/mailman/listinfo/emacs-devel>,
	<mailto:emacs-devel-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/pipermail/emacs-devel>
List-Post: <mailto:emacs-devel@gnu.org>
List-Help: <mailto:emacs-devel-request@gnu.org?subject=help>
List-Subscribe: <http://lists.gnu.org/mailman/listinfo/emacs-devel>,
	<mailto:emacs-devel-request@gnu.org?subject=subscribe>

Hi, Emacs!

Suppose you've got an enhanced text mode, in which lines and paragraphs
look something like this:

  o - This is a paragraph with a "bullet" heading.  Typically, it
    extends over several lines, with indentation.
    o - This line starts a "sub-bullet" paragraph.

Now put point on the word "heading" and do M-a.  This is going to move
point to the "bullet".  Clearly, the Right Thing is to move point to "This".

An obvious way to do this is to enhance `sentence-end' so that " o - "
gets recognised as a full stop.  Something like this should do it:

(defvar my-sentence-end
  (let (sentence-end)
    (concat "^[ \t]*o - [ \t]+\\|\\("
            (sentence-end)
	    "\\)")))

, then put
  (setq sentence-end my-sentence-end) 
in the mode startup code.  Note the "^" at the start of the regexp.

However, M-a _still_ doesn't work.  The problem is that (forward-sentence
-1) limits its re-search-backwards to the paragraph TEXT, as opposed to
the entire paragraph including leading whitespace.

The specification of sentence-end doesn't preclude anchoring a
"full-stop" at BOL (or even EOL).  Therefore, there is a bug.  The
following patch fixes it.

Can anybody see any problems with this patch?  May I install it?



2008-07-07  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.


*** paragraphs.el	2008-05-29 18:20:14.000000000 +0000
--- paragraphs.070708.el	2008-07-07 08:54:43.856911952 +0000
***************
*** 887,893 ****
          (sentence-end (sentence-end)))
      (while (< arg 0)
        (let ((pos (point))
! 	    (par-beg (save-excursion (start-of-paragraph-text) (point))))
         (if (and (re-search-backward sentence-end par-beg t)
  		(or (< (match-end 0) pos)
  		    (re-search-backward sentence-end par-beg t)))
--- 887,893 ----
          (sentence-end (sentence-end)))
      (while (< arg 0)
        (let ((pos (point))
! 	    (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)))


-- 
Alan Mackenzie (Nuremberg, Germany).



----- End forwarded message -----




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

* Re: PING!!!: [acm@muc.de: M-a casts anchored `sentence-end' adrift.]
  2008-07-29 20:29 PING!!!: [acm@muc.de: M-a casts anchored `sentence-end' adrift.] Alan Mackenzie
@ 2008-07-29 22:03 ` Stefan Monnier
  0 siblings, 0 replies; 2+ messages in thread
From: Stefan Monnier @ 2008-07-29 22:03 UTC (permalink / raw)
  To: Alan Mackenzie; +Cc: Chong Yidong, emacs-devel

> I've not yet hat an answer to this one, so forgive me reposting it.  A
> minimal answer of 3 letters would be appreciated.  :-)

Yes, that looks OK.  Although a lot of the paragraph-* regexps
explicitly forbid the use of ^ and instead use `looking-at' from the
margin (which may or not be at bol).


        Stefan




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

end of thread, other threads:[~2008-07-29 22:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-07-29 20:29 PING!!!: [acm@muc.de: M-a casts anchored `sentence-end' adrift.] Alan Mackenzie
2008-07-29 22:03 ` Stefan Monnier

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.