* forward-paragraph, paragraph-start trouble
@ 2008-04-05 23:20 John J Foerch
2008-04-07 14:32 ` Andreas Röhler
0 siblings, 1 reply; 3+ messages in thread
From: John J Foerch @ 2008-04-05 23:20 UTC (permalink / raw)
To: help-gnu-emacs
Hello,
I am writing a major mode for a particular flavor of plain text file. I
am having trouble coercing `forward-paragraph' to recognize the
paragraph style. Here is some example text:
==begin example==
This is the first paragraph. It is
totally awesome.
This is the second paragraph. forward-paragraph
won't normally treat this one as a separate paragraph.
But the real difficulty is when
there is a paragraph like this.
To find out whether a given line
is a start-paragraph, you have
to be able to look at the previous
line to compare the amount of
indentation.
Crazy though it may seem,
this sentence begins a new
paragraph.
This sentence, though formatted
a bit strangely, should also be
treated as a single paragraph.
==end example==
`forward-paragraph' uses two regular expressions, `paragraph-start' and
`paragraph-separate' to find paragraphs. I simply need to be able to
say that a line with more identation than the previous line is a
paragraph-start. However, since emacs regular expressions lack
look-behind assertions, I am under the impression that what I want to do
is impossible.
Any advice?
Thank you,
John Foerch
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: forward-paragraph, paragraph-start trouble
2008-04-05 23:20 forward-paragraph, paragraph-start trouble John J Foerch
@ 2008-04-07 14:32 ` Andreas Röhler
2008-04-10 20:14 ` John J Foerch
0 siblings, 1 reply; 3+ messages in thread
From: Andreas Röhler @ 2008-04-07 14:32 UTC (permalink / raw)
To: help-gnu-emacs
Am Sonntag, 6. April 2008 01:20 schrieb John J Foerch:
> line to compare the amount of
> indentation.
> Crazy though it may seem,
> this sentence begins a new
> paragraph.
What about this?
(defun my-paragraph-start (&optional indent this)
(interactive)
(beginning-of-line)
(or this (setq this (point-min)))
(when (<= this (point))
(let* ((pos (point))
(this-indent (- (progn (skip-chars-forward " \t")(point))pos))
(indent (or indent
this-indent)))
(unless
(< indent this-indent)
(forward-line 1)
(my-paragraph-start this-indent (point))))))
Andreas Röhler
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: forward-paragraph, paragraph-start trouble
2008-04-07 14:32 ` Andreas Röhler
@ 2008-04-10 20:14 ` John J Foerch
0 siblings, 0 replies; 3+ messages in thread
From: John J Foerch @ 2008-04-10 20:14 UTC (permalink / raw)
To: help-gnu-emacs
Andreas Röhler <andreas.roehler@online.de> writes:
> What about this?
>
> (defun my-paragraph-start (&optional indent this)
> (interactive)
> (beginning-of-line)
> (or this (setq this (point-min)))
> (when (<= this (point))
> (let* ((pos (point))
> (this-indent (- (progn (skip-chars-forward " \t")(point))pos))
> (indent (or indent
> this-indent)))
> (unless
> (< indent this-indent)
> (forward-line 1)
> (my-paragraph-start this-indent (point))))))
Hi Andreas,
Thank you so much--I will play around with this code and see what I can
come up with.
Yet now I am thinking that the best course for me may be to modify
`forward-paragraph' perhaps to add a third regexp for finding paragraph
boundaries. forward-paragraph is very dense code, and it may be a
considerable challenge to do what I want with it, but the advantage
would be that my mode would not have to have a complete set of its own
movement commands. Presumably reducing code duplication is the
intention behind the variables `paragraph-start' and
`paragraph-separate', but unfortunately, they are not quite enough for
even this simple of a variation on emacs' standard paragraph style.
John Foerch
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2008-04-10 20:14 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-04-05 23:20 forward-paragraph, paragraph-start trouble John J Foerch
2008-04-07 14:32 ` Andreas Röhler
2008-04-10 20:14 ` John J Foerch
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.