unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* bash and reverse-search-history
@ 2006-04-21 12:43 Baurzhan Ismagulov
  2006-04-21 15:13 ` Peter Dyballa
  0 siblings, 1 reply; 15+ messages in thread
From: Baurzhan Ismagulov @ 2006-04-21 12:43 UTC (permalink / raw)


Hello all,

I'm using bash inside emacs and want to use the reverse-search-history
of bash, bound to C-r. Unfortunately, C-r is interpreted by emacs and
doesn't apparently reach bash. How can I use this function of bash from
within emacs?

Thanks in advance,
Baurzhan.

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

* Re: bash and reverse-search-history
  2006-04-21 12:43 Baurzhan Ismagulov
@ 2006-04-21 15:13 ` Peter Dyballa
  2006-04-21 15:43   ` Baurzhan Ismagulov
  0 siblings, 1 reply; 15+ messages in thread
From: Peter Dyballa @ 2006-04-21 15:13 UTC (permalink / raw)
  Cc: help-gnu-emacs


Am 21.04.2006 um 14:43 schrieb Baurzhan Ismagulov:

> I'm using bash inside emacs and want to use the reverse-search-history
> of bash, bound to C-r. Unfortunately, C-r is interpreted by emacs and
> doesn't apparently reach bash. How can I use this function of bash  
> from
> within emacs?

I don't know. By escaping? What is so bad about Emacs' own shell  
history?

--
Greetings

   Pete

Mac OS X is like a wigwam: no fences, no gates, but an apache inside.

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

* Re: bash and reverse-search-history
  2006-04-21 15:13 ` Peter Dyballa
@ 2006-04-21 15:43   ` Baurzhan Ismagulov
  2006-04-21 16:45     ` Drew Adams
  2006-04-21 22:02     ` Kevin Rodgers
  0 siblings, 2 replies; 15+ messages in thread
From: Baurzhan Ismagulov @ 2006-04-21 15:43 UTC (permalink / raw)


Hello Peter,

On Fri, Apr 21, 2006 at 05:13:55PM +0200, Peter Dyballa wrote:
> >I'm using bash inside emacs and want to use the reverse-search-history
> >of bash, bound to C-r. Unfortunately, C-r is interpreted by emacs and
> >doesn't apparently reach bash. How can I use this function of bash  
> >from
> >within emacs?
> 
> I don't know. By escaping? What is so bad about Emacs' own shell  
> history?

Do you mean M-r? Two reasons:

1. It's not as convenient for me as the bash's one shows what it found
   as I type, and with emacs' one I have to modify regexp on the next
   run.

2. I couldn't find a way to search the whole bash history. When I type
   some expression that I know is in ~/.bash_history, emacs says "Not
   found".

With kind regards,
Baurzhan.

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

* RE: bash and reverse-search-history
  2006-04-21 15:43   ` Baurzhan Ismagulov
