emacs-devel
[Top][All Lists]
Advanced

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

PING!!!: address@hidden: M-a casts anchored `sentence-end' adrift.]


From: Alan Mackenzie
Subject: PING!!!: address@hidden: M-a casts anchored `sentence-end' adrift.]
Date: Tue, 29 Jul 2008 20:29:05 +0000
User-agent: Mutt/1.5.9i

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

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: address@hidden
X-Delivery-Agent: TMDA/1.1.5 (Fettercairn)
From: Alan Mackenzie <address@hidden>
X-Primary-Address: address@hidden
X-detected-kernel: by monty-python.gnu.org: FreeBSD 4.6-4.9
Subject: M-a casts anchored `sentence-end' adrift.
X-BeenThere: address@hidden
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:address@hidden>
List-Archive: <http://lists.gnu.org/pipermail/emacs-devel>
List-Post: <mailto:address@hidden>
List-Help: <mailto:address@hidden>
List-Subscribe: <http://lists.gnu.org/mailman/listinfo/emacs-devel>,
        <mailto:address@hidden>

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



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




reply via email to

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