unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* A smarter command history
@ 2014-01-25 16:53 Tom
  2014-01-25 21:55 ` Stefan Monnier
  0 siblings, 1 reply; 5+ messages in thread
From: Tom @ 2014-01-25 16:53 UTC (permalink / raw)
  To: emacs-devel

After doing grep the command history contains this entry:

  (grep "grep -n -i test")

This is useful to repeat a previous grep command later, but 
you have to switch to the directory first if you want to 
run grep in the same directory as previously.

What if the code which updates command history had a hook
which the command could use to fix the history entry if
it loses some useful attribute of executing the command

For example, in grep's case the command history would look
like this after the fix:

  (let ((default-directory "/home/me/projx")) (grep "grep -n -i test"))

So the user could easily run grep again in the same directory.

grep-find is the same case and there must be similar cases
where simply storing the lisp function call in the history is
not enough, because the function arguments do not cover
all attributes of the command's execution.

Adding a hook to make it possible for the commands to add
the necessary info to the history entry would solve this problem.





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

* Re: A smarter command history
  2014-01-25 16:53 A smarter command history Tom
@ 2014-01-25 21:55 ` Stefan Monnier
  2014-01-26 16:53   ` Tom
  0 siblings, 1 reply; 5+ messages in thread
From: Stefan Monnier @ 2014-01-25 21:55 UTC (permalink / raw)
  To: Tom; +Cc: emacs-devel

> For example, in grep's case the command history would look
> like this after the fix:
>   (let ((default-directory "/home/me/projx")) (grep "grep -n -i test"))

That could also be problematic if the user wants to run the same grep in
various directory.

But, for various other reasons, we do need to provide a way for an
interactive spec to indicate the precise form of the command recorded in
the command history.  We currently have some hacks, for example to try
and recognize when two arguments correspond to the region boundaries and
replace the corresponding numbers with (point) and (mark), but those are
brittle and need to be replaced by something more reliable and flexible.


        Stefan



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

* Re: A smarter command history
  2014-01-25 21:55 ` Stefan Monnier
@ 2014-01-26 16:53   ` Tom
  2014-01-26 18:53     ` Drew Adams
  0 siblings, 1 reply; 5+ messages in thread
From: Tom @ 2014-01-26 16:53 UTC (permalink / raw)
  To: emacs-devel

Stefan Monnier <monnier <at> iro.umontreal.ca> writes:

> 
> > For example, in grep's case the command history would look
> > like this after the fix:
> >   (let ((default-directory "/home/me/projx")) (grep "grep -n -i test"))
> 
> That could also be problematic if the user wants to run the same grep in
> various directory.
> 

Deleting things is easy and in my experience in most of the cases I
want to run the same grep query in the same directory. 




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

* RE: A smarter command history
  2014-01-26 16:53   ` Tom
@ 2014-01-26 18:53     ` Drew Adams
  2014-01-26 19:13       ` Tom
  0 siblings, 1 reply; 5+ messages in thread
From: Drew Adams @ 2014-01-26 18:53 UTC (permalink / raw)
  To: Tom, emacs-devel

> > > For example, in grep's case the command history would look
> > > like this after the fix:
> > >   (let ((default-directory "/home/me/projx"))
> > >     (grep "grep -n -i test"))
> >
> > That could also be problematic if the user wants to run the same
> > grep in various directory.
> 
> Deleting things is easy and in my experience in most of the
> cases I want to run the same grep query in the same directory.

Sounds like a reason _not_ to implement what you asked for:
YAGNI, if you typically run the same grep query in the same dir.

Your reason for the request was that it is a nuisance to change
directory:

>> This is useful to repeat a previous grep command later,
>> but you have to switch to the directory first if you want
>> to run grep in the same directory as previously.

FWIW, I'd suggest that Emacs command `cd' provide a reasonable
minibuffer history list: the directory names previously entered
from the minibuffer.  That is not the case currently - all
entered file and directory names are in the history.

(To change to a subdir, `cd' completion is quick.)



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

* Re: A smarter command history
  2014-01-26 18:53     ` Drew Adams
@ 2014-01-26 19:13       ` Tom
  0 siblings, 0 replies; 5+ messages in thread
From: Tom @ 2014-01-26 19:13 UTC (permalink / raw)
  To: emacs-devel

Drew Adams <drew.adams <at> oracle.com> writes:

> 
> Sounds like a reason _not_ to implement what you asked for:
> YAGNI, if you typically run the same grep query in the same dir.
> 

Yes, in the same directory where I ran that grep was previously.
I do a grep, check something, then do other things, then later
I want to check that grep result again (when the grep buffer
may already be gone and I'm in a different directory).

> Your reason for the request was that it is a nuisance to change
> directory:


Yes, because it's two operations then:

First, I change to that directory (usually by visiting a file
in that directory or visiting the directory). Then I retrieve
the previous grep command with C-x ESC ESC.

My point is that the directory where grep was run belongs
to the context of that operation (grep implicitly uses the
default directory when run), so if we store this operation
in the history then that important context info should be
stored as well.

This way rerunning the previous grep is simply a matter of
C-x ESC ESC. There is no need to visit a file in that 
directory first. So it's one operation instead of two.

And if I want to run that specific grep in an other directory
(not usual) then it's easy to delete the 
(let ((default-directory ...  part from the history item.




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

end of thread, other threads:[~2014-01-26 19:13 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-25 16:53 A smarter command history Tom
2014-01-25 21:55 ` Stefan Monnier
2014-01-26 16:53   ` Tom
2014-01-26 18:53     ` Drew Adams
2014-01-26 19:13       ` Tom

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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