unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* editing previous command in the *shell* buffer
@ 2015-04-27 23:06 cplum987
  2015-04-28 14:18 ` Doug Lewan
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: cplum987 @ 2015-04-27 23:06 UTC (permalink / raw)
  To: help-gnu-emacs

How can I do one or both of the following:

(1) Find a previous command in the *shell* buffer via search C-s, and have pressing enter insert the command as the current command, but without execution. This would allow me to edit the command before executing it, but not have to modify the command as it previously exists in the *shell* buffer.

(2) type the first part of the command, and have M-p search for the previous occurrence of the command that starts with the same pattern I've typed in. This is an xemacs feature I sorely miss.  C-s just isn't the same. If often finds all sorts of other cruft you have to skip over.
thanks,

thanks,

Chris


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

* RE: editing previous command in the *shell* buffer
  2015-04-27 23:06 editing previous command in the *shell* buffer cplum987
@ 2015-04-28 14:18 ` Doug Lewan
  2015-04-28 17:10 ` HASM
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 10+ messages in thread
From: Doug Lewan @ 2015-04-28 14:18 UTC (permalink / raw)
  To: cplum987@gmail.com, help-gnu-emacs@gnu.org

> -----Original Message-----
> On
> Behalf Of cplum987
> Subject: editing previous command in the *shell* buffer
> 
> How can I do one or both of the following:
> 
> (1) Find a previous command in the *shell* buffer via search C-s, and
> have pressing enter insert the command as the current command, but
> without execution. This would allow me to edit the command before
> executing it, but not have to modify the command as it previously
> exists in the *shell* buffer.

I agree. This is a bit of a hole. I copy and paste and edit all the time.
It doesn't seem like it would be too hard to build, 
but it's probably too little to bother getting permission from my employer
to give away. :(

> 
> (2) type the first part of the command, and have M-p search for the
> previous occurrence of the command that starts with the same pattern
> I've typed in. This is an xemacs feature I sorely miss.  C-s just isn't
> the same. If often finds all sorts of other cruft you have to skip
> over.

This sounds like it would be a good addition. I use M-/ to do such a thing,
but that does get a little tedious.
Does the xemacs lisp port to GNU emacs?

> thanks,
> 
> Chris
[Doug Lewan] 


-- 
,Doug
Douglas Lewan
Shubert Ticketing
(201) 489-8600 ext 224 or ext 4335

The human brain is the most complex thing known to man, according to the human brain.



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

* Re: editing previous command in the *shell* buffer
  2015-04-27 23:06 editing previous command in the *shell* buffer cplum987
  2015-04-28 14:18 ` Doug Lewan
@ 2015-04-28 17:10 ` HASM
  2015-04-28 19:39   ` cplum987
       [not found] ` <mailman.1792.1430230730.904.help-gnu-emacs@gnu.org>
  2015-04-29 11:57 ` Steve Perry
  3 siblings, 1 reply; 10+ messages in thread
From: HASM @ 2015-04-28 17:10 UTC (permalink / raw)
  To: help-gnu-emacs

cplum987@gmail.com writes:

> How can I do one or both of the following:
>
> (1) Find a previous command in the *shell* buffer via search
> C-s, and have pressing enter insert the command as the
> current command, but without execution.

Doesn't M-r work for you?
  M-r runs the command comint-history-isearch-backward-regexp,
-- HASM


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

* Re: editing previous command in the *shell* buffer
       [not found] ` <mailman.1792.1430230730.904.help-gnu-emacs@gnu.org>
@ 2015-04-28 19:23   ` cplum987
  0 siblings, 0 replies; 10+ messages in thread
From: cplum987 @ 2015-04-28 19:23 UTC (permalink / raw)
  To: help-gnu-emacs

