unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Adding `#' at each new line with text until the end of the file
@ 2010-05-17 16:05 Merciadri Luca
  2010-05-17 18:26 ` Pascal J. Bourguignon
  0 siblings, 1 reply; 11+ messages in thread
From: Merciadri Luca @ 2010-05-17 16:05 UTC (permalink / raw)
  To: help-gnu-emacs

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

Hi,

I have some personally-defined function:

==
(defun psig ()
  "Insert the signature for a personal posting on a newsgroup, including a saying."
  (interactive)
  (goto-char (point-max))
  (or (= (char-after (- (point) 1)) ?\n)
      (newline 1))
  (insert "-- \n")
  (let ((saying ""))
    (save-window-excursion
      (find-file "~/Sayings")
      (goto-char (point-min))
      (search-forward "#")
      (delete-char -1)
      (setq fill-prefix nil)
      (mark-paragraph)
      (setq saying (buffer-substring (region-beginning) (region-end)))
      (exchange-point-and-mark)
      (if (eobp) (goto-char (1+ (point-min))))
      ;(insert "#")
      (save-buffer))
    (insert saying)
    ))
==

The file ~/Sayings contains sayings, and, at the beginning, each line
with some saying was beginning with a #.

So, my sayings' file looked like:

==

#saying1

#saying2

#...

#sayingn

==

Nice, but my psig() function takes the `#' to tell me that the given
saying has already been used. As it looks for the following `#', it
takes the first line with `#' beginning it, that is, the first saying
which has not been already used before.

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?

Thanks.

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

Act today only, tomorrow is too late.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Processed by Mailcrypt 3.5.8 <http://mailcrypt.sourceforge.net/>

iEYEARECAAYFAkvxaTQACgkQM0LLzLt8MhzYBQCgoZsPqIFxOkVJjMnpdh41rUMw
0AMAoKILCLVRtsastH6moo0tjpbqU7Gg
=XnME
-----END PGP SIGNATURE-----


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

end of thread, other threads:[~2010-05-20 19:05 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-17 16:05 Adding `#' at each new line with text until the end of the file Merciadri Luca
2010-05-17 18:26 ` Pascal J. Bourguignon
2010-05-17 20:11   ` Merciadri Luca
     [not found]     ` <87zkzyjkcb.fsf@kuiper.lan.informatimago.com>
2010-05-18 10:09       ` Merciadri Luca
2010-05-18 12:06         ` Pascal J. Bourguignon
2010-05-18 16:47           ` Merciadri Luca
2010-05-18 20:27             ` Pascal J. Bourguignon
2010-05-19 16:08               ` Merciadri Luca
2010-05-20 13:18                 ` Pascal J. Bourguignon
2010-05-20 18:09                   ` Merciadri Luca
2010-05-20 19:05                 ` Andreas Politz

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).