all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Simple copy & paste problem
@ 2010-08-11 16:51 Andrea Crotti
  2010-08-11 17:51 ` Drew Adams
                   ` (7 more replies)
  0 siblings, 8 replies; 20+ messages in thread
From: Andrea Crotti @ 2010-08-11 16:51 UTC (permalink / raw)
  To: help-gnu-emacs

This is probably very stupid but every time I step into it and it's very
annoying.

Supposing I want to copy something from Safari to emacs.
So I
- select and copy
- select and kill the text I want to substitute
- try to paste

ARGH! Now the text I copied from safari is disappeared...

A workardound is to delete first and then copy-paste.
But is there a smarter way to solve this?
Something like
"if I copied something from the os keep it as first in the kill ring"?




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

* Re: Simple copy & paste problem
       [not found] <mailman.4.1281546350.9082.help-gnu-emacs@gnu.org>
@ 2010-08-11 17:43 ` Pascal J. Bourguignon
  2010-09-05  1:44   ` David Combs
  2010-08-11 18:11 ` notbob
  1 sibling, 1 reply; 20+ messages in thread
From: Pascal J. Bourguignon @ 2010-08-11 17:43 UTC (permalink / raw)
  To: help-gnu-emacs

Andrea Crotti <andrea.crotti.0@gmail.com> writes:

> This is probably very stupid but every time I step into it and it's very
> annoying.
>
> Supposing I want to copy something from Safari to emacs.
> So I
> - select and copy
> - select and kill the text I want to substitute
> - try to paste
>
> ARGH! Now the text I copied from safari is disappeared...


> A workardound is to delete first and then copy-paste.

or:

- select and copy
- yank (it's called yank in emacs, not paste).
- select and kill the text you wanted to substitute


> But is there a smarter way to solve this?
> Something like
> "if I copied something from the os keep it as first in the kill ring"?

Use delete-region-and-yank instead of yank:

(defun delete-region-and-yank (&optional arg)
  "Deletes region if mark is active and yanks the last kill.
Always replaces the region with the yank, whether the region was
selected via keyboard or mouse.  Also works for normal
yank even with ARGS (thus it can be mapped to \\C-y)"
  (interactive "*P")                    ; raw, like yank.
  (message "arg=%S" arg)
  (cond
    (mark-active                        ; delete region
     (let ((str (buffer-substring (point) (mark))))
       (delete-region (point) (mark))
       (if (string=* str (current-kill 0 1))
           (let ((str2 (current-kill 1 1)))
             (kill-new str2 t))))
     (if arg
         (yank arg)
         (yank)))
    ;; else no region selected:
    ((consp arg)                        ; delete forward sexp
     (set-mark (point))
     (forward-sexp 1)
     (delete-region-and-yank))
    (arg (yank arg))
    (t   (yank))))


-- 
__Pascal Bourguignon__                     http://www.informatimago.com/


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

* RE: Simple copy & paste problem
  2010-08-11 16:51 Andrea Crotti
@ 2010-08-11 17:51 ` Drew Adams
  2010-08-11 18:10   ` Andrea Crotti
  2010-08-11 19:05 ` Glauber Alex Dias Prado
                   ` (6 subsequent siblings)
  7 siblings, 1 reply; 20+ messages in thread
From: Drew Adams @ 2010-08-11 17:51 UTC (permalink / raw)
  To: 'Andrea Crotti', help-gnu-emacs

> This is probably very stupid but every time I step into it 
> and it's very annoying.
> 
> Supposing I want to copy something from Safari to emacs. So I
> - select and copy
> - select and kill the text I want to substitute
> - try to paste
> 
> ARGH! Now the text I copied from safari is disappeared...
> 
> A workardound is to delete first and then copy-paste.
> But is there a smarter way to solve this?
> Something like
> "if I copied something from the os keep it as first in the kill ring"?

When you report a problem, always mention your Emacs version.

If you are using a development version, then be aware that there is currently a
lot of change being made to the way selection (& copy & paste) behaves. There
are still problems that need to be fixed. Look at the bug list if you want to
see what problems are being discussed.




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

* Re: Simple copy & paste problem
  2010-08-11 17:51 ` Drew Adams