@ 2006-04-21 16:45     ` Drew Adams
  2006-04-22 19:24       ` Baurzhan Ismagulov
  2006-04-21 22:02     ` Kevin Rodgers
  1 sibling, 1 reply; 15+ messages in thread
From: Drew Adams @ 2006-04-21 16:45 UTC (permalink / raw)


    > >I'm using bash inside emacs and want to use the
    reverse-search-history
    > >of bash, bound to C-r. Unfortunately, C-r is interpreted by emacs and
    > >doesn't apparently reach bash. How can I use this function of bash
    > >from
    > >within emacs?
    >
    > I don't know. By escaping? What is so bad about Emacs' own shell
    > history?

    Do you mean M-r? Two reasons:

    1. It's not as convenient for me as the bash's one shows what it found
       as I type, and with emacs' one I have to modify regexp on the next
       run.

    2. I couldn't find a way to search the whole bash history. When I type
       some expression that I know is in ~/.bash_history, emacs says "Not
       found".

I don't know if this helps you or not, but you might take a look. Icicles (a
library for GNU Emacs) lets you search the entire history (your #2),
updating matches as you type (your #1). I don't know what you mean by "have
to modify regexp on the next run".

Anyway, take a look:
http://www.emacswiki.org/cgi-bin/wiki/Icicles_-_History_Enhancements. That
discussion is in the middle of the Icicles doc, so if it's not immediately
obvious how it could apply to your question you might read some of the
introductory material. The doc entry point is here:
http://www.emacswiki.org/cgi-bin/wiki/Icicles.

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

* Re: bash and reverse-search-history
  2006-04-21 15:43   ` Baurzhan Ismagulov
  2006-04-21 16:45     ` Drew Adams
@ 2006-04-21 22:02     ` Kevin Rodgers
  2006-04-22 12:24       ` Baurzhan Ismagulov
  1 sibling, 1 reply; 15+ messages in thread
From: Kevin Rodgers @ 2006-04-21 22:02 UTC (permalink / raw)


Baurzhan Ismagulov wrote:
 > 2. I couldn't find a way to search the whole bash history. When I type
 >    some expression that I know is in ~/.bash_history, emacs says "Not
 >    found".

Does `C-h v comint-input-ring-file-name' in the *shell* buffer agree
with "~/.bash_history"?

-- 
Kevin Rodgers
Sr. Software Engineer, IHS

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

* Re: bash and reverse-search-history
       [not found] <mailman.700.1145623405.9609.help-gnu-emacs@gnu.org>
@ 2006-04-22  9:18 ` Gary Wessle
  2006-04-22 12:21   ` Baurzhan Ismagulov
  0 siblings, 1 reply; 15+ messages in thread
From: Gary Wessle @ 2006-04-22  9:18 UTC (permalink / raw)


Baurzhan Ismagulov <ibr@radix50.net> writes:

> Hello all,
> 
> I'm using bash inside emacs and want to use the reverse-search-history
> of bash, bound to C-r. Unfortunately, C-r is interpreted by emacs and
> doesn't apparently reach bash. How can I use this function of bash from
> within emacs?
> 
> Thanks in advance,
> Baurzhan.

Ctl up-arrow works for me.

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

* Re: bash and reverse-search-history
  2006-04-22  9:18 ` bash and reverse-search-history Gary Wessle
@ 2006-04-22 12:21   ` Baurzhan Ismagulov
  0 siblings, 0 replies; 15+ messages in thread
From: Baurzhan Ismagulov @ 2006-04-22 12:21 UTC (permalink / raw)


Hello Gary,

On Sat, Apr 22, 2006 at 07:18:15PM +1000, Gary Wessle wrote:
> > I'm using bash inside emacs and want to use the reverse-search-history
> > of bash, bound to C-r. Unfortunately, C-r is interpreted by emacs and
> > doesn't apparently reach bash. How can I use this function of bash from
> > within emacs?
> 
> Ctl up-arrow works for me.

So does M-p for me, but that isn't incremental history search.

With kind regards,
Baurzhan.

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

* Re: bash and reverse-search-history
  2006-04-21 22:02     ` Kevin Rodgers
@ 2006-04-22 12:24       ` Baurzhan Ismagulov
  0 siblings, 0 replies; 15+ messages in thread
From: Baurzhan Ismagulov @ 2006-04-22 12:24 UTC (permalink / raw)


Hello Kevin,

On Fri, Apr 21, 2006 at 04:02:08PM -0600, Kevin Rodgers wrote:
> > 2. I couldn't find a way to search the whole bash history. When I type
> >    some expression that I know is in ~/.bash_history, emacs says "Not
> >    found".
> 
> Does `C-h v comint-input-ring-file-name' in the *shell* buffer agree
> with "~/.bash_history"?

The command produces the following output:

comint-input-ring-file-name's value is "~/.bash_history"
Local in buffer *shell*; global value is nil

Documentation:
*If non-nil, name of the file to read/write input history.
See also `comint-read-input-ring' and `comint-write-input-ring'.

