From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Merciadri Luca Newsgroups: gmane.emacs.help Subject: Adding `#' at each new line with text until the end of the file Date: Mon, 17 May 2010 18:05:08 +0200 Organization: ULg Message-ID: <87k4r24iq3.fsf@merciadriluca-station.MERCIADRILUCA> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1291832194 13557 80.91.229.12 (8 Dec 2010 18:16:34 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 8 Dec 2010 18:16:34 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Dec 08 19:16:30 2010 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PQOZ2-0004Nu-8E for geh-help-gnu-emacs@m.gmane.org; Wed, 08 Dec 2010 19:16:28 +0100 Original-Received: from localhost ([127.0.0.1]:60047 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PQOZ1-0003fg-9Q for geh-help-gnu-emacs@m.gmane.org; Wed, 08 Dec 2010 13:16:27 -0500 Original-Path: usenet.stanford.edu!goblin2!goblin.stu.neva.ru!news.net.uni-c.dk!dotsrc.org!filter.dotsrc.org!news.dotsrc.org!not-for-mail Original-Newsgroups: gnu.emacs.help User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.2 (gnu/linux) Cancel-Lock: sha1:OftodgLvEuyA6w/BkQwIYbtjF98= Original-Lines: 89 Original-NNTP-Posting-Host: 62.197.101.67 Original-X-Trace: news.sunsite.dk DXC=7YKi List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:75773 Archived-At: -----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 iEYEARECAAYFAkvxaTQACgkQM0LLzLt8MhzYBQCgoZsPqIFxOkVJjMnpdh41rUMw 0AMAoKILCLVRtsastH6moo0tjpbqU7Gg =XnME -----END PGP SIGNATURE-----