@ 2010-08-11 18:10   ` Andrea Crotti
  0 siblings, 0 replies; 20+ messages in thread
From: Andrea Crotti @ 2010-08-11 18:10 UTC (permalink / raw)
  To: help-gnu-emacs

"Drew Adams" <drew.adams@oracle.com> writes:

>
> When you report a problem, always mention your Emacs version.
>
> If you are using a development version, then be aware that there is currently a
> lot of change being made to the way selection (& copy & paste) behaves. There
> are still problems that need to be fixed. Look at the bug list if you want to
> see what problems are being discussed.

Yes right sorry:
GNU Emacs 23.2.1 (x86_64-apple-darwin10.3.0, NS apple-appkit-1038.29) of
2010-05-09 on linc

On osx 10.6

Well I don't see it as a bug, it's probably the normal behaviour since I
overwrite the last position in the kill ring.

But of course if it could be fixed or there is a nice workaround it
would be much better ;)




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

* Re: Simple copy & paste problem
       [not found] <mailman.4.1281546350.9082.help-gnu-emacs@gnu.org>
  2010-08-11 17:43 ` Simple copy & paste problem Pascal J. Bourguignon
@ 2010-08-11 18:11 ` notbob
  1 sibling, 0 replies; 20+ messages in thread
From: notbob @ 2010-08-11 18:11 UTC (permalink / raw)
  To: help-gnu-emacs

On 2010-08-11, Andrea Crotti <andrea.crotti.0@gmail.com> wrote:

> A workardound is to delete first and then copy-paste.

You call it a workaround.  I call it common sense.  Same number of
steps.

> But is there a smarter way to solve this?
> Something like
> "if I copied something from the os keep it as first in the kill ring"?

Not sure what you are calling a kill ring, but you could use KDE
desktop and its Windows-like clipboard copy/cut/paste approach while
running emacs in konsole.  No doubt there are other options, this
being Linux, not M$ or Apple.

nb


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

* Re: Simple copy & paste problem
  2010-08-11 16:51 Andrea Crotti
  2010-08-11 17:51 ` Drew Adams
@ 2010-08-11 19:05 ` Glauber Alex Dias Prado
  2010-08-11 19:15 ` Joel James Adamson
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 20+ messages in thread
From: Glauber Alex Dias Prado @ 2010-08-11 19:05 UTC (permalink / raw)
  To: Andrea Crotti; +Cc: help-gnu-emacs

Andrea Crotti <andrea.crotti.0@gmail.com> writes:

> This is probably very stupid but every time I step into it and it's very
> annoying.
>
> Supposing I want to copy something from Safari to emacs.
> So I
> - select and copy
> - select and kill the text I want to substitute
> - try to paste
>
> ARGH! Now the text I copied from safari is disappeared...
>
> A workardound is to delete first and then copy-paste.
> But is there a smarter way to solve this?
> Something like
> "if I copied something from the os keep it as first in the kill ring"?

never found something like this what i usually do is paste first then
kill or kill first then paste, dunno how much a solution to this problem
would be os dependant though.



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

* Re: Simple copy & paste problem
  2010-08-11 16:51 Andrea Crotti
  2010-08-11 17:51 ` Drew Adams
  2010-08-11 19:05 ` Glauber Alex Dias Prado