This variable is buffer-local, and is a good thing to set in mode hooks.

You can customize this variable.

Defined in `comint'.


I'm not sure what you mean by "agree". I'm able to scroll through
.bash_history via M-p, but M-r finds only expressions that I typed
during the current session.


With kind regards,
Baurzhan.

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

* Re: bash and reverse-search-history
  2006-04-21 16:45     ` Drew Adams
@ 2006-04-22 19:24       ` Baurzhan Ismagulov
  2006-04-22 20:27         ` Drew Adams
  2006-04-22 21:29         ` Peter Dyballa
  0 siblings, 2 replies; 15+ messages in thread
From: Baurzhan Ismagulov @ 2006-04-22 19:24 UTC (permalink / raw)


Hello Drew,

On Fri, Apr 21, 2006 at 09:45:09AM -0700, Drew Adams wrote:
> I don't know if this helps you or not, but you might take a look. Icicles (a
> library for GNU Emacs) lets you search the entire history (your #2),
> updating matches as you type (your #1).

This looks interesting. I wanted to try it, however I couldn't find out
how to invoke it. I downloaded the *.el files mentioned, put them into
~/.elisp/load, and added the following lines to my ~/.emacs:

(add-to-list 'load-path (expand-file-name "~/.elisp/load"))
(load-library "icicles.el")

I start emacs, M-x shell RET, and get the shell prompt. I've read some
of the wiki pages, but it isn't clear for me how I can use Icicles. The
page about history doesn't mention shell at all, only minibuffer
completions. Any idea?


> I don't know what you mean by "have to modify regexp on the next run".

In bash, you can press C-r, and type, e.g., "dpkg". As you type each
character, bash shows the most recent command that matches the
expression you've typed up to that moment.

In emacs, I press M-r, it asks for a regexp, I type "dpkg". Nothing is
updated as I type, emacs waits for me to press RET to start searching. I
press RET, it finds the last dpkg command, which happens to be the 29th.
I see it isn't what I was looking for, and want to repeat the search. I
have to press M-r dpkg RET again (this is the "next run" I'd mentioned
in the first posting; "modifying" it is about the case you are not
satisfied with your initial regexp and want to enter a more specific one
instead of the one you typed at first). Or, I can press M-r M-r RET RET,
and emacs will search again. But only 32 commands back?!

So, what I'm looking for is more or less exactly bash's C-r
functionality. Can I perhaps just unbind emacs's C-r for shell buffers,
so that the character is passed to bash?


With kind regards,
Baurzhan.

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

* RE: bash and reverse-search-history
  2006-04-22 19:24       ` Baurzhan Ismagulov
