unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* fill-paragraph from elisp
@ 2014-10-11 16:55 Eike Kettner
  2014-10-11 19:15 ` Drew Adams
  0 siblings, 1 reply; 3+ messages in thread
From: Eike Kettner @ 2014-10-11 16:55 UTC (permalink / raw)
  To: help-gnu-emacs


Hello list,

I want to insert some text from a database into a buffer. This should
happen with `fill-paraph' applied, and the string contains multiple
paragraphs. I came up with this (`descr' is the string):

(let ((beg (point)))
  (insert descr)
  (set-mark beg)
  (fill-paragraph nil t)
  (set-mark nil))

This works, but I'm not feeling confident with it. The documentation of
`set-mark' says this:

    ...Novice Emacs Lisp programmers often try to use the mark for the
    wrong purposes. ...

So.. I'm a novice elisp programmer. Is this a "wrong purpose"? What is
the idiomatic way to achieve this?

Thanks and regards
Eike

--
gpg: AD7AC35E
finger print: 137F BB0B 1639 D25F DC5D  E59C B412 C5F5 AD7A C35E



^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: fill-paragraph from elisp
  2014-10-11 16:55 fill-paragraph from elisp Eike Kettner
@ 2014-10-11 19:15 ` Drew Adams
  2014-10-11 19:52   ` Eike Kettner
  0 siblings, 1 reply; 3+ messages in thread
From: Drew Adams @ 2014-10-11 19:15 UTC (permalink / raw)
  To: Eike Kettner, help-gnu-emacs

> (let ((beg (point)))
>   (insert descr)
>   (set-mark beg)
>   (fill-paragraph nil t)
>   (set-mark nil))
> 
> What is the idiomatic way to achieve this?

Use `narrow-to-region' to operate on the text between two positions.



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: fill-paragraph from elisp
  2014-10-11 19:15 ` Drew Adams
@ 2014-10-11 19:52   ` Eike Kettner
  0 siblings, 0 replies; 3+ messages in thread
From: Eike Kettner @ 2014-10-11 19:52 UTC (permalink / raw)
  To: Drew Adams; +Cc: help-gnu-emacs


Thanks for your answer! I just found out, that I completely missed the
`fill-region' function… I read the doc-string of `fill-paragraph'
multiple times and yet, I managed to ignore it.

It turns out that (fill-region start end) is what I want.

I'm sorry for the noise and confusion.

Regards
Eike

Drew Adams writes:

>> (let ((beg (point)))
>>   (insert descr)
>>   (set-mark beg)
>>   (fill-paragraph nil t)
>>   (set-mark nil))
>>
>> What is the idiomatic way to achieve this?
>
> Use `narrow-to-region' to operate on the text between two positions.

--
gpg: AD7AC35E
finger print: 137F BB0B 1639 D25F DC5D  E59C B412 C5F5 AD7A C35E



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-10-11 19:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-11 16:55 fill-paragraph from elisp Eike Kettner
2014-10-11 19:15 ` Drew Adams
2014-10-11 19:52   ` Eike Kettner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).