help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Compleet buffer to clipboard


From: Xah Lee
Subject: Re: Compleet buffer to clipboard
Date: Mon, 20 Apr 2009 12:18:35 -0700 (PDT)
User-agent: G2/1.0

On Apr 18, 5:27 am, Decebal <CLDWester...@gmail.com> wrote:
> A lot of times I want to copy the complete buffer to the clipboard.
> This is possible with:
>     C-x h
>     M-w
>
> But one of the complications is that you lose your cursor position.
> When you put in yor .emacs:
>     (defun buffer-yank()
>       (interactive)
>       (kill-new (buffer-substring (point-min) (point-max))))
>
>     (global-set-key (kbd "C-c C-a") 'buffer-yank)
>
> Then you can use:
>     C-c C-a
> to copy the complete buffer to the clipboard.

Here's what i use:

(defun copy-all ()
  "Put the whole buffer content into the kill-ring.
If narrow-to-region is in effect, then just copy that region."
  (interactive)
  (kill-ring-save (point-min) (point-max))
  (message "Buffer content copied")
  )

(defun cut-all ()
  "Cut the whole buffer content into the kill-ring.
If narrow-to-region is in effect, then just copy that region."
  (interactive)
  (kill-region (point-min) (point-max))
  (message "Buffer content cut")
  )

assigned to Alt+Shift+C and Alt+Shift+X.

>From http://code.google.com/p/ergoemacs/

I also find the that select all in emacs (mark-whole-buffer)'s
behavior of losing cursor position very annoying. One time i got
curious, and checked. This doesn't happen in all editors i know of.
With the above 2 commands, now i basically never do select all in
emacs.

  Xah
∑ http://xahlee.org/

reply via email to

[Prev in Thread] Current Thread [Next in Thread]