On Tuesday, April 28, 2015 at 7:18:52 AM UTC-7, Doug Lewan wrote:
> > -----Original Message-----
> > On
> > Behalf Of cplum987
> > Subject: editing previous command in the *shell* buffer
> > 
> > How can I do one or both of the following:
> > 
> > (1) Find a previous command in the *shell* buffer via search C-s, and
> > have pressing enter insert the command as the current command, but
> > without execution. This would allow me to edit the command before
> > executing it, but not have to modify the command as it previously
> > exists in the *shell* buffer.
> 
> I agree. This is a bit of a hole. I copy and paste and edit all the time.
> It doesn't seem like it would be too hard to build, 
> but it's probably too little to bother getting permission from my employer
> to give away. :(
> 
> > 
> > (2) type the first part of the command, and have M-p search for the
> > previous occurrence of the command that starts with the same pattern
> > I've typed in. This is an xemacs feature I sorely miss.  C-s just isn't
> > the same. If often finds all sorts of other cruft you have to skip
> > over.
> 
> This sounds like it would be a good addition. I use M-/ to do such a thing,
> but that does get a little tedious.
Looks like M-/ iterates through the command history just like M-p, but only includes the root command, not the arguments.

> Does the xemacs lisp port to GNU emacs?
I have no idea. Beyond my abilities for sure.




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

* Re: editing previous command in the *shell* buffer
  2015-04-28 17:10 ` HASM
@ 2015-04-28 19:39   ` cplum987
  2015-04-28 21:29     ` Barry Margolin
                       ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: cplum987 @ 2015-04-28 19:39 UTC (permalink / raw)
  To: help-gnu-emacs

On Tuesday, April 28, 2015 at 10:10:22 AM UTC-7, HASM wrote:
> 
> > How can I do one or both of the following:
> >
> > (1) Find a previous command in the *shell* buffer via search
> > C-s, and have pressing enter insert the command as the
> > current command, but without execution.
> 
> Doesn't M-r work for you?
>   M-r runs the command comint-history-isearch-backward-regexp,
> -- HASM

[BTW, I meant C-r, not C-s. My brain can never recall why my fingers type.]

M-r seems to be a step in the right direction. However, you don't know what command line it will grab until after you press <RET>. As an example, I just tried  "M-r cd<RET>". It found a command with "CD" in the middle of it. I wanted the one that started with "cd".

With xemacs, "cd M-p" would have found the most recent occurrence of a command that started with "cd", and entered it as the current command so I can edit it (it doesn't take you to the location in *shell* of the match like C-r does). No need to press <RET> first and hope it grabs the right one. Also, each time I type M-p after that, it will grab an even older instance of a command that starts with those same chars. So I just type the first few chars of the command, and then type M-p until xemacs finds the one I want.


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

* Re: editing previous command in the *shell* buffer
  2015-04-28 19:39   ` cplum987
@ 2015-04-28 21:29     ` Barry Margolin
  2015-04-29  0:20     ` Robert Thorpe
       [not found]     ` <mailman.1854.1430266854.904.help-gnu-emacs@gnu.org>
  2 siblings, 0 replies; 10+ messages in thread
From: Barry Margolin @ 2015-04-28 21:29 UTC (permalink / raw)
  To: help-gnu-emacs

In article <36243f68-c9ad-4185-af20-215cceecf0b3@googlegroups.com>,
 cplum987@gmail.com wrote:

> On Tuesday, April 28, 2015 at 10:10:22 AM UTC-7, HASM wrote:
> > 
> > > How can I do one or both of the following:
> > >
> > > (1) Find a previous command in the *shell* buffer via search
> > > C-s, and have pressing enter insert the command as the
> > > current command, but without execution.
> > 
> > Doesn't M-r work for you?
> >   M-r runs the command comint-history-isearch-backward-regexp,
> > -- HASM
> 
> [BTW, I meant C-r, not C-s. My brain can never recall why my fingers type.]
> 
> M-r seems to be a step in the right direction. However, you don't know what 
> command line it will grab until after you press <RET>. As an example, I just 
> tried  "M-r cd<RET>". It found a command with "CD" in the middle of it. I 
> wanted the one that started with "cd".

The parameter is a regular expression, so use "^cd" to find a command 
that begins with "cd".

-- 
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***


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

* Re: editing previous command in the *shell* buffer
  2015-04-28 19:39   ` cplum987
  2015-04-28 21:29     ` Barry Margolin
@ 2015-04-29  0:20     ` Robert Thorpe
       [not found]     ` <mailman.1854.1430266854.904.help-gnu-emacs@gnu.org>
  2 siblings, 0 replies; 10+ messages in thread
From: Robert Thorpe @ 2015-04-29  0:20 UTC (permalink / raw)
  To: cplum987; +Cc: help-gnu-emacs

cplum987@gmail.com writes:

> [BTW, I meant C-r, not C-s. My brain can never recall why my fingers type.]
>
> M-r seems to be a step in the right direction. However, you don't know
> what command line it will grab until after you press <RET>. As an
> example, I just tried  "M-r cd<RET>". It found a command with "CD" in
> the middle of it. I wanted the one that started with "cd".

It's a regex as Barry Margolin mentioned, that's one way to narrow
things down.  Another is to search further.  M-r initiates a backwards
regex isearch of history.  When you meet a match C-r will continue the
search back to the next match.  (Typing M-r again switches from regex
search to normal search).

There are quite a few other commands available.  See (info "(emacs)
Shell Ring")

> With xemacs, "cd M-p" would have found the most recent occurrence of a
> command that started with "cd", and entered it as the current command
> so I can edit it (it doesn't take you to the location in *shell* of
> the match like C-r does). No need to press <RET> first and hope it
> grabs the right one. Also, each time I type M-p after that, it will
> grab an even older instance of a command that starts with those same
> chars. So I just type the first few chars of the command, and then
> type M-p until xemacs finds the one I want.

This sounds useful.  There's probably a package on Melpa or Marmalade to
do it.  But I don't know precisely where to start looking.

BR,
Robert Thorpe



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

* Re: editing previous command in the *shell* buffer
       [not found]     ` <mailman.1854.1430266854.904.help-gnu-emacs@gnu.org>
@ 2015-04-29  4:22       ` cplum987
  0 siblings, 0 replies; 10+ messages in thread
From: cplum987 @ 2015-04-29  4:22 UTC (permalink / raw)
  To: help-gnu-emacs

On Tuesday, April 28, 2015 at 5:20:56 PM UTC-7, Robert Thorpe wrote:
> 
> > M-r seems to be a step in the right direction. However, you don't know
> > what command line it will grab until after you press <RET>. As an
> > example, I just tried  "M-r cd<RET>". It found a command with "CD" in
> > the middle of it. I wanted the one that started with "cd".
> 
> It's a regex as Barry Margolin mentioned, that's one way to narrow
> things down.  Another is to search further.  M-r initiates a backwards
> regex isearch of history.  When you meet a match C-r will continue the
> search back to the next match.  (Typing M-r again switches from regex
> search to normal search).

I couldn't get M-r followed by C-r to work as you described. C-r reverts back to searching the previous pattern I searched with C-r, not the pattern I just searched with M-r.

However, I did not know that after doing the first M-r search, I could just repeatedly do "M-r <RET>" to search for previous occurrences. Still a bit awkward compared to just having to do M-p on xemacs, but at least is another step closer.



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

* Re: editing previous command in the *shell* buffer
  2015-04-27 23:06 editing previous command in the *shell* buffer cplum987
                   ` (2 preceding siblings ...)
       [not found] ` <mailman.1792.1430230730.904.help-gnu-emacs@gnu.org>
@ 2015-04-29 11:57 ` Steve Perry
  2015-04-29 20:14   ` cplum987
  3 siblings, 1 reply; 10+ messages in thread
From: Steve Perry @ 2015-04-29 11:57 UTC (permalink / raw)
  To: help-gnu-emacs

cplum987@gmail.com writes:
> How can I do one or both of the following:
>
> ...
>
> (2) type the first part of the command, and have M-p search for the
> previous occurrence of the command that starts with the same pattern
> I've typed in. This is an xemacs feature I sorely miss.  C-s just
> isn't the same. If often finds all sorts of other cruft you have to
> skip over.
> thanks,

I bind M-p and M-n to comint-previous-matching-input-from-input and
comint-next-matching-input-from-input respectively which I think does
what you want...





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

* Re: editing previous command in the *shell* buffer
  2015-04-29 11:57 ` Steve Perry
@ 2015-04-29 20:14   ` cplum987
  0 siblings, 0 replies; 10+ messages in thread
From: cplum987 @ 2015-04-29 20:14 UTC (permalink / raw)
  To: help-gnu-emacs

On Wednesday, April 29, 2015 at 4:57:34 AM UTC-7, Steve Perry wrote:
> > How can I do one or both of the following:
> >
> > ...
> >
> > (2) type the first part of the command, and have M-p search for the
> > previous occurrence of the command that starts with the same pattern
> > I've typed in. This is an xemacs feature I sorely miss.  C-s just
> > isn't the same. If often finds all sorts of other cruft you have to
> > skip over.
> > thanks,
> 
> I bind M-p and M-n to comint-previous-matching-input-from-input and
> comint-next-matching-input-from-input respectively which I think does
> what you want...

That's real close, but after typing the first few characters of the command, I then have to select them in order to get the matching to work. Otherwise it just works as M-p does by default.


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

end of thread, other threads:[~2015-04-29 20:14 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-04-27 23:06 editing previous command in the *shell* buffer cplum987
2015-04-28 14:18 ` Doug Lewan
2015-04-28 17:10 ` HASM
2015-04-28 19:39   ` cplum987
2015-04-28 21:29     ` Barry Margolin
2015-04-29  0:20     ` Robert Thorpe
     [not found]     ` <mailman.1854.1430266854.904.help-gnu-emacs@gnu.org>
2015-04-29  4:22       ` cplum987
     [not found] ` <mailman.1792.1430230730.904.help-gnu-emacs@gnu.org>
2015-04-28 19:23   ` cplum987
2015-04-29 11:57 ` Steve Perry
2015-04-29 20:14   ` cplum987

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