* Selection not to be copied into kill-ring @ 2007-07-12 12:14 Will 2007-07-12 12:29 ` weber ` (3 more replies) 0 siblings, 4 replies; 7+ messages in thread From: Will @ 2007-07-12 12:14 UTC (permalink / raw) To: help-gnu-emacs Hi, I'd like to copy text from external applications (e.g. web browser) to an Emacs buffer. Often before I paste the text into an Emacs buffer I'd like to delete text in the this buffer _without_ it being copied to the kill-ring, because then the text from the external application gets lost. => How do I switch off that hightlighted text is copied automatially into the kill-ring? => How do I delete a region without it getting copied into the kill-ring, e.g. by highlighting the text and pressing <delete>? Thanks in advance, Will PS: I am working with GNU Emacs 22.1.1 (i386-mingw-nt5.1.2600) of 2007-06-02 on RELEASE with MS Windows XP. ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Selection not to be copied into kill-ring 2007-07-12 12:14 Selection not to be copied into kill-ring Will @ 2007-07-12 12:29 ` weber 2007-07-12 12:53 ` Eli Zaretskii ` (2 subsequent siblings) 3 siblings, 0 replies; 7+ messages in thread From: weber @ 2007-07-12 12:29 UTC (permalink / raw) To: help-gnu-emacs On 12 jul, 09:14, Will <schimpan...@gmx.de> wrote: > Hi, > > I'd like to copy text from external applications (e.g. web browser) to > an Emacs buffer. Often before I paste the text into an Emacs buffer I'd > like to delete text in the this buffer _without_ it being copied to the > kill-ring, because then the text from the external application gets lost. > > => How do I switch off that hightlighted text is copied automatially > into the kill-ring? > => How do I delete a region without it getting copied into the > kill-ring, e.g. by highlighting the text and pressing <delete>? > > Thanks in advance, > > Will > > PS: I am working with > GNU Emacs 22.1.1 (i386-mingw-nt5.1.2600) of 2007-06-02 on RELEASE > with MS Windows XP. There is another command, delete-region, that doesn't copy to the kill ring. You could bind it to delete like this: (define-key global-map (kbd "<delete>") 'delete-region) HTH, weber ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Selection not to be copied into kill-ring 2007-07-12 12:14 Selection not to be copied into kill-ring Will 2007-07-12 12:29 ` weber @ 2007-07-12 12:53 ` Eli Zaretskii 2007-07-12 15:21 ` Peter Dyballa [not found] ` <mailman.3386.1184244752.32220.help-gnu-emacs@gnu.org> 3 siblings, 0 replies; 7+ messages in thread From: Eli Zaretskii @ 2007-07-12 12:53 UTC (permalink / raw) To: help-gnu-emacs > From: Will <schimpanski@gmx.de> > Newsgroups: gnu.emacs.help > Date: Thu, 12 Jul 2007 14:14:01 +0200 > > I'd like to copy text from external applications (e.g. web browser) to > an Emacs buffer. Often before I paste the text into an Emacs buffer I'd > like to delete text in the this buffer _without_ it being copied to the > kill-ring, because then the text from the external application gets lost. > > => How do I switch off that hightlighted text is copied automatially > into the kill-ring? > => How do I delete a region without it getting copied into the > kill-ring, e.g. by highlighting the text and pressing <delete>? Try "M-x delete-selection-mode RET". Is this what you want? ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Selection not to be copied into kill-ring 2007-07-12 12:14 Selection not to be copied into kill-ring Will 2007-07-12 12:29 ` weber 2007-07-12 12:53 ` Eli Zaretskii @ 2007-07-12 15:21 ` Peter Dyballa [not found] ` <mailman.3386.1184244752.32220.help-gnu-emacs@gnu.org> 3 siblings, 0 replies; 7+ messages in thread From: Peter Dyballa @ 2007-07-12 15:21 UTC (permalink / raw) To: Will; +Cc: help-gnu-emacs Am 12.07.2007 um 14:14 schrieb Will: > => How do I switch off that hightlighted text is copied > automatially into the kill-ring? Do not mark it with the mouse. This mode has side-effects ... > => How do I delete a region without it getting copied into the kill- > ring, e.g. by highlighting the text and pressing <delete>? Mark without mouse, then delete-region. I think you would need to change the bindings of <down-mouse-1> and <mouse-1>, which isn't easy because both events can run different functions depending on the context (for example mouse-drag-region) ... -- Mit friedvollen Grüßen Pete Macht kaputt, was Afghanistan kaputt macht! ^ permalink raw reply [flat|nested] 7+ messages in thread
[parent not found: <mailman.3386.1184244752.32220.help-gnu-emacs@gnu.org>]
* Saving the selection before killing (was: Selection not to be copied into kill-ring) [not found] ` <mailman.3386.1184244752.32220.help-gnu-emacs@gnu.org> @ 2007-07-12 20:31 ` Stefan Monnier [not found] ` <jwvmyy1qskp.fsf-monnier+gnu.emacs.help@gnu.org> 1 sibling, 0 replies; 7+ messages in thread From: Stefan Monnier @ 2007-07-12 20:31 UTC (permalink / raw) To: help-gnu-emacs; +Cc: emacs-devel >>>>> "Eli" == Eli Zaretskii <eliz@gnu.org> writes: >> From: Will <schimpanski@gmx.de> >> Newsgroups: gnu.emacs.help >> Date: Thu, 12 Jul 2007 14:14:01 +0200 >> >> I'd like to copy text from external applications (e.g. web browser) to >> an Emacs buffer. Often before I paste the text into an Emacs buffer I'd >> like to delete text in the this buffer _without_ it being copied to the >> kill-ring, because then the text from the external application gets lost. >> >> => How do I switch off that hightlighted text is copied automatially >> into the kill-ring? >> => How do I delete a region without it getting copied into the >> kill-ring, e.g. by highlighting the text and pressing <delete>? > Try "M-x delete-selection-mode RET". Is this what you want? I bump into the OP's problem every once in a while, but I don't like delete-selection-mode for some reason, so I use the patch below instead. What it does is that when you kill text, before doing the kill (which will replace the current X-selection with the killed text), we save the current selection on the kill-ring (only if it doesn't come from us, of course since otherwise it's already in the kill-ring). So I can simply do my kill and then C-y (which re-inserts what I just killed) and M-y (which replaces the text with the previous X-selection). This feature is pretty unnoticeable, so I'm tempted to install it just like that, but maybe people want yet-another-config-var to control it? Stefan --- orig/lisp/simple.el +++ mod/lisp/simple.el @@ -2479,6 +2536,20 @@ argument is not used by `insert-for-yank'. However, since Lisp code may access and use elements from the kill ring directly, the STRING argument should still be a \"useful\" string for such uses." + ;; To better pretend that X-selection = head-of-kill-ring, we copy other + ;; application's X-selection to the kill-ring. This comes in handy when + ;; you do something like: + ;; - copy a piece of text in your web-browser. + ;; - have to do some editing (including killing) before you can yank + ;; that text. + ;; Note: this piece of code inspired from current-kill. + (let ((paste (and interprogram-paste-function + (funcall interprogram-paste-function)))) + (when paste + (let ((interprogram-cut-function nil) + (interprogram-paste-function nil)) + (kill-new paste)))) + ;; The actual kill-new functionality. (if (> (length string) 0) (if yank-handler (put-text-property 0 (length string) ^ permalink raw reply [flat|nested] 7+ messages in thread
[parent not found: <jwvmyy1qskp.fsf-monnier+gnu.emacs.help@gnu.org>]
* Re: Saving the selection before killing [not found] ` <jwvmyy1qskp.fsf-monnier+gnu.emacs.help@gnu.org> @ 2007-07-12 20:45 ` David Kastrup 2007-07-13 7:23 ` Will 1 sibling, 0 replies; 7+ messages in thread From: David Kastrup @ 2007-07-12 20:45 UTC (permalink / raw) To: help-gnu-emacs; +Cc: emacs-devel Stefan Monnier <monnier@iro.umontreal.ca> writes: >>> From: Will <schimpanski@gmx.de> >>> Newsgroups: gnu.emacs.help >>> Date: Thu, 12 Jul 2007 14:14:01 +0200 >>> >>> I'd like to copy text from external applications (e.g. web >>> browser) to an Emacs buffer. Often before I paste the text into an >>> Emacs buffer I'd like to delete text in the this buffer _without_ >>> it being copied to the kill-ring, because then the text from the >>> external application gets lost. > > I bump into the OP's problem every once in a while, but I don't like > delete-selection-mode for some reason, so I use the patch below > instead. What it does is that when you kill text, before doing the > kill (which will replace the current X-selection with the killed > text), we save the current selection on the kill-ring (only if it > doesn't come from us, of course since otherwise it's already in the > kill-ring). So I can simply do my kill and then C-y (which > re-inserts what I just killed) and M-y (which replaces the text with > the previous X-selection). > > This feature is pretty unnoticeable, so I'm tempted to install it > just like that, but maybe people want yet-another-config-var to > control it? The problem I see is that it is pretty unnoticeable iff the size of the selection is small compared to the network bandwidth. It would be nicest if Emacs could tell the X server "if someone asks for a selection, tell me, and then I'll tell you whether I'll hand over a selection, or whether you can ask the one who has it now for it." I don't know the X protocols to know whether this is feasible with regard to the network traffic. It might be infeasible due to program's expectations about the kill ring, anyway. -- David Kastrup, Kriemhildstr. 15, 44793 Bochum ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Saving the selection before killing [not found] ` <jwvmyy1qskp.fsf-monnier+gnu.emacs.help@gnu.org> 2007-07-12 20:45 ` Saving the selection before killing David Kastrup @ 2007-07-13 7:23 ` Will 1 sibling, 0 replies; 7+ messages in thread From: Will @ 2007-07-13 7:23 UTC (permalink / raw) To: help-gnu-emacs Hi, Stefan, thanks for helping. However, I couldn't make your code work. I saved it an extra library and loaded it with "require" after adding some missing brackets, provide command etc. When I evaluate (if (> (length string) 0) (if yank-handler (put-text-property 0 (length string) ))) it still get errors like: Debugger entered--Lisp error: (void-variable string) (length string) (> (length string) 0) (if (> (length string) 0) (if yank-handler (put-text-property 0 ...))) eval((if (> (length string) 0) (if yank-handler (put-text-property 0 ...)))) eval-last-sexp-1(nil) eval-last-sexp(nil) call-interactively(eval-last-sexp) Best, Will Stefan Monnier skrev: >>>>>> "Eli" == Eli Zaretskii <eliz@gnu.org> writes: >>> From: Will <schimpanski@gmx.de> >>> Newsgroups: gnu.emacs.help >>> Date: Thu, 12 Jul 2007 14:14:01 +0200 >>> >>> I'd like to copy text from external applications (e.g. web browser) to >>> an Emacs buffer. Often before I paste the text into an Emacs buffer I'd >>> like to delete text in the this buffer _without_ it being copied to the >>> kill-ring, because then the text from the external application gets lost. >>> >>> => How do I switch off that hightlighted text is copied automatially >>> into the kill-ring? >>> => How do I delete a region without it getting copied into the >>> kill-ring, e.g. by highlighting the text and pressing <delete>? > >> Try "M-x delete-selection-mode RET". Is this what you want? > > I bump into the OP's problem every once in a while, but I don't like > delete-selection-mode for some reason, so I use the patch below instead. > What it does is that when you kill text, before doing the kill (which will > replace the current X-selection with the killed text), we save the current > selection on the kill-ring (only if it doesn't come from us, of course > since otherwise it's already in the kill-ring). So I can simply do my kill > and then C-y (which re-inserts what I just killed) and M-y (which replaces > the text with the previous X-selection). > > This feature is pretty unnoticeable, so I'm tempted to install it just like > that, but maybe people want yet-another-config-var to control it? > > > Stefan > > > --- orig/lisp/simple.el > +++ mod/lisp/simple.el > @@ -2479,6 +2536,20 @@ > argument is not used by `insert-for-yank'. However, since Lisp code > may access and use elements from the kill ring directly, the STRING > argument should still be a \"useful\" string for such uses." > + ;; To better pretend that X-selection = head-of-kill-ring, we copy other > + ;; application's X-selection to the kill-ring. This comes in handy when > + ;; you do something like: > + ;; - copy a piece of text in your web-browser. > + ;; - have to do some editing (including killing) before you can yank > + ;; that text. > + ;; Note: this piece of code inspired from current-kill. > + (let ((paste (and interprogram-paste-function > + (funcall interprogram-paste-function)))) > + (when paste > + (let ((interprogram-cut-function nil) > + (interprogram-paste-function nil)) > + (kill-new paste)))) > + ;; The actual kill-new functionality. > (if (> (length string) 0) > (if yank-handler > (put-text-property 0 (length string) ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2007-07-13 7:23 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2007-07-12 12:14 Selection not to be copied into kill-ring Will 2007-07-12 12:29 ` weber 2007-07-12 12:53 ` Eli Zaretskii 2007-07-12 15:21 ` Peter Dyballa [not found] ` <mailman.3386.1184244752.32220.help-gnu-emacs@gnu.org> 2007-07-12 20:31 ` Saving the selection before killing (was: Selection not to be copied into kill-ring) Stefan Monnier [not found] ` <jwvmyy1qskp.fsf-monnier+gnu.emacs.help@gnu.org> 2007-07-12 20:45 ` Saving the selection before killing David Kastrup 2007-07-13 7:23 ` Will
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).