help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: Adding `#' at each new line with text until the end of the file


From: Pascal J. Bourguignon
Subject: Re: Adding `#' at each new line with text until the end of the file
Date: Wed, 08 Dec 2010 15:08:38 -0000
User-agent: Gnus/5.101 (Gnus v5.10.10) Emacs/23.1 (gnu/linux)

Merciadri Luca <Luca.Merciadri@student.ulg.ac.be> writes:

> The problem is that, as I do not have *a lot* of sayings, I would like
> Gnus to modify the sayings' file so it looks like at its beginning,
> that is, with a `#' beginning each saying.
>
> I tried
>
> ==
> (defun fildi ()
>        (find-file "/~Sayings")
>        (goto-char (point-min))
>        ; go to the first saying, and do the following until the end of the
>        ; file is reached, for each line with some text on it:
>        (insert "#")
>        (save-buffer))
> ==
>
> But I don't know how to translate my two lines of comments into real
> ELisp code. Any idea about how I could achieve this?

A line that has some text on it is a line that has at least one character right?

So:
    (while (< (point) (point-max))
        (when (looking-at ".")
            (insert "#"))
        (forward-line))

-- 
__Pascal Bourguignon__                     http://www.informatimago.com/


reply via email to

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