emacs-devel
[Top][All Lists]
Advanced

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

M-a casts anchored `sentence-end' adrift.


From: Alan Mackenzie
Subject: M-a casts anchored `sentence-end' adrift.
Date: Mon, 7 Jul 2008 09:01:35 +0000
User-agent: Mutt/1.5.9i

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  <address@hidden>

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




reply via email to

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