* delete-region - is their a way to get the deleted text?
@ 2013-06-13 8:49 Thorsten Jolitz
2013-06-13 8:56 ` Peter Dyballa
` (2 more replies)
0 siblings, 3 replies; 18+ messages in thread
From: Thorsten Jolitz @ 2013-06-13 8:49 UTC (permalink / raw)
To: help-gnu-emacs
Hi List,
I found a function that would be useful for me as is - if only I would
have access to the region deleted with 'delete-region' inside that
function.
,------------------------------------------------------------------
| (delete-region START END)
| Delete the text between START and END.
| This command deletes buffer text without modifying the kill ring.
`------------------------------------------------------------------
If its not in the kill ring - is there any other way to get the text
that deleted, or is it simply gone and lost?
--
cheers,
Thorsten
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: delete-region - is their a way to get the deleted text?
2013-06-13 8:49 Thorsten Jolitz
@ 2013-06-13 8:56 ` Peter Dyballa
2013-06-13 9:25 ` Eric Abrahamsen
2013-06-13 16:16 ` David Engster
2 siblings, 0 replies; 18+ messages in thread
From: Peter Dyballa @ 2013-06-13 8:56 UTC (permalink / raw)
To: Thorsten Jolitz; +Cc: help-gnu-emacs
Am 13.06.2013 um 10:49 schrieb Thorsten Jolitz:
> If its not in the kill ring - is there any other way to get the text
> that deleted, or is it simply gone and lost?
You can undo and then perform kill-region…
--
Mit friedvollen Grüßen
Pete
My sister opened a computer store in Hawaii. She sells C shells down by the seashore.
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: delete-region - is their a way to get the deleted text?
2013-06-13 8:49 Thorsten Jolitz
2013-06-13 8:56 ` Peter Dyballa
@ 2013-06-13 9:25 ` Eric Abrahamsen
2013-06-13 10:00 ` Peter Dyballa
[not found] ` <mailman.1532.1371117614.22516.help-gnu-emacs@gnu.org>
2013-06-13 16:16 ` David Engster
2 siblings, 2 replies; 18+ messages in thread
From: Eric Abrahamsen @ 2013-06-13 9:25 UTC (permalink / raw)
To: help-gnu-emacs
Thorsten Jolitz <tjolitz@gmail.com> writes:
> Hi List,
>
> I found a function that would be useful for me as is - if only I would
> have access to the region deleted with 'delete-region' inside that
> function.
>
> ,------------------------------------------------------------------
> | (delete-region START END)
> | Delete the text between START and END.
> | This command deletes buffer text without modifying the kill ring.
> `------------------------------------------------------------------
>
> If its not in the kill ring - is there any other way to get the text
> that deleted, or is it simply gone and lost?
`delete-and-extract-region'!
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: delete-region - is their a way to get the deleted text?
2013-06-13 9:25 ` Eric Abrahamsen
@ 2013-06-13 10:00 ` Peter Dyballa
2013-06-13 10:20 ` Thorsten Jolitz
2013-06-13 10:23 ` Eric Abrahamsen
[not found] ` <mailman.1532.1371117614.22516.help-gnu-emacs@gnu.org>
1 sibling, 2 replies; 18+ messages in thread
From: Peter Dyballa @ 2013-06-13 10:00 UTC (permalink / raw)
To: Eric Abrahamsen; +Cc: help-gnu-emacs
Am 13.06.2013 um 11:25 schrieb Eric Abrahamsen:
> delete-and-extract-region
Which is not interactive…
--
Greetings
Pete
Chicago, n.:
Where the dead still vote … early and often!
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: delete-region - is their a way to get the deleted text?
2013-06-13 10:00 ` Peter Dyballa
@ 2013-06-13 10:20 ` Thorsten Jolitz
2013-06-13 10:23 ` Eric Abrahamsen
1 sibling, 0 replies; 18+ messages in thread
From: Thorsten Jolitz @ 2013-06-13 10:20 UTC (permalink / raw)
To: help-gnu-emacs
Peter Dyballa <Peter_Dyballa@Web.DE> writes:
> Am 13.06.2013 um 11:25 schrieb Eric Abrahamsen:
>
>> delete-and-extract-region
>
> Which is not interactive…
,--------------------------------
| (defun fun-from-other-pkg ()
| [... do a lot of things ...]
| (delete-region ...)
| [... do more things ...] )
`--------------------------------
It must not be interactive, the problem is that I could reuse
`fun-from-other-pkg' as-is if I could get my hands on the deleted
region, but I can't change that function.
Of course I could simply copy it and replace `delete-region' with
`delete-and-extract-region' (thanks for the tip!), and thats probably
what I' going to do, but I wanted to make sure that there is really no
way to recover the deleted string of `delete-region'.
--
cheers,
Thorsten
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: delete-region - is their a way to get the deleted text?
2013-06-13 10:00 ` Peter Dyballa
2013-06-13 10:20 ` Thorsten Jolitz
@ 2013-06-13 10:23 ` Eric Abrahamsen
1 sibling, 0 replies; 18+ messages in thread
From: Eric Abrahamsen @ 2013-06-13 10:23 UTC (permalink / raw)
To: help-gnu-emacs
Peter Dyballa <Peter_Dyballa@Web.DE> writes:
> Am 13.06.2013 um 11:25 schrieb Eric Abrahamsen:
>
>> delete-and-extract-region
>
> Which is not interactive…
Whoops, missed that requirement...
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: delete-region - is their a way to get the deleted text?
[not found] ` <mailman.1532.1371117614.22516.help-gnu-emacs@gnu.org>
@ 2013-06-13 13:33 ` Barry Margolin
2013-06-13 18:31 ` Peter Dyballa
[not found] ` <mailman.1597.1371148312.22516.help-gnu-emacs@gnu.org>
0 siblings, 2 replies; 18+ messages in thread
From: Barry Margolin @ 2013-06-13 13:33 UTC (permalink / raw)
To: help-gnu-emacs
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 460 bytes --]
In article <mailman.1532.1371117614.22516.help-gnu-emacs@gnu.org>,
Peter Dyballa <Peter_Dyballa@Web.DE> wrote:
> Am 13.06.2013 um 11:25 schrieb Eric Abrahamsen:
>
> > delete-and-extract-region
>
> Which is not interactive
Why is that needed? The OP said that he needed access to the deleted
region within the function that calls it.
--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: delete-region - is their a way to get the deleted text?
[not found] <mailman.1524.1371113397.22516.help-gnu-emacs@gnu.org>
@ 2013-06-13 15:11 ` Stefan Monnier
2013-06-14 8:18 ` Thorsten Jolitz
0 siblings, 1 reply; 18+ messages in thread
From: Stefan Monnier @ 2013-06-13 15:11 UTC (permalink / raw)
To: help-gnu-emacs
> ,------------------------------------------------------------------
> | (delete-region START END)
> | Delete the text between START and END.
> | This command deletes buffer text without modifying the kill ring.
> `------------------------------------------------------------------
> If its not in the kill ring - is there any other way to get the text
> that deleted, or is it simply gone and lost?
By and large it's gone and lost. What you can do:
- copy the text before calling the function (then try and figure out
which part of the text was deleted).
- make sure the function is called with undo enabled, then look for the
deleted string in the undo log (that's how delete-and-extract-region
was originally coded, back when I wrote it in Elisp).
- temporarily advise delete-region so it stashes its result in
some variable.
- even nastier hacks can be imagined, of course.
Stefan
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: delete-region - is their a way to get the deleted text?
2013-06-13 8:49 Thorsten Jolitz
2013-06-13 8:56 ` Peter Dyballa
2013-06-13 9:25 ` Eric Abrahamsen
@ 2013-06-13 16:16 ` David Engster
2013-06-14 8:20 ` Thorsten Jolitz
2 siblings, 1 reply; 18+ messages in thread
From: David Engster @ 2013-06-13 16:16 UTC (permalink / raw)
To: help-gnu-emacs
Thorsten Jolitz writes:
> I found a function that would be useful for me as is - if only I would
> have access to the region deleted with 'delete-region' inside that
> function.
>
> ,------------------------------------------------------------------
> | (delete-region START END)
> | Delete the text between START and END.
> | This command deletes buffer text without modifying the kill ring.
> `------------------------------------------------------------------
>
> If its not in the kill ring - is there any other way to get the text
> that deleted, or is it simply gone and lost?
Well, there's always the super-hacky way:
(require 'cl)
(defadvice your-function-of-interest
(around replace-delete-with-kill activate)
"Replace `delete-region' with `kill-region'."
(flet ((delete-region (x y)
(kill-region x y)))
ad-do-it))
And then just yank...
-David
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: delete-region - is their a way to get the deleted text?
2013-06-13 13:33 ` Barry Margolin
@ 2013-06-13 18:31 ` Peter Dyballa
[not found] ` <mailman.1597.1371148312.22516.help-gnu-emacs@gnu.org>
1 sibling, 0 replies; 18+ messages in thread
From: Peter Dyballa @ 2013-06-13 18:31 UTC (permalink / raw)
To: Barry Margolin; +Cc: help-gnu-emacs
Am 13.06.2013 um 15:33 schrieb Barry Margolin:
> Why is that needed?
Because delete-region is an interactive command. I naturally assumed that a substitute should a few features of the original command. Or it wouldn't be a substitute.
> The OP said that he needed access to the deleted region within the function that calls it.
That's not true. Or my English is too bad.
--
Greetings
Pete
Mushrooms always grow in damp places, which is why they look like umbrellas.
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: delete-region - is their a way to get the deleted text?
[not found] ` <mailman.1597.1371148312.22516.help-gnu-emacs@gnu.org>
@ 2013-06-13 18:51 ` Barry Margolin
2013-06-13 19:41 ` Peter Dyballa
[not found] ` <mailman.1599.1371152513.22516.help-gnu-emacs@gnu.org>
0 siblings, 2 replies; 18+ messages in thread
From: Barry Margolin @ 2013-06-13 18:51 UTC (permalink / raw)
To: help-gnu-emacs
In article <mailman.1597.1371148312.22516.help-gnu-emacs@gnu.org>,
Peter Dyballa <Peter_Dyballa@Web.DE> wrote:
> Am 13.06.2013 um 15:33 schrieb Barry Margolin:
>
> > Why is that needed?
>
> Because delete-region is an interactive command. I naturally assumed that a
> substitute should a few features of the original command. Or it wouldn't be a
> substitute.
He didn't ask for a complete substitute, just something that provides
access to the deleted region for the caller.
>
> > The OP said that he needed access to the deleted region within the function
> > that calls it.
>
> That's not true. Or my English is too bad.
He wrote "if only I would have access to the region deleted with
'delete-region' inside that function."
It's confusing because there's no antecedent to "that function". But the
only possibility that makes sense to me is "the function that calls
delete-region".
--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: delete-region - is their a way to get the deleted text?
2013-06-13 18:51 ` Barry Margolin
@ 2013-06-13 19:41 ` Peter Dyballa
[not found] ` <mailman.1599.1371152513.22516.help-gnu-emacs@gnu.org>
1 sibling, 0 replies; 18+ messages in thread
From: Peter Dyballa @ 2013-06-13 19:41 UTC (permalink / raw)
To: Barry Margolin; +Cc: help-gnu-emacs
Am 13.06.2013 um 20:51 schrieb Barry Margolin:
> He wrote "if only I would have access to the region deleted with
> 'delete-region' inside that function."
>
> It's confusing because there's no antecedent to "that function". But the
> only possibility that makes sense to me is "the function that calls
> delete-region".
"That function" is clearly 'delete-region' – or why would Thorsten have asked for a function that is used in a function that returns the deleted text? (Commas are missing.)
--
Greetings
Pete
Cyanide is so poisonous that one drop of it on a dog's tongue will kill the strongest man.
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: delete-region - is their a way to get the deleted text?
[not found] ` <mailman.1599.1371152513.22516.help-gnu-emacs@gnu.org>
@ 2013-06-13 21:08 ` Barry Margolin
2013-06-13 23:00 ` Peter Dyballa
0 siblings, 1 reply; 18+ messages in thread
From: Barry Margolin @ 2013-06-13 21:08 UTC (permalink / raw)
To: help-gnu-emacs
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1096 bytes --]
In article <mailman.1599.1371152513.22516.help-gnu-emacs@gnu.org>,
Peter Dyballa <Peter_Dyballa@Web.DE> wrote:
> Am 13.06.2013 um 20:51 schrieb Barry Margolin:
>
> > He wrote "if only I would have access to the region deleted with
> > 'delete-region' inside that function."
> >
> > It's confusing because there's no antecedent to "that function". But the
> > only possibility that makes sense to me is "the function that calls
> > delete-region".
>
> "That function" is clearly 'delete-region' or why would Thorsten have asked
> for a function that is used in a function that returns the deleted text?
> (Commas are missing.)
I can't figure out what this interpretation means. Are "deleted with"
and "inside that function" both saying the same thing? Where do the
missing commas go?
For the interpretation you have, isn't that what wipe-region does? It
deletes the region, and puts it on the kill ring, which gives you access
to the region that was deleted.
--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: delete-region - is their a way to get the deleted text?
2013-06-13 21:08 ` Barry Margolin
@ 2013-06-13 23:00 ` Peter Dyballa
2013-06-14 8:15 ` Thorsten Jolitz
0 siblings, 1 reply; 18+ messages in thread
From: Peter Dyballa @ 2013-06-13 23:00 UTC (permalink / raw)
To: Barry Margolin; +Cc: help-gnu-emacs
Am 13.06.2013 um 23:08 schrieb Barry Margolin:
> I can't figure out what this interpretation means.
That's OK! From time to time I am satisfied when I understand what I said. Or wrote.
> Are "deleted with" and "inside that function" both saying the same thing?
Not to me! But I am not an US American.
> Where do the missing commas go?
For the German language I would know it by heart, we have (no, we *had*, in last millennium) clear rules. For English I would wish I would like to know the exact rules – if there were any.
>
> For the interpretation you have, isn't that what wipe-region does?
I don't know that function. When was it deleted? I mentioned to Thorsten a similar function, "kill-region", which, as far as I know, is interactively putting the wiped out text into the kill-ring.
--
Greetings
Pete
Sorry my terrible English, my native language Lisp
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: delete-region - is their a way to get the deleted text?
2013-06-13 23:00 ` Peter Dyballa
@ 2013-06-14 8:15 ` Thorsten Jolitz
2013-06-14 8:37 ` Peter Dyballa
0 siblings, 1 reply; 18+ messages in thread
From: Thorsten Jolitz @ 2013-06-14 8:15 UTC (permalink / raw)
To: help-gnu-emacs
Peter Dyballa <Peter_Dyballa@Web.DE> writes:
Hi Peter, Hi Barry,
> Am 13.06.2013 um 23:08 schrieb Barry Margolin:
>
>> I can't figure out what this interpretation means.
sorry for the confusion my comma-less English caused, you are not the
first ones critizising this (it actually started in high-school) and its
not restricted to Englisch (the number of commas in some German texts I
wrote doubled after a second author/editor had a look at them ;).
But in German in actually no problem anymore, since they made so many
language reforms in the past decades that we lost track and started to
use phonetic spelling again like in Martin Luther's time ...
> That's OK! From time to time I am satisfied when I understand what I
> said. Or wrote.
>
>> Are "deleted with" and "inside that function" both saying the same thing?
>
> Not to me! But I am not an US American.
>
>> Where do the missing commas go?
>
> For the German language I would know it by heart, we have (no, we *had*, in
> last millennium) clear rules. For English I would wish I would like to know
> the exact rules – if there were any.
I meant this:
- there is a function that does what I want
- except it uses delete-region in its implementation
- because I need access to the deleted string
and my question was, [watch the comma!] if there is a way to resuse the
function, [!] and somehow recover the deleted region? It was not about
writing my own function with an alternative implementation (e.g.
kill-region).
>> For the interpretation you have, isn't that what wipe-region does?
>
> I don't know that function. When was it deleted? I mentioned to Thorsten a
> similar function, "kill-region", which, as far as I know, is interactively
> putting the wiped out text into the kill-ring.
There are some interesting hacks proposed as solutions in the thread,
thanks for your interest!
--
cheers,
Thorsten
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: delete-region - is their a way to get the deleted text?
2013-06-13 15:11 ` delete-region - is their a way to get the deleted text? Stefan Monnier
@ 2013-06-14 8:18 ` Thorsten Jolitz
0 siblings, 0 replies; 18+ messages in thread
From: Thorsten Jolitz @ 2013-06-14 8:18 UTC (permalink / raw)
To: help-gnu-emacs
Stefan Monnier <monnier@iro.umontreal.ca> writes:
>> ,------------------------------------------------------------------
>> | (delete-region START END)
>> | Delete the text between START and END.
>> | This command deletes buffer text without modifying the kill ring.
>> `------------------------------------------------------------------
>> If its not in the kill ring - is there any other way to get the text
>> that deleted, or is it simply gone and lost?
> - make sure the function is called with undo enabled, then look for the
> deleted string in the undo log (that's how delete-and-extract-region
> was originally coded, back when I wrote it in Elisp).
that sounds reasonably simple
> - temporarily advise delete-region so it stashes its result in
> some variable.
another option I like
> - even nastier hacks can be imagined, of course.
thanks for the tips!
--
cheers,
Thorsten
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: delete-region - is their a way to get the deleted text?
2013-06-13 16:16 ` David Engster
@ 2013-06-14 8:20 ` Thorsten Jolitz
0 siblings, 0 replies; 18+ messages in thread
From: Thorsten Jolitz @ 2013-06-14 8:20 UTC (permalink / raw)
To: help-gnu-emacs
David Engster <deng@randomsample.de> writes:
> Thorsten Jolitz writes:
>> I found a function that would be useful for me as is - if only I would
>> have access to the region deleted with 'delete-region' inside that
>> function.
>>
>> ,------------------------------------------------------------------
>> | (delete-region START END)
>> | Delete the text between START and END.
>> | This command deletes buffer text without modifying the kill ring.
>> `------------------------------------------------------------------
>>
>> If its not in the kill ring - is there any other way to get the text
>> that deleted, or is it simply gone and lost?
>
> Well, there's always the super-hacky way:
>
> (require 'cl)
>
> (defadvice your-function-of-interest
> (around replace-delete-with-kill activate)
> "Replace `delete-region' with `kill-region'."
> (flet ((delete-region (x y)
> (kill-region x y)))
> ad-do-it))
>
> And then just yank...
Not that I understand all of it, but it seems to do exactly what I want.
Thanks!
--
cheers,
Thorsten
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: delete-region - is their a way to get the deleted text?
2013-06-14 8:15 ` Thorsten Jolitz
@ 2013-06-14 8:37 ` Peter Dyballa
0 siblings, 0 replies; 18+ messages in thread
From: Peter Dyballa @ 2013-06-14 8:37 UTC (permalink / raw)
To: Thorsten Jolitz; +Cc: help-gnu-emacs
Am 14.06.2013 um 10:15 schrieb Thorsten Jolitz:
> thanks for your interest!
Well, I had some fun, I should be more thankful!
--
Mit friedvollen Grüßen
Pete
Mit Jazz statt Bomben gegen die Taliban!
^ permalink raw reply [flat|nested] 18+ messages in thread
end of thread, other threads:[~2013-06-14 8:37 UTC | newest]
Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <mailman.1524.1371113397.22516.help-gnu-emacs@gnu.org>
2013-06-13 15:11 ` delete-region - is their a way to get the deleted text? Stefan Monnier
2013-06-14 8:18 ` Thorsten Jolitz
2013-06-13 8:49 Thorsten Jolitz
2013-06-13 8:56 ` Peter Dyballa
2013-06-13 9:25 ` Eric Abrahamsen
2013-06-13 10:00 ` Peter Dyballa
2013-06-13 10:20 ` Thorsten Jolitz
2013-06-13 10:23 ` Eric Abrahamsen
[not found] ` <mailman.1532.1371117614.22516.help-gnu-emacs@gnu.org>
2013-06-13 13:33 ` Barry Margolin
2013-06-13 18:31 ` Peter Dyballa
[not found] ` <mailman.1597.1371148312.22516.help-gnu-emacs@gnu.org>
2013-06-13 18:51 ` Barry Margolin
2013-06-13 19:41 ` Peter Dyballa
[not found] ` <mailman.1599.1371152513.22516.help-gnu-emacs@gnu.org>
2013-06-13 21:08 ` Barry Margolin
2013-06-13 23:00 ` Peter Dyballa
2013-06-14 8:15 ` Thorsten Jolitz
2013-06-14 8:37 ` Peter Dyballa
2013-06-13 16:16 ` David Engster
2013-06-14 8:20 ` Thorsten Jolitz
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).