@ 2010-08-11 19:15 ` Joel James Adamson
  2010-08-11 20:06   ` Thierry Volpiatto
       [not found]   ` <mailman.4.1281557372.27891.help-gnu-emacs@gnu.org>
  2010-08-12  5:42 ` Jonathan Groll
                   ` (4 subsequent siblings)
  7 siblings, 2 replies; 20+ messages in thread
From: Joel James Adamson @ 2010-08-11 19:15 UTC (permalink / raw)
  To: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 807 bytes --]

Andrea Crotti <andrea.crotti.0@gmail.com> writes:

> This is probably very stupid but every time I step into it and it's very
> annoying.
>
> Supposing I want to copy something from Safari to emacs.
> So I
> - select and copy
> - select and kill the text I want to substitute
> - try to paste
>
> ARGH! Now the text I copied from safari is disappeared...
>
> A workardound is to delete first and then copy-paste.
> But is there a smarter way to solve this?
> Something like
> "if I copied something from the os keep it as first in the kill ring"?

How about drag and drop?  Does that work on OS X?  Select the text, then
drag it to Emacs.  That's usually what I do when I want to go from
Firefox to Emacs.

Joel

-- 
Joel J. Adamson
FSF Member #8164
http://www.unc.edu/~adamsonj

[-- Attachment #2: Type: application/pgp-signature, Size: 229 bytes --]

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

* Re: Simple copy & paste problem
  2010-08-11 19:15 ` Joel James Adamson
@ 2010-08-11 20:06   ` Thierry Volpiatto
  2010-08-11 22:44     ` Andrea Crotti
  2010-08-12 17:25     ` Joel James Adamson
       [not found]   ` <mailman.4.1281557372.27891.help-gnu-emacs@gnu.org>
  1 sibling, 2 replies; 20+ messages in thread
From: Thierry Volpiatto @ 2010-08-11 20:06 UTC (permalink / raw)
  To: help-gnu-emacs

Joel James Adamson <adamsonj@email.unc.edu> writes:

> Andrea Crotti <andrea.crotti.0@gmail.com> writes:
>
>> This is probably very stupid but every time I step into it and it's very
>> annoying.
>>
>> Supposing I want to copy something from Safari to emacs.
>> So I
>> - select and copy
>> - select and kill the text I want to substitute
>> - try to paste
>>
>> ARGH! Now the text I copied from safari is disappeared...
>>
>> A workardound is to delete first and then copy-paste.
>> But is there a smarter way to solve this?
>> Something like
>> "if I copied something from the os keep it as first in the kill ring"?
>
> How about drag and drop?  Does that work on OS X?  Select the text, then
> drag it to Emacs.  That's usually what I do when I want to go from
> Firefox to Emacs.

