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: Merciadri Luca
Subject: Re: Adding `#' at each new line with text until the end of the file
Date: Wed, 08 Dec 2010 15:08:39 -0000
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.2 (gnu/linux)

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

pjb@informatimago.com (Pascal J. Bourguignon) writes:

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

After extensive testing,

==
(defun fildi ()
  (find-file "~/Sayings")
  (goto-char (point-min))
  (while (< (point) (point-max))
    (when (looking-at ".")
      (insert "#"))
    (forward-line)) 
  )
==

does not work. When I evaluate it using C-x C-e (in a buffer), it only
says `fildi', which does not look very interesting. What am I doing
wrong? It finds the file; it goes to the beginning of it; while it has
not reached the end of the file, it looks for a line containing a dot
(as every saying ends by a dot); while this works, it inserts a "#"
and, as the cursor is at the beginning of the line, it inserts a "#"
at the beginning of the line. It also goes to the next line. And?

- -- 
Merciadri Luca
See http://www.student.montefiore.ulg.ac.be/~merciadri/
- -- 

When making your choices in life, do not forget to live. (Samuel Johnson)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Processed by Mailcrypt 3.5.8 <http://mailcrypt.sourceforge.net/>

iEYEARECAAYFAkvxovUACgkQM0LLzLt8Mhy/UwCfZVeNrnTF0Ygl0XwS54iTVvEa
qRwAn1oBeyo6ORYEJ1D/YZ2zVu6uCvyZ
=0fJA
-----END PGP SIGNATURE-----


reply via email to

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