@ 2006-04-22 20:27         ` Drew Adams
  2006-04-22 21:05           ` Baurzhan Ismagulov
  2006-04-22 21:29         ` Peter Dyballa
  1 sibling, 1 reply; 15+ messages in thread
From: Drew Adams @ 2006-04-22 20:27 UTC (permalink / raw)


Hello Baurzhan,

    > Icicles lets you search the entire history (your #2),
    > updating matches as you type (your #1).

    This looks interesting. I wanted to try it, however I couldn't find out
    how to invoke it. I downloaded the *.el files mentioned, put them into
    ~/.elisp/load, and added the following lines to my ~/.emacs:

    (add-to-list 'load-path (expand-file-name "~/.elisp/load"))
    (load-library "icicles.el")

After you load Icicles you are automatically in Icicle mode, unless
`define-minor-mode' is not defined in your version of Emacs, in which case
you can put this in your .emacs (it doesn't hurt to do this anyway): (when
(fboundp 'icicle-mode) (icicle-mode 99)). Whenever you are in Icicle mode,
you will see "Icy" in the mode line minor-mode list. Command `icicle-mode'
enters and exits the mode.

In Icicle mode, minibuffer completion is enhanced in several ways, including
matching minibuffer history items, with incremental update of the list of
possible completions.

    I start emacs, M-x shell RET, and get the shell prompt. I've read some
    of the wiki pages, but it isn't clear for me how I can use Icicles. The
    page about history doesn't mention shell at all, only minibuffer
    completions. Any idea?

I haven't used the Emacs shell in years. I guess I was thinking that you
were inputting stuff through the minibuffer - sorry to have misled you.
Icicles works with any minibuffer input, but I imagine that you won't get
many Icicles features out of the box with comint (shell command line)
completion, which does not use the minibuffer.

I did enhance dabbrev completion (which, like comint completion, does not
use the minibuffer) to be able to take advantage of some Icicles features,
but I haven't yet done that for comint (shell) completion.

Trying shell command completion just now, I notice that about the only thing
you get for free is Icicles candidate cycling, which isn't all that helpful
here. Comint completion apparently does its own matching, so it can't
automatically take advantage of Icicles completion features like regexp
matching. And there is no way to use the Icicles minibuffer history
enhancements with the (non-minibuffer) shell history. With some Emacs-Lisp
programming, you could probably cobble together some of the Icicles
functions to get yourself something workable, but I'm sorry that I don't
have time to work on this.

So I guess the short answer is that you won't get what you want with
Icicles, until I get around to tweaking comint completion so that it can use
Icicles features. Sorry for the false route.

    In bash, you can press C-r, and type, e.g., "dpkg". As you type each
    character, bash shows the most recent command that matches the
    expression you've typed up to that moment.

    In emacs, I press M-r, it asks for a regexp, I type "dpkg". Nothing is
    updated as I type, emacs waits for me to press RET to start searching. I
    press RET, it finds the last dpkg command, which happens to be the 29th.
    I see it isn't what I was looking for, and want to repeat the search. I
    have to press M-r dpkg RET again (this is the "next run" I'd mentioned
    in the first posting; "modifying" it is about the case you are not
    satisfied with your initial regexp and want to enter a more specific one
    instead of the one you typed at first). Or, I can press M-r M-r RET RET,
    and emacs will search again. But only 32 commands back?!

    So, what I'm looking for is more or less exactly bash's C-r
    functionality. Can I perhaps just unbind emacs's C-r for shell buffers,
    so that the character is passed to bash?

The incremental completion update you describe is available in Icicles
(which is why I replied to you) for both standard prefix matching and regexp
matching, but only for minibuffer completion. Sorry.

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

* Re: bash and reverse-search-history
  2006-04-22 20:27         ` Drew Adams
@ 2006-04-22 21:05           ` Baurzhan Ismagulov
  0 siblings, 0 replies; 15+ messages in thread
From: Baurzhan Ismagulov @ 2006-04-22 21:05 UTC (permalink / raw)


Hello Drew,

On Sat, Apr 22, 2006 at 01:27:26PM -0700, Drew Adams wrote:
> The incremental completion update you describe is available in Icicles
> (which is why I replied to you) for both standard prefix matching and regexp
> matching, but only for minibuffer completion. Sorry.

No problem, I learned something new about emacs and tried a library that
may be useful for me in the future. I appreciate your input!


However, the question remains: I'm sure there is a way to unbind emacs's
C-r for shell buffers only, so that the character is passed to bash. How
can I do that?


With kind regards,
Baurzhan.

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

* Re: bash and reverse-search-history
  2006-04-22 19:24       ` Baurzhan Ismagulov
  2006-04-22 20:27         ` Drew Adams
@ 2006-04-22 21:29         ` Peter Dyballa
  2006-04-22 21:53           ` Baurzhan Ismagulov
  1 sibling, 1 reply; 15+ messages in thread
From: Peter Dyballa @ 2006-04-22 21:29 UTC (permalink / raw)
  Cc: help-gnu-emacs


Am 22.04.2006 um 21:24 schrieb Baurzhan Ismagulov:

> I have to press M-r dpkg RET again

Try repeat-complex-command: C-x ESC ESC, C-x M-:, C-x M-ESC. It is  
bound to <again>, <redo>.

(I am using tcsh. GNU Emacs searches its history.)

--
Greetings

   Pete

Genius may have its limitations, but stupidity is not thus handicapped.
-- Elbert Hubbard

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

* Re: bash and reverse-search-history
  2006-04-22 21:29         ` Peter Dyballa
@ 2006-04-22 21:53           ` Baurzhan Ismagulov
  2006-04-22 22:21             ` Peter Dyballa
  0 siblings, 1 reply; 15+ messages in thread
From: Baurzhan Ismagulov @ 2006-04-22 21:53 UTC (permalink / raw)


Hello Peter,

On Sat, Apr 22, 2006 at 11:29:38PM +0200, Peter Dyballa wrote:
> Try repeat-complex-command: C-x ESC ESC, C-x M-:, C-x M-ESC. It is  
> bound to <again>, <redo>.

Thanks for the tip! I used to record macros for such things.

W.r.t. history searching, I personally find this not that convenient
compared to bash's C-r (and no advantage over M-r M-r RET RET, in terms
of keystrokes required :) ).


