From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.devel Subject: M-a casts anchored `sentence-end' adrift. Date: Mon, 7 Jul 2008 09:01:35 +0000 Message-ID: <20080707090135.GA1901@muc.de> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1215419833 23679 80.91.229.12 (7 Jul 2008 08:37:13 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 7 Jul 2008 08:37:13 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Jul 07 10:37:51 2008 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1KFmEF-0008Ox-Bv for ged-emacs-devel@m.gmane.org; Mon, 07 Jul 2008 10:37:47 +0200 Original-Received: from localhost ([127.0.0.1]:49938 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KFmDO-0000cV-0s for ged-emacs-devel@m.gmane.org; Mon, 07 Jul 2008 04:36:54 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KFmDI-0000cL-EG for emacs-devel@gnu.org; Mon, 07 Jul 2008 04:36:48 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KFmDF-0000c5-NO for emacs-devel@gnu.org; Mon, 07 Jul 2008 04:36:47 -0400 Original-Received: from [199.232.76.173] (port=49784 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KFmDF-0000bw-K6 for emacs-devel@gnu.org; Mon, 07 Jul 2008 04:36:45 -0400 Original-Received: from colin.muc.de ([193.149.48.1]:4698 helo=mail.muc.de) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1KFmDF-0002RG-40 for emacs-devel@gnu.org; Mon, 07 Jul 2008 04:36:45 -0400 Original-Received: (qmail 98569 invoked by uid 3782); 7 Jul 2008 08:36:34 -0000 Original-Received: from acm.muc.de (pD9E50FD8.dip.t-dialin.net [217.229.15.216]) by colin2.muc.de (tmda-ofmipd) with ESMTP; Mon, 07 Jul 2008 10:36:33 +0200 Original-Received: (qmail 2374 invoked by uid 1000); 7 Jul 2008 09:01:35 -0000 Content-Disposition: inline User-Agent: Mutt/1.5.9i X-Delivery-Agent: TMDA/1.1.5 (Fettercairn) X-Primary-Address: acm@muc.de X-detected-kernel: by monty-python.gnu.org: FreeBSD 4.6-4.9 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:100413 Archived-At: 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 * 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).