[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
What is going wrong with my replace-regexp-in-string
From: |
Decebal |
Subject: |
What is going wrong with my replace-regexp-in-string |
Date: |
Wed, 28 Jan 2009 09:16:07 -0800 (PST) |
User-agent: |
G2/1.0 |
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?
- What is going wrong with my replace-regexp-in-string,
Decebal <=