all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* What is going wrong with my replace-regexp-in-string
@ 2009-01-28 17:16 Decebal
  2009-01-29  9:08 ` Decebal
  0 siblings, 1 reply; 2+ messages in thread
From: Decebal @ 2009-01-28 17:16 UTC (permalink / raw)
  To: help-gnu-emacs

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?


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

* Re: What is going wrong with my replace-regexp-in-string
  2009-01-28 17:16 What is going wrong with my replace-regexp-in-string Decebal
@ 2009-01-29  9:08 ` Decebal
  0 siblings, 0 replies; 2+ messages in thread
From: Decebal @ 2009-01-29  9:08 UTC (permalink / raw)
  To: help-gnu-emacs

On 28 jan, 18:16, Decebal <CLDWester...@gmail.com> wrote:
>                  "^\\([^\\^]\\)"

It should be:
                  "^\\(.\\)"


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

end of thread, other threads:[~2009-01-29  9:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-01-28 17:16 What is going wrong with my replace-regexp-in-string Decebal
2009-01-29  9:08 ` Decebal

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.