* M-a casts anchored `sentence-end' adrift.
@ 2008-07-07 9:01 Alan Mackenzie
2009-01-12 4:25 ` Stefan Monnier
0 siblings, 1 reply; 2+ messages in thread
From: Alan Mackenzie @ 2008-07-07 9:01 UTC (permalink / raw)
To: emacs-devel
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).
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: M-a casts anchored `sentence-end' adrift.
2008-07-07 9:01 M-a casts anchored `sentence-end' adrift Alan Mackenzie
@ 2009-01-12 4:25 ` Stefan Monnier
0 siblings, 0 replies; 2+ messages in thread
From: Stefan Monnier @ 2009-01-12 4:25 UTC (permalink / raw)
To: Alan Mackenzie; +Cc: emacs-devel
> 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.
I'm not sure it's a big deal, but it seems safe, so I installed it, even
if belatedly.
Stefan
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-01-12 4:25 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-07-07 9:01 M-a casts anchored `sentence-end' adrift Alan Mackenzie
2009-01-12 4:25 ` 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.