all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Compleet buffer to clipboard
@ 2009-04-18 12:27 Decebal
  2009-04-18 16:27 ` Drew Adams
                   ` (4 more replies)
  0 siblings, 5 replies; 9+ messages in thread
From: Decebal @ 2009-04-18 12:27 UTC (permalink / raw)
  To: help-gnu-emacs

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.


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

* RE: Compleet buffer to clipboard
  2009-04-18 12:27 Compleet buffer to clipboard Decebal
@ 2009-04-18 16:27 ` Drew Adams
       [not found] ` <mailman.5623.1240072028.31690.help-gnu-emacs@gnu.org>
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 9+ messages in thread
From: Drew Adams @ 2009-04-18 16:27 UTC (permalink / raw)
  To: 'Decebal', help-gnu-emacs

> 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.

C-u C-SPC  C-u C-SPC should take you back where you were.





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

* Re: Compleet buffer to clipboard
       [not found] ` <mailman.5623.1240072028.31690.help-gnu-emacs@gnu.org>
@ 2009-04-18 16:39   ` Decebal
  2009-04-18 17:41     ` B. T. Raven
  0 siblings, 1 reply; 9+ messages in thread
From: Decebal @ 2009-04-18 16:39 UTC (permalink / raw)
  To: help-gnu-emacs

On 18 apr, 18:27, "Drew Adams" <drew.ad...@oracle.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.
>
> C-u C-SPC  C-u C-SPC should take you back where you were.

I did not know that. But I prefer my solution. ;-}
I find it easier and faster to do:
    C-c C-a
then to do:
    C-x h
    M-w
    C-u C-SPC
    C-u C-SPC


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

* Re: Compleet buffer to clipboard
  2009-04-18 16:39   ` Decebal
@ 2009-04-18 17:41     ` B. T. Raven
  2009-04-18 17:58       ` B. T. Raven
  0 siblings, 1 reply; 9+ messages in thread
From: B. T. Raven @ 2009-04-18 17:41 UTC (permalink / raw)
  To: help-gnu-emacs

Decebal wrote:
> On 18 apr, 18:27, "Drew Adams" <drew.ad...@oracle.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.
>> C-u C-SPC  C-u C-SPC should take you back where you were.
> 
> I did not know that. But I prefer my solution. ;-}
> I find it easier and faster to do:
>     C-c C-a
> then to do:
>     C-x h
>     M-w
>     C-u C-SPC
>     C-u C-SPC

What is C-c C-a bound to? It's undefined here. In any case your solution 
involves two more (unnecessary) key chords than Drew's

Or do you mean ... easier ..... THAN to do: ???


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

* Re: Compleet buffer to clipboard
  2009-04-18 17:41     ` B. T. Raven
@ 2009-04-18 17:58       ` B. T. Raven
  2009-04-19  5:51         ` Decebal
  0 siblings, 1 reply; 9+ messages in thread
From: B. T. Raven @ 2009-04-18 17:58 UTC (permalink / raw)
  To: help-gnu-emacs

B. T. Raven wrote:
> Decebal wrote:
>> On 18 apr, 18:27, "Drew Adams" <drew.ad...@oracle.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.
>>> C-u C-SPC  C-u C-SPC should take you back where you were.
>>
>> I did not know that. But I prefer my solution. ;-}
>> I find it easier and faster to do:
>>     C-c C-a
>> then to do:
>>     C-x h
>>     M-w
>>     C-u C-SPC
>>     C-u C-SPC
> 
> What is C-c C-a bound to? It's undefined here. In any case your solution 
> involves two more (unnecessary) key chords than Drew's
> 
> Or do you mean ... easier ..... THAN to do: ???

Oops! I read Drew's answer but not the o.p.

This also doesn't seem to mess with the mark or at least the docs say 
"In Transient Mark mode, deactivate the mark."

  (defun buffer-yank()
       (interactive)
       (kill-ring-save(point-min)(point-max)))

     (global-set-key (kbd "C-c C-a") 'buffer-yank)

Does your version cut from the original buffer or just copy?


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

* Re: Compleet buffer to clipboard
  2009-04-18 17:58       ` B. T. Raven
