* pushing and popping the mark
@ 2015-05-09 11:18 Sam Halliday
2015-05-09 11:30 ` Sam Halliday
2015-05-09 21:47 ` Emanuel Berg
0 siblings, 2 replies; 13+ messages in thread
From: Sam Halliday @ 2015-05-09 11:18 UTC (permalink / raw)
To: help-gnu-emacs
Hi all,
I have found myself doing some repetitive editing recently that I am sure can be optimised.
Let's say I have a chunk of existing text (in the middle of the buffer), and a bunch of new text (at the bottom of the buffer) with bits of text that I want to selectively kill and then yank into the existing text.
So the workflow looks like this:
1. go to "new text", kill some relevant text
2. go to "existing text", yank
3. repeat
In terms of keys strokes this means:
1. `C-U SPACE` (now near relevant "new text") then unavoidable manual keystrokes to select/kill
2. `C-SPACE C-SPACE`, then `C-U SPACE` (does nothing) to add this location to the mark ring and ignore that mark in the ring.
3. `C-U SPACE` (now near relevant "existing text") then unavoidable manual keystrokes to yank
4. `C-SPACE C-SPACE`, then `C-U SPACE` (does nothing) to add this location to the mark ring
Actually, my fingers can confused and end up just using pageup/down :-/
Obviously, steps 2 and 4 are undesirable. Is there a single command that I can perform to effectively save the current point, then go to the second mark in the mark ring?
Or, equivalently, save the point, visit the head of the mark ring (possibly pop it, I don't need it anymore) and then push the saved point to the head of the mark ring.
(Probably I would have finished my work already instead of writing this email...)
Best regards,
Sam
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: pushing and popping the mark
2015-05-09 11:18 pushing and popping the mark Sam Halliday
@ 2015-05-09 11:30 ` Sam Halliday
2015-05-09 12:49 ` Francis Belliveau
[not found] ` <mailman.2663.1431175800.904.help-gnu-emacs@gnu.org>
2015-05-09 21:47 ` Emanuel Berg
1 sibling, 2 replies; 13+ messages in thread
From: Sam Halliday @ 2015-05-09 11:30 UTC (permalink / raw)
To: help-gnu-emacs
To answer my own question, with an alternative, below:
On Saturday, 9 May 2015 12:18:39 UTC+1, Sam Halliday wrote:
> I have found myself doing some repetitive editing recently that I am sure can be optimised.
>
> Let's say I have a chunk of existing text (in the middle of the buffer), and a bunch of new text (at the bottom of the buffer) with bits of text that I want to selectively kill and then yank into the existing text.
>
> So the workflow looks like this:
>
> 1. go to "new text", kill some relevant text
> 2. go to "existing text", yank
> 3. repeat
>
>
> In terms of keys strokes this means:
>
> 1. `C-U SPACE` (now near relevant "new text") then unavoidable manual keystrokes to select/kill
> 2. `C-SPACE C-SPACE`, then `C-U SPACE` (does nothing) to add this location to the mark ring and ignore that mark in the ring.
> 3. `C-U SPACE` (now near relevant "existing text") then unavoidable manual keystrokes to yank
> 4. `C-SPACE C-SPACE`, then `C-U SPACE` (does nothing) to add this location to the mark ring
>
> Actually, my fingers can confused and end up just using pageup/down :-/
>
> Obviously, steps 2 and 4 are undesirable. Is there a single command that I can perform to effectively save the current point, then go to the second mark in the mark ring?
The workflow can also be optimised by opening a second frame into the same buffer. That helps a lot because `C-x o` then jumps to approximately the locations where I was wanting to set the marks anyway. However, it then requires me to split my screen... which is sometimes not ideal.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: pushing and popping the mark
2015-05-09 11:30 ` Sam Halliday
@ 2015-05-09 12:49 ` Francis Belliveau
[not found] ` <mailman.2663.1431175800.904.help-gnu-emacs@gnu.org>
1 sibling, 0 replies; 13+ messages in thread
From: Francis Belliveau @ 2015-05-09 12:49 UTC (permalink / raw)
To: Sam Halliday; +Cc: help-gnu-emacs
Sam,
First let me say that emacs is so engrained in my finger tips that I find it difficult to decipher keystroke speak. I do not have time to try your keystrokes to get the fill feel of what your are doing.
Although I do not fully follow what you are doing, two things come to mind.
First would C-X C-X (swap point and mark) rather than C-U C-Space (pop mark) to help reduce things a little. It is certainly easier to type.
Second, whenever I have something repetitive like this to do, I usually define a temporary keyboard macro to help out. You just need to be creative about where in the process the macro starts and ends.
I would think something like:
1. Position curser at yank location.
2. C-Space to mark the location
3. Position curser at start of cut location.
4. Mark and select text to be cut.
5. C-X( to start keyboard macro.
6. C-W to cut the text
7. C-X C-X to swap to paste location
8. C-Y to yank the text
9. C-X) to end keyboard macro.
Now you have.
A. Perform the first 4 steps.
B. C-Xe to execute the macro.
As opposed what I see as your 7 steps, this takes 9 steps the first time, then 5 steps for every repeat after that.
Not much of a savings, but with a lot of repeats it does helps and it certainly gets around the finger tangles.
The one that I use a lot is to paste something at the beginning of a line like when turning an enumerated list into a switch statement:
After priming the pump with a "M-W C-E :” I create a macro that looks something like:
C-N C-A C-Y C-E:
Fran
> On May 9, 2015, at 7:30 AM, Sam Halliday <sam.halliday@gmail.com> wrote:
>
> To answer my own question, with an alternative, below:
>
> On Saturday, 9 May 2015 12:18:39 UTC+1, Sam Halliday wrote:
>> I have found myself doing some repetitive editing recently that I am sure can be optimised.
>>
>> Let's say I have a chunk of existing text (in the middle of the buffer), and a bunch of new text (at the bottom of the buffer) with bits of text that I want to selectively kill and then yank into the existing text.
>>
>> So the workflow looks like this:
>>
>> 1. go to "new text", kill some relevant text
>> 2. go to "existing text", yank
>> 3. repeat
>>
>>
>> In terms of keys strokes this means:
>>
>> 1. `C-U SPACE` (now near relevant "new text") then unavoidable manual keystrokes to select/kill
>> 2. `C-SPACE C-SPACE`, then `C-U SPACE` (does nothing) to add this location to the mark ring and ignore that mark in the ring.
>> 3. `C-U SPACE` (now near relevant "existing text") then unavoidable manual keystrokes to yank
>> 4. `C-SPACE C-SPACE`, then `C-U SPACE` (does nothing) to add this location to the mark ring
>>
>> Actually, my fingers can confused and end up just using pageup/down :-/
>>
>> Obviously, steps 2 and 4 are undesirable. Is there a single command that I can perform to effectively save the current point, then go to the second mark in the mark ring?
>
>
> The workflow can also be optimised by opening a second frame into the same buffer. That helps a lot because `C-x o` then jumps to approximately the locations where I was wanting to set the marks anyway. However, it then requires me to split my screen... which is sometimes not ideal.
^ permalink raw reply [flat|nested] 13+ messages in thread
* pushing and popping the mark
@ 2015-05-09 15:03 Jude DaShiell
0 siblings, 0 replies; 13+ messages in thread
From: Jude DaShiell @ 2015-05-09 15:03 UTC (permalink / raw)
To: help-gnu-emacs
If I had that problem I'd handle the work flow differently.
1) break the document into sequentially numbered files,
2) examine each numbered file and change file name to different number if
necessary and if number I wanted to use was already used, I'd probably add
100 to the number the new file name got as a temporary measure. Once all
files had correct numbers on them,
3) use cat and send the output to the original document destructively.
Maye an emacs extension can handle this but if so I don't know which.
-- Twitter: JudeDaShiell
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: pushing and popping the mark
[not found] ` <mailman.2663.1431175800.904.help-gnu-emacs@gnu.org>
@ 2015-05-09 21:08 ` Sam Halliday
2015-05-09 21:15 ` Drew Adams
[not found] ` <mailman.2680.1431206116.904.help-gnu-emacs@gnu.org>
0 siblings, 2 replies; 13+ messages in thread
From: Sam Halliday @ 2015-05-09 21:08 UTC (permalink / raw)
To: help-gnu-emacs
On Saturday, 9 May 2015 13:50:01 UTC+1, Francis Belliveau wrote:
...
> First would C-X C-X (swap point and mark) rather than C-U C-Space (pop mark) to help reduce things a little. It is certainly easier to type.
Fantastic! I didn't know about this command (although I think I've hit it by accident in the past and it confused the hell out of me). It allows me to completely rethink the workflow.
Thanks :-)
Sam
^ permalink raw reply [flat|nested] 13+ messages in thread
* RE: pushing and popping the mark
2015-05-09 21:08 ` Sam Halliday
@ 2015-05-09 21:15 ` Drew Adams
[not found] ` <mailman.2680.1431206116.904.help-gnu-emacs@gnu.org>
1 sibling, 0 replies; 13+ messages in thread
From: Drew Adams @ 2015-05-09 21:15 UTC (permalink / raw)
To: Sam Halliday, help-gnu-emacs
> > C-x C-x
>
> Fantastic! I didn't know about this command (although I think I've
> hit it by accident in the past and it confused the hell out of me).
> It allows me to completely rethink the workflow.
If `C-x C-x' isn't in the Emacs tutorial, it certainly should be.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: pushing and popping the mark
2015-05-09 11:18 pushing and popping the mark Sam Halliday
2015-05-09 11:30 ` Sam Halliday
@ 2015-05-09 21:47 ` Emanuel Berg
2015-05-09 22:11 ` Sam Halliday
1 sibling, 1 reply; 13+ messages in thread
From: Emanuel Berg @ 2015-05-09 21:47 UTC (permalink / raw)
To: help-gnu-emacs
Sam Halliday <sam.halliday@gmail.com> writes:
> 1. go to "new text", kill some relevant text 2.
> go to "existing text", yank 3. repeat
The best way to do this is to move (once), kill
everything, move again (once), and yank everything.
So use the kill *ring*.
When you yank, if it isn't what you like, do
(immediately after the yank) `M-y' for `yank-pop'.
You might also like:
(defun yank-pop-back (&optional arg)
(interactive "*p")
(yank-pop (if arg (* arg -1) -1)) )
If you rely on it, bind it to some equally close and
fast key.
--
underground experts united
http://user.it.uu.se/~embe8573
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: pushing and popping the mark
[not found] ` <mailman.2680.1431206116.904.help-gnu-emacs@gnu.org>
@ 2015-05-09 22:04 ` Sam Halliday
0 siblings, 0 replies; 13+ messages in thread
From: Sam Halliday @ 2015-05-09 22:04 UTC (permalink / raw)
To: help-gnu-emacs
On Saturday, 9 May 2015 22:15:18 UTC+1, Drew Adams wrote:
> > > C-x C-x
> >
> > Fantastic! I didn't know about this command (although I think I've
> > hit it by accident in the past and it confused the hell out of me).
> > It allows me to completely rethink the workflow.
>
> If `C-x C-x' isn't in the Emacs tutorial, it certainly should be.
I'm sure it is, but every reading only has a certain "sponge factor" of things that are retained :-)
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: pushing and popping the mark
2015-05-09 21:47 ` Emanuel Berg
@ 2015-05-09 22:11 ` Sam Halliday
2015-05-09 22:34 ` Emanuel Berg
` (3 more replies)
0 siblings, 4 replies; 13+ messages in thread
From: Sam Halliday @ 2015-05-09 22:11 UTC (permalink / raw)
To: help-gnu-emacs
On Saturday, 9 May 2015 22:42:21 UTC+1, Emanuel Berg wrote:
> Sam Halliday <sam.halliday@gmail.com> writes:
>
> > 1. go to "new text", kill some relevant text 2.
> > go to "existing text", yank 3. repeat
>
> The best way to do this is to move (once), kill
> everything, move again (once), and yank everything.
>
> So use the kill *ring*.
>
> When you yank, if it isn't what you like, do
> (immediately after the yank) `M-y' for `yank-pop'.
I know this is called `yank-pop`, but it is more of a "peek" because it keeps the kill ring intact.
More generally though, this is a neat solution. I hadn't thought to do it this way. The only problem with it is that it necessitates doing everything in exact order and not making any mistakes along the way. Therefore, I'll prefer `C-x C-x` when there are more than a few things needing moved around, but prefer this in simple cases.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: pushing and popping the mark
2015-05-09 22:11 ` Sam Halliday
@ 2015-05-09 22:34 ` Emanuel Berg
2015-05-10 0:02 ` Drew Adams
` (2 subsequent siblings)
3 siblings, 0 replies; 13+ messages in thread
From: Emanuel Berg @ 2015-05-09 22:34 UTC (permalink / raw)
To: help-gnu-emacs
Sam Halliday <sam.halliday@gmail.com> writes:
>> So use the kill *ring*.
>>
>> When you yank, if it isn't what you like, do
>> (immediately after the yank) `M-y' for `yank-pop'.
>
> I know this is called `yank-pop`, but it is more of
> a "peek" because it keeps the kill ring intact.
>
> More generally though, this is a neat solution.
> I hadn't thought to do it this way. The only problem
> with it is that it necessitates doing everything in
> exact order and not making any mistakes along
> the way.
Try yanking and then do `M-y' *several times* - and if
you skip the insert you'd like by mistake do the Elisp
I provided (bind it to for example `C-M-y'), which can
likewise be repeated.
I'd say the second best solution is to split the
window. Or sometimes that would be the best solution -
it depends. Jumping back and forth in the same buffer
is the worst solution by far (so far).
Think of this as something physical. Someone chops
wood and then puts it in the stove. No one would cut
one piece of firewood, carry it all the way back, put
it in, then return all the way for another piece, and
so on.
--
underground experts united
http://user.it.uu.se/~embe8573
^ permalink raw reply [flat|nested] 13+ messages in thread
* RE: pushing and popping the mark
2015-05-09 22:11 ` Sam Halliday
2015-05-09 22:34 ` Emanuel Berg
@ 2015-05-10 0:02 ` Drew Adams
[not found] ` <mailman.2683.1431216187.904.help-gnu-emacs@gnu.org>
2015-05-10 13:41 ` Jude DaShiell
3 siblings, 0 replies; 13+ messages in thread
From: Drew Adams @ 2015-05-10 0:02 UTC (permalink / raw)
To: Sam Halliday, help-gnu-emacs
> > `M-y' for `yank-pop'.
>
> I know this is called `yank-pop`, but it is more of a "peek"
> because it keeps the kill ring intact.
>
> More generally though, this is a neat solution. I hadn't thought to
> do it this way. The only problem with it is that it necessitates
> doing everything in exact order and not making any mistakes along
> the way. Therefore, I'll prefer `C-x C-x` when there are more than a
> few things needing moved around, but prefer this in simple cases.
There are plenty of ways to more directly access given entries on
the kill-ring. `browse-kill-ring[+].el' provides one. Icicles
provides another, and I'm sure that other general completion
packages do too now.
Quite often, when vanilla Emacs provides only a way to cycle, to
get to some candidate, some package such as Icicles gives you a
way to get to it more directly.
Whether it is navigating among function-definition tag matches
or among index matches in Info, the vanilla Emacs approach is
often to have you repeatedly hit a key (e.g. `M-,') to get to
successive candidates, but completion packages let you
pattern-match against all candidates (and cycle among the
matches, if you like).
Even vanilla Emacs sometimes gives you more direct ways, in
addition to mechanically cycling. To get to a previous
minibuffer (history) entry, for example, you need not cycle to
it using `M-p' over and over. You can sometimes reach it more
directly by matching, using `M-r'. Or even better, using `C-r'
(in the minibuffer - see (emacs) `Isearch Minibuffer'). I'm
not saying that these vanilla matching means are wonderful,
but they sometimes exist and are underused.
Sometimes cycling is handier than matching; sometimes the
reverse - depending on how long the candidate list is and
whether partial matching shortens the list to be cycled.
Icicles and other packages that combine matching with cycling
usually let you get where you are going pretty directly.
Compared to using `yank-pop', for example, being able to get
to any marked locations anywhere, by matching, or by a
combination of matching and cycling, sure beats just cycling.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: pushing and popping the mark
[not found] ` <mailman.2683.1431216187.904.help-gnu-emacs@gnu.org>
@ 2015-05-10 1:59 ` Emanuel Berg
0 siblings, 0 replies; 13+ messages in thread
From: Emanuel Berg @ 2015-05-10 1:59 UTC (permalink / raw)
To: help-gnu-emacs
Drew Adams <drew.adams@oracle.com> writes:
> Quite often, when vanilla Emacs provides only a way
> to cycle ... but completion packages let you
> pattern-match ...
Even tho I was the one suggesting `yank-pop' and
"yank-pop-back" (as I have it implemented) I don't
like cycling and I absolutely don't like
pattern-matching or autocompletion. (Now we speak
pattern-matching as a form of "advanced cycling" or
browsing of a command history - I *do* like
`replace-regexp' and that branch of the business for
editing purposes.)
OK, I don't get into the OPs situation often, so when
I do splitting the window is good enough. But if it
*did* happen to me often let me describe how I would
want it and maybe someone can say if this is already
in a package.
First I'd go to the "source buffer" or buffer part.
Then I'd kill everything with `M-w' (which is
`kill-ring-save').
Then I'd go to the "destination buffer" or
buffer part.
Last, I'd bring up a situation which this dump [1]
illustrates. So there would be no cycling or matching
or TAB completion - I would just hit the command to
invoke the mode (and bring up the pane) and then hit
the letter to insert that exact entry.
Notice it uses (it would use) normal letters for
insert unlike the ispell way which uses 1-9 and only
then letters. The reason is the same old: those chars
are much closer to typing position than the digits and
are thus much faster and safer to hit and much more
integrated in the "typeflow" than those digits which
are like the pelicans of the zoo rather than
city doves.
[1] http://user.it.uu.se/~embe8573/dumps/kill-ring.png
--
underground experts united
http://user.it.uu.se/~embe8573
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: pushing and popping the mark
2015-05-09 22:11 ` Sam Halliday
` (2 preceding siblings ...)
[not found] ` <mailman.2683.1431216187.904.help-gnu-emacs@gnu.org>
@ 2015-05-10 13:41 ` Jude DaShiell
3 siblings, 0 replies; 13+ messages in thread
From: Jude DaShiell @ 2015-05-10 13:41 UTC (permalink / raw)
To: Sam Halliday; +Cc: help-gnu-emacs
That's why you can write macros in emacs, for when precision and exact
order of operations is essential.
-- Twitter: JudeDaShiell
On Sat, 9 May 2015, Sam Halliday wrote:
> On Saturday, 9 May 2015 22:42:21 UTC+1, Emanuel Berg wrote:
>> Sam Halliday <sam.halliday@gmail.com> writes:
>>
>>> 1. go to "new text", kill some relevant text 2.
>>> go to "existing text", yank 3. repeat
>>
>> The best way to do this is to move (once), kill
>> everything, move again (once), and yank everything.
>>
>> So use the kill *ring*.
>>
>> When you yank, if it isn't what you like, do
>> (immediately after the yank) `M-y' for `yank-pop'.
>
> I know this is called `yank-pop`, but it is more of a "peek" because it keeps the kill ring intact.
>
> More generally though, this is a neat solution. I hadn't thought to do it this way. The only problem with it is that it necessitates doing everything in exact order and not making any mistakes along the way. Therefore, I'll prefer `C-x C-x` when there are more than a few things needing moved around, but prefer this in simple cases.
>
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2015-05-10 13:41 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-09 11:18 pushing and popping the mark Sam Halliday
2015-05-09 11:30 ` Sam Halliday
2015-05-09 12:49 ` Francis Belliveau
[not found] ` <mailman.2663.1431175800.904.help-gnu-emacs@gnu.org>
2015-05-09 21:08 ` Sam Halliday
2015-05-09 21:15 ` Drew Adams
[not found] ` <mailman.2680.1431206116.904.help-gnu-emacs@gnu.org>
2015-05-09 22:04 ` Sam Halliday
2015-05-09 21:47 ` Emanuel Berg
2015-05-09 22:11 ` Sam Halliday
2015-05-09 22:34 ` Emanuel Berg
2015-05-10 0:02 ` Drew Adams
[not found] ` <mailman.2683.1431216187.904.help-gnu-emacs@gnu.org>
2015-05-10 1:59 ` Emanuel Berg
2015-05-10 13:41 ` Jude DaShiell
-- strict thread matches above, loose matches on Subject: below --
2015-05-09 15:03 Jude DaShiell
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).