2012-10-10

[emacs] copy until char (like zap-to-char)




sdfasdfsadf

Today, When we doing a story with a piece of XML like this:

<suburb>S-123456789</suburb>

I feel not convenient to copy out the S-123456789

So I wrote a new copy-without-selection function copy-to-char function (like zap-to-char):
init.el
(defun copy-to-char (arg char)
  "Copy until char like zap-to-char"
  (interactive "p\ncZap to char: ")
  (let ((start (point)))
    (save-excursion
      (copy-region-as-kill start (progn
                         (search-forward (char-to-string char) nil nil arg)
                         (backward-char)
                         (point)))
      )
    )
)
(global-set-key (kbd "C-c c") 'copy-to-char) 

No comments:

Post a Comment