@ 2009-04-19  5:51         ` Decebal
  0 siblings, 0 replies; 9+ messages in thread
From: Decebal @ 2009-04-19  5:51 UTC (permalink / raw)
  To: help-gnu-emacs

On Apr 18, 7:58 pm, "B. T. Raven" <ni...@nihilo.net> wrote:
> >> I find it easier and faster to do:
> >>     C-c C-a
> >> then to do:
> >>     C-x h
> >>     M-w
> >>     C-u C-SPC
> >>     C-u C-SPC
>
> > What is C-c C-a bound to? It's undefined here. In any case your solution
> > involves two more (unnecessary) key chords than Drew's
>
> > Or do you mean ... easier ..... THAN to do: ???

Excuse my English. It should have been than. :-{
>
> Oops! I read Drew's answer but not the o.p.
>
> This also doesn't seem to mess with the mark or at least the docs say
> "In Transient Mark mode, deactivate the mark."
>
>   (defun buffer-yank()
>        (interactive)
>        (kill-ring-save(point-min)(point-max)))
>
>      (global-set-key (kbd "C-c C-a") 'buffer-yank)
>
> Does your version cut from the original buffer or just copy?

This does a copy. (That is what I almost alway want, and otherwise is
'C-x h, C-w' not so bad to do.) But I could change the function that
with 'C-u' prepended it does a cut instead of a copy.


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

* Re: Compleet buffer to clipboard
  2009-04-18 12:27 Compleet buffer to clipboard Decebal
  2009-04-18 16:27 ` Drew Adams
       [not found] ` <mailman.5623.1240072028.31690.help-gnu-emacs@gnu.org>
@ 2009-04-20 19:18 ` Xah Lee
  2009-04-21  6:55 ` Alan Mackenzie
       [not found] ` <mailman.5756.1240296937.31690.help-gnu-emacs@gnu.org>
  4 siblings, 0 replies; 9+ messages in thread
From: Xah Lee @ 2009-04-20 19:18 UTC (permalink / raw)
  To: help-gnu-emacs

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/^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Compleet buffer to clipboard
  2009-04-18 12:27 Compleet buffer to clipboard Decebal
                   ` (2 preceding siblings ...)
  2009-04-20 19:18 ` Xah Lee
@ 2009-04-21  6:55 ` Alan Mackenzie
       [not found] ` <mailman.5756.1240296937.31690.help-gnu-emacs@gnu.org>
  4 siblings, 0 replies; 9+ messages in thread
From: Alan Mackenzie @ 2009-04-21  6:55 UTC (permalink / raw)
  To: Decebal; +Cc: help-gnu-emacs

Hi, Decebal,

On Sat, Apr 18, 2009 at 05:27:38AM -0700, Decebal 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.

Sort of, some of the time.  C-c C-a is a binding reserved for major modes
(see page "Key Binding Conventions" in the elisp manual).  If you're in a
major mode which actually uses this binding (e.g. C Mode, Diff Mode), it
will take precedence over your `buffer-yank'.

You might be better using a binding reserved for users, say C-c a.

-- 
Alan Mackenzie (Nuremberg, Germany).




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

* Re: Compleet buffer to clipboard
       [not found] ` <mailman.5756.1240296937.31690.help-gnu-emacs@gnu.org>
@ 2009-04-21  7:40   ` Decebal
  0 siblings, 0 replies; 9+ messages in thread
From: Decebal @ 2009-04-21  7:40 UTC (permalink / raw)
  To: help-gnu-emacs

On Apr 21, 8:55 am, Alan Mackenzie <a...@muc.de> wrote:
> >     (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.
>
> Sort of, some of the time.  C-c C-a is a binding reserved for major modes
> (see page "Key Binding Conventions" in the elisp manual).  If you're in a
> major mode which actually uses this binding (e.g. C Mode, Diff Mode), it
> will take precedence over your `buffer-yank'.
>
> You might be better using a binding reserved for users, say C-c a.

Good tip, I did not know that. In my case less important, because I
only expect to use it in text-mode or modes derived from this. But it
is always good to know the potential pittfalls.


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

end of thread, other threads:[~2009-04-21  7:40 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-04-18 12:27 Compleet buffer to clipboard Decebal
2009-04-18 16:27 ` Drew Adams
     [not found] ` <mailman.5623.1240072028.31690.help-gnu-emacs@gnu.org>
2009-04-18 16:39   ` Decebal
2009-04-18 17:41     ` B. T. Raven
2009-04-18 17:58       ` B. T. Raven
2009-04-19  5:51         ` Decebal
2009-04-20 19:18 ` Xah Lee
2009-04-21  6:55 ` Alan Mackenzie
     [not found] ` <mailman.5756.1240296937.31690.help-gnu-emacs@gnu.org>
2009-04-21  7:40   ` 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.