> (I am using tcsh. GNU Emacs searches its history.)

How do you search beyond 32 commands back?


With kind regards,
Baurzhan.

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

* Re: bash and reverse-search-history
  2006-04-22 21:53           ` Baurzhan Ismagulov
@ 2006-04-22 22:21             ` Peter Dyballa
  2006-04-23  7:00               ` Baurzhan Ismagulov
  0 siblings, 1 reply; 15+ messages in thread
From: Peter Dyballa @ 2006-04-22 22:21 UTC (permalink / raw)
  Cc: help-gnu-emacs


Am 22.04.2006 um 23:53 schrieb Baurzhan Ismagulov:

> How do you search beyond 32 commands back?

!<command>  -- I use tcsh because Emacs fails here! Or I search in  
tcsh's history and repeat what was found there.

--
Greetings

   Pete

"One person with a belief is a social power equal to ninety-nine who  
have only interests." - John Stuart Mill

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

* Re: bash and reverse-search-history
  2006-04-22 22:21             ` Peter Dyballa
@ 2006-04-23  7:00               ` Baurzhan Ismagulov
  0 siblings, 0 replies; 15+ messages in thread
From: Baurzhan Ismagulov @ 2006-04-23  7:00 UTC (permalink / raw)


Hello Peter,

On Sun, Apr 23, 2006 at 12:21:55AM +0200, Peter Dyballa wrote:
> >How do you search beyond 32 commands back?
> 
> !<command>  -- I use tcsh because Emacs fails here! Or I search in  
> tcsh's history and repeat what was found there.

I see, screen is my friend :) .

With kind regards,
Baurzhan.

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

end of thread, other threads:[~2006-04-23  7:00 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <mailman.700.1145623405.9609.help-gnu-emacs@gnu.org>
2006-04-22  9:18 ` bash and reverse-search-history Gary Wessle
2006-04-22 12:21   ` Baurzhan Ismagulov
2006-04-21 12:43 Baurzhan Ismagulov
2006-04-21 15:13 ` Peter Dyballa
2006-04-21 15:43   ` Baurzhan Ismagulov
2006-04-21 16:45     ` Drew Adams
2006-04-22 19:24       ` Baurzhan Ismagulov
2006-04-22 20:27         ` Drew Adams
2006-04-22 21:05           ` Baurzhan Ismagulov
2006-04-22 21:29         ` Peter Dyballa
2006-04-22 21:53           ` Baurzhan Ismagulov
2006-04-22 22:21             ` Peter Dyballa
2006-04-23  7:00               ` Baurzhan Ismagulov
2006-04-21 22:02     ` Kevin Rodgers
2006-04-22 12:24       ` Baurzhan Ismagulov

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