From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Decebal Newsgroups: gmane.emacs.help Subject: What is going wrong with my replace-regexp-in-string Date: Wed, 28 Jan 2009 09:16:07 -0800 (PST) Organization: http://groups.google.com Message-ID: <3ab4a0bc-6d7a-4c33-93ec-a43c43c86390@p23g2000prp.googlegroups.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1233165399 26417 80.91.229.12 (28 Jan 2009 17:56:39 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 28 Jan 2009 17:56:39 +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 Jan 28 18:57:52 2009 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.50) id 1LSEfV-0005Fj-VP for geh-help-gnu-emacs@m.gmane.org; Wed, 28 Jan 2009 18:57:42 +0100 Original-Received: from localhost ([127.0.0.1]:40418 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LSEeD-000786-VC for geh-help-gnu-emacs@m.gmane.org; Wed, 28 Jan 2009 12:56:21 -0500 Original-Path: news.stanford.edu!headwall.stanford.edu!news.glorb.com!news2.glorb.com!postnews.google.com!p23g2000prp.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 21 Original-NNTP-Posting-Host: 80.79.97.145 Original-X-Trace: posting.google.com 1233162968 23929 127.0.0.1 (28 Jan 2009 17:16:08 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Wed, 28 Jan 2009 17:16:08 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: p23g2000prp.googlegroups.com; posting-host=80.79.97.145; posting-account=K-cdeAoAAAD_0d505kUtHXJaT5LFIu-3 User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; nl; rv:1.9.0.5) Gecko/2008120122 Firefox/3.0.5,gzip(gfe),gzip(gfe) X-HTTP-Via: 1.1 proxy-26:8080 (squid/2.5.STABLE8) Original-Xref: news.stanford.edu gnu.emacs.help:166416 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor 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:61733 Archived-At: I defined the following function: (defun my-headed-yank(begin end head do-kill) "Put region with 'head' prepended to every line in the kill- ring" (interactive "r\nsHead: \nnKill Region? ") (setq head (concat head "\\1")) (kill-new (replace-regexp-in-string "^\\([^\\^]\\)" head (buffer-substring begin end) ) ) (if (= do-kill 0) (deactivate-mark) (delete-region begin end) ) ) What I want is that head is prepended to every not empty line. When the last line is not empty, head is not prepended to it, but the other empty lines do get head prepended. Why?