You can't do that if emacs and firefox are on differents desktops.
But you can use mouse2 (don't know for OSX).
You can use that also:

,----
| (defun yank-from-clipboard ()
|   (interactive)
|   (let ((primary (x-selection 'PRIMARY)))
|     (when primary (insert primary))))
| (global-set-key (kbd "C-c v") 'yank-from-clipboard)
`----

Like that nothing is added to emacs kill-ring.

If you don't mind adding to emacs kill-ring:

,----
| ;; (setq interprogram-paste-function 'x-cut-buffer-or-selection-value)
| ;; (setq x-select-enable-primary t)
`----

-- 
Thierry Volpiatto
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997 




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

* Re: Simple copy & paste problem
  2010-08-11 20:06   ` Thierry Volpiatto
@ 2010-08-11 22:44     ` Andrea Crotti
  2010-08-12 17:25     ` Joel James Adamson
  1 sibling, 0 replies; 20+ messages in thread
From: Andrea Crotti @ 2010-08-11 22:44 UTC (permalink / raw)
  To: help-gnu-emacs

Thierry Volpiatto <thierry.volpiatto@gmail.com> writes:

>
> You can't do that if emacs and firefox are on differents desktops.
> But you can use mouse2 (don't know for OSX).
> You can use that also:
>
> ,----
> | (defun yank-from-clipboard ()
> |   (interactive)
> |   (let ((primary (x-selection 'PRIMARY)))
> |     (when primary (insert primary))))
> | (global-set-key (kbd "C-c v") 'yank-from-clipboard)
> `----
>

That would be good but then I should use two different key bindings for
pasting, which is a bit annoying.
I also found this variable (by the way, how to you write with that nice
style?
This "cut here" is a bit too much...
--8<---------------cut here---------------start------------->8---
x-select-enable-clipboard is a variable defined in `C source code'.
It is void as a variable.

Documentation:
Non-nil means cutting and pasting uses the clipboard.
This is in addition to, but in preference to, the primary selection.
--8<---------------cut here---------------end--------------->8---

Would not be possible to avoid overwriting the clipboard entry with the
last entry killed?

Or is there a way to understand from emacs if something is copied on the
on the operating system clipboard?




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

* Re: Simple copy & paste problem
  2010-08-11 16:51 Andrea Crotti
                   ` (2 preceding siblings ...)
  2010-08-11 19:15 ` Joel James Adamson
@ 2010-08-12  5:42 ` Jonathan Groll
  2010-08-13  2:35 ` Kevin Rodgers
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 20+ messages in thread
From: Jonathan Groll @ 2010-08-12  5:42 UTC (permalink / raw)
  To: Andrea Crotti, help-gnu-emacs

On Wed, Aug 11, 2010 at 06:51:03PM +0200, Andrea Crotti wrote:
>This is probably very stupid but every time I step into it and it's very
>annoying.
>
>Supposing I want to copy something from Safari to emacs.
>So I
>- select and copy
>- select and kill the text I want to substitute
>- try to paste

Perhaps consider installing a clipboard manager:
http://theappleblog.com/2009/06/02/10-clipboard-managers-for-os-x/
   
Cheers,
Jonathan



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

* Re: Simple copy & paste problem
  2010-08-11 20:06   ` Thierry Volpiatto
  2010-08-11 22:44     ` Andrea Crotti
@ 2010-08-12 17:25     ` Joel James Adamson
  2010-08-12 18:14       ` Thierry Volpiatto
  1 sibling, 1 reply; 20+ messages in thread
From: Joel James Adamson @ 2010-08-12 17:25 UTC (permalink / raw)
  To: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 1296 bytes --]

Thierry Volpiatto <thierry.volpiatto@gmail.com> writes:

> Joel James Adamson <adamsonj@email.unc.edu> writes:
>
>> Andrea Crotti <andrea.crotti.0@gmail.com> writes:
>>
>>> This is probably very stupid but every time I step into it and it's very
>>> annoying.
>>>
>>> Supposing I want to copy something from Safari to emacs.
>>> So I
>>> - select and copy
>>> - select and kill the text I want to substitute
>>> - try to paste
>>>
>>> ARGH! Now the text I copied from safari is disappeared...
>>>
>>> A workardound is to delete first and then copy-paste.
>>> But is there a smarter way to solve this?
>>> Something like
>>> "if I copied something from the os keep it as first in the kill ring"?
>>
>> How about drag and drop?  Does that work on OS X?  Select the text, then
>> drag it to Emacs.  That's usually what I do when I want to go from
>> Firefox to Emacs.
>
> You can't do that if emacs and firefox are on differents desktops.
> But you can use mouse2 (don't know for OSX).
> You can use that also:

Hi Thierry,

What do you mean I can't?  I do that all the time.  Do you mean desktops
as in virtual desktops, as in many X window managers?  As I said, I do
it all the time.

Joel
-- 
Joel J. Adamson
FSF Member #8164
http://www.unc.edu/~adamsonj

[-- Attachment #2: Type: application/pgp-signature, Size: 229 bytes --]

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

* Re: Simple copy & paste problem
  2010-08-12 17:25     ` Joel James Adamson
@ 2010-08-12 18:14       ` Thierry Volpiatto
  0 siblings, 0 replies; 20+ messages in thread
From: Thierry Volpiatto @ 2010-08-12 18:14 UTC (permalink / raw)
  To: help-gnu-emacs

Joel James Adamson <adamsonj@email.unc.edu> writes:

> Thierry Volpiatto <thierry.volpiatto@gmail.com> writes:
>
>> Joel James Adamson <adamsonj@email.unc.edu> writes:
>>
>>> Andrea Crotti <andrea.crotti.0@gmail.com> writes:
>>>
>>>> This is probably very stupid but every time I step into it and it's very
>>>> annoying.
>>>>
>>>> Supposing I want to copy something from Safari to emacs.
>>>> So I
>>>> - select and copy
>>>> - select and kill the text I want to substitute
>>>> - try to paste
>>>>
>>>> ARGH! Now the text I copied from safari is disappeared...
>>>>
>>>> A workardound is to delete first and then copy-paste.
>>>> But is there a smarter way to solve this?
>>>> Something like
>>>> "if I copied something from the os keep it as first in the kill ring"?
>>>
>>> How about drag and drop?  Does that work on OS X?  Select the text, then
>>> drag it to Emacs.  That's usually what I do when I want to go from
>>> Firefox to Emacs.
>>
>> You can't do that if emacs and firefox are on differents desktops.
>> But you can use mouse2 (don't know for OSX).
>> You can use that also:
>
> Hi Thierry,
>
> What do you mean I can't?  I do that all the time.  Do you mean desktops
> as in virtual desktops, as in many X window managers?  As I said, I do
> it all the time.

Hi Joel,
yes i mean desktop of X window managers, they are called groups in my
window manager (stumpwm).
I don't understand how do you drag and drop if you have not the emacs
window and the firefox window on same frame or desktop.
Though i don't use the mouse often, so may be i miss something, thanks
to explain ;-)

-- 
Thierry Volpiatto
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997 




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

* Re: Simple copy & paste problem
  2010-08-11 16:51 Andrea Crotti
                   ` (3 preceding siblings ...)
  2010-08-12  5:42 ` Jonathan Groll
@ 2010-08-13  2:35 ` Kevin Rodgers
  2010-08-25 13:47 ` Leo
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 20+ messages in thread
From: Kevin Rodgers @ 2010-08-13  2:35 UTC (permalink / raw)
  To: help-gnu-emacs

Andrea Crotti wrote:
> This is probably very stupid but every time I step into it and it's very
> annoying.
> 
> Supposing I want to copy something from Safari to emacs.
> So I
> - select and copy
> - select and kill the text I want to substitute
> - try to paste
> 
> ARGH! Now the text I copied from safari is disappeared...

Delete the text in Emacs instead of killing it.  I use:

(global-set-key "\C-cw" 'delete-region)	  ; ala C-w and M-C-w

> A workardound is to delete first and then copy-paste.
> But is there a smarter way to solve this?
> Something like
> "if I copied something from the os keep it as first in the kill ring"?

-- 
Kevin Rodgers
Denver, Colorado, USA




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

* Re: Simple copy & paste problem
  2010-08-11 16:51 Andrea Crotti
                   ` (4 preceding siblings ...)
  2010-08-13  2:35 ` Kevin Rodgers
@ 2010-08-25 13:47 ` Leo
       [not found] ` <mailman.0.1281553020.25709.help-gnu-emacs@gnu.org>
       [not found] ` <mailman.4.1282744218.27059.help-gnu-emacs@gnu.org>
  7 siblings, 0 replies; 20+ messages in thread
From: Leo @ 2010-08-25 13:47 UTC (permalink / raw)
  To: help-gnu-emacs

On 2010-08-11 17:51 +0100, Andrea Crotti wrote:
> This is probably very stupid but every time I step into it and it's very
> annoying.
>
> Supposing I want to copy something from Safari to emacs.
> So I
> - select and copy
> - select and kill the text I want to substitute
> - try to paste
>
> ARGH! Now the text I copied from safari is disappeared...
>
> A workardound is to delete first and then copy-paste.
> But is there a smarter way to solve this?
> Something like
> "if I copied something from the os keep it as first in the kill ring"?

Set save-interprogram-paste-before-kill to t. If you think it should
default to t, report it as a bug.

Leo




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

* Re: Simple copy & paste problem
  2010-08-11 17:43 ` Simple copy & paste problem Pascal J. Bourguignon
@ 2010-09-05  1:44   ` David Combs
  2010-09-05  1:55     ` Pascal J. Bourguignon
  0 siblings, 1 reply; 20+ messages in thread
From: David Combs @ 2010-09-05  1:44 UTC (permalink / raw)
  To: help-gnu-emacs

In article <87fwyl9haf.fsf@kuiper.lan.informatimago.com>,
Pascal J. Bourguignon <pjb@informatimago.com> wrote:
>
>Use delete-region-and-yank instead of yank:
>
>(defun delete-region-and-yank (&optional arg)
>  "Deletes region if mark is active and yanks the last kill.
>Always replaces the region with the yank, whether the region was
>selected via keyboard or mouse.  Also works for normal
>yank even with ARGS (thus it can be mapped to \\C-y)"
>  (interactive "*P")                    ; raw, like yank.
>  (message "arg=%S" arg)
>  (cond
>    (mark-active                        ; delete region
>     (let ((str (buffer-substring (point) (mark))))
>       (delete-region (point) (mark))
>       (if (string=* str (current-kill 0 1))
>           (let ((str2 (current-kill 1 1)))
>             (kill-new str2 t))))
>     (if arg
>         (yank arg)
>         (yank)))
>    ;; else no region selected:
>    ((consp arg)                        ; delete forward sexp
>     (set-mark (point))
>     (forward-sexp 1)
>     (delete-region-and-yank))
>    (arg (yank arg))
>    (t   (yank))))
>
>
>-- 
>__Pascal Bourguignon__                     http://www.informatimago.com/


That function, delete-region-and-yank, is not part
of standard emacs -- its yours, you wrote it.

What, writing code is so easy that it flies off
your fingers as fast as you can type?

No, of course not.  So, pjb, what do you have, 
a whole library of these useful tools that you wrote?

With a little annotation of why you wrote function x,
and how it works, you'd have something you could,
if you felt super generous, provide it to everyone,
the library.

(For all I know, you already have!)


(With sufficient annotation (commenting), it'd be good
for additional examples of using elisp).


Thanks!

David




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

* Re: Simple copy & paste problem
       [not found] ` <mailman.0.1281553020.25709.help-gnu-emacs@gnu.org>
@ 2010-09-05  1:48   ` David Combs
  2010-09-29 21:20     ` David Combs
  0 siblings, 1 reply; 20+ messages in thread
From: David Combs @ 2010-09-05  1:48 UTC (permalink / raw)
  To: help-gnu-emacs

In article <mailman.0.1281553020.25709.help-gnu-emacs@gnu.org>,
Glauber Alex Dias Prado  <smade4@gmail.com> wrote:
>Andrea Crotti <andrea.crotti.0@gmail.com> writes:
>
>> This is probably very stupid but every time I step into it and it's very
>> annoying.
>>
>> Supposing I want to copy something from Safari to emacs.
>> So I
>> - select and copy
>> - select and kill the text I want to substitute
>> - try to paste
>>
>> ARGH! Now the text I copied from safari is disappeared...
>>
>> A workardound is to delete first and then copy-paste.
>> But is there a smarter way to solve this?
>> Something like
>> "if I copied something from the os keep it as first in the kill ring"?
>
>never found something like this what i usually do is paste first then
>kill or kill first then paste, dunno how much a solution to this problem
>would be os dependant though.
>

FWIW, when I want to COPY a region, I do this:
   C-w
   y   (yank it right back -- or C-x u (undo))
   go to other location
   y (again)

David




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

* Re: Simple copy & paste problem
  2010-09-05  1:44   ` David Combs
@ 2010-09-05  1:55     ` Pascal J. Bourguignon
  0 siblings, 0 replies; 20+ messages in thread
From: Pascal J. Bourguignon @ 2010-09-05  1:55 UTC (permalink / raw)
  To: help-gnu-emacs

dkcombs@panix.com (David Combs) writes:

> In article <87fwyl9haf.fsf@kuiper.lan.informatimago.com>,
> Pascal J. Bourguignon <pjb@informatimago.com> wrote:
>>
>>Use delete-region-and-yank instead of yank:
>>
>>(defun delete-region-and-yank (&optional arg)
>>  "Deletes region if mark is active and yanks the last kill.
>>Always replaces the region with the yank, whether the region was
>>selected via keyboard or mouse.  Also works for normal
>>yank even with ARGS (thus it can be mapped to \\C-y)"
>>  (interactive "*P")                    ; raw, like yank.
>>  (message "arg=%S" arg)
>>  (cond
>>    (mark-active                        ; delete region
>>     (let ((str (buffer-substring (point) (mark))))
>>       (delete-region (point) (mark))
>>       (if (string=* str (current-kill 0 1))
>>           (let ((str2 (current-kill 1 1)))
>>             (kill-new str2 t))))
>>     (if arg
>>         (yank arg)
>>         (yank)))
>>    ;; else no region selected:
>>    ((consp arg)                        ; delete forward sexp
>>     (set-mark (point))
>>     (forward-sexp 1)
>>     (delete-region-and-yank))
>>    (arg (yank arg))
>>    (t   (yank))))
>>
>>
>>-- 
>>__Pascal Bourguignon__                     http://www.informatimago.com/
>
>
> That function, delete-region-and-yank, is not part
> of standard emacs -- its yours, you wrote it.
>
> What, writing code is so easy that it flies off
> your fingers as fast as you can type?

Exactly.



> No, of course not.  

Yes, indeed.


> So, pjb, what do you have, 
> a whole library of these useful tools that you wrote?

Of course, I don't like to do twice the same thing.


> With a little annotation of why you wrote function x,
> and how it works, you'd have something you could,
> if you felt super generous, provide it to everyone,
> the library.

I have, and I do.


> (For all I know, you already have!)

Indeed.

> (With sufficient annotation (commenting), it'd be good
> for additional examples of using elisp).

Why don't you try to follow this little 
link you can find in all my signatures: ---------------+
Why do you think we take the pain of                   |
putting such links in our signatures?                  |
                                                       V
-- 
__Pascal Bourguignon__                     http://www.informatimago.com/



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

* Re: Simple copy & paste problem
       [not found]   ` <mailman.4.1281557372.27891.help-gnu-emacs@gnu.org>
@ 2010-09-05  1:59     ` David Combs
  0 siblings, 0 replies; 20+ messages in thread
From: David Combs @ 2010-09-05  1:59 UTC (permalink / raw)
  To: help-gnu-emacs

In article <mailman.4.1281557372.27891.help-gnu-emacs@gnu.org>,
Thierry Volpiatto  <thierry.volpiatto@gmail.com> wrote:
>Joel James Adamson <adamsonj@email.unc.edu> writes:
...
...
>
>You can't do that if emacs and firefox are on differents desktops.
>But you can use mouse2 (don't know for OSX).

     mouse2 -- what does that do?

>You can use that also:
>
>,----
>| (defun yank-from-clipboard ()
>|   (interactive)
>|   (let ((primary (x-selection 'PRIMARY)))
>|     (when primary (insert primary))))
>| (global-set-key (kbd "C-c v") 'yank-from-clipboard)
>`----
>
>Like that nothing is added to emacs kill-ring.
>
>If you don't mind adding to emacs kill-ring:
>
>,----
>| ;; (setq interprogram-paste-function 'x-cut-buffer-or-selection-value)
>| ;; (setq x-select-enable-primary t)
>`----


x-cut-buffer-or-selection-value is an alias for `x-get-selection-value' in `w32-fns.el'.
(x-cut-buffer-or-selection-value)

Return the value of the current selection.
Consult the selection, then the cut buffer.  Treat empty strings as if
they were unset.


What does that mean?  If there's a selection, use it,
else what's in the cut-buffer?   (cut-buffer -- what's that?)>

And that x-cut-buffer-or-selection-value -- not in 23.0.0.1.  ???



>-- 
>Thierry Volpiatto
>Get my Gnupg key:
>gpg --keyserver pgp.mit.edu --recv-keys 59F29997 
>
>

Thanks!

David



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

* Re: Simple copy & paste problem
       [not found] ` <mailman.4.1282744218.27059.help-gnu-emacs@gnu.org>
@ 2010-09-05  2:02   ` David Combs
  0 siblings, 0 replies; 20+ messages in thread
From: David Combs @ 2010-09-05  2:02 UTC (permalink / raw)
  To: help-gnu-emacs

In article <mailman.4.1282744218.27059.help-gnu-emacs@gnu.org>,
Leo  <sdl.web@gmail.com> wrote:
>On 2010-08-11 17:51 +0100, Andrea Crotti wrote:
>> This is probably very stupid but every time I step into it and it's very
>> annoying.
>>
>> Supposing I want to copy something from Safari to emacs.
>> So I
>> - select and copy
>> - select and kill the text I want to substitute
>> - try to paste
>>
>> ARGH! Now the text I copied from safari is disappeared...
>>
>> A workardound is to delete first and then copy-paste.
>> But is there a smarter way to solve this?
>> Something like
>> "if I copied something from the os keep it as first in the kill ring"?
>
>Set save-interprogram-paste-before-kill to t. If you think it should
>default to t, report it as a bug.

No such variable as save-interprogram... in 23.0.0.1, at least
not via C-h v.

David




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

* Re: Simple copy & paste problem
  2010-09-05  1:48   ` David Combs
@ 2010-09-29 21:20     ` David Combs
  0 siblings, 0 replies; 20+ messages in thread
From: David Combs @ 2010-09-29 21:20 UTC (permalink / raw)
  To: help-gnu-emacs

In article <i5usu1$ois$2@reader1.panix.com>,
David Combs <dkcombs@panix.com> wrote:
>
>FWIW, when I want to COPY a region, I do this:
>   C-w
>   y   (yank it right back -- or C-x u (undo))
>   go to other location
>   y (again)
>
>David
>
>

Oh, and why not M-w?

Because it's much more obvious, "in your face",
what is being copied, when the whole region
disappears (and comes back) than a cursor-bounce.

David




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

end of thread, other threads:[~2010-09-29 21:20 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <mailman.4.1281546350.9082.help-gnu-emacs@gnu.org>
2010-08-11 17:43 ` Simple copy & paste problem Pascal J. Bourguignon
2010-09-05  1:44   ` David Combs
2010-09-05  1:55     ` Pascal J. Bourguignon
2010-08-11 18:11 ` notbob
2010-08-11 16:51 Andrea Crotti
2010-08-11 17:51 ` Drew Adams
2010-08-11 18:10   ` Andrea Crotti
2010-08-11 19:05 ` Glauber Alex Dias Prado
2010-08-11 19:15 ` Joel James Adamson
2010-08-11 20:06   ` Thierry Volpiatto
2010-08-11 22:44     ` Andrea Crotti
2010-08-12 17:25     ` Joel James Adamson
2010-08-12 18:14       ` Thierry Volpiatto
     [not found]   ` <mailman.4.1281557372.27891.help-gnu-emacs@gnu.org>
2010-09-05  1:59     ` David Combs
2010-08-12  5:42 ` Jonathan Groll
2010-08-13  2:35 ` Kevin Rodgers
2010-08-25 13:47 ` Leo
     [not found] ` <mailman.0.1281553020.25709.help-gnu-emacs@gnu.org>
2010-09-05  1:48   ` David Combs
2010-09-29 21:20     ` David Combs
     [not found] ` <mailman.4.1282744218.27059.help-gnu-emacs@gnu.org>
2010-09-05  2:02   ` David Combs

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.