unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#516: [PATCH] Minor Enhancement for grep.el: auto-input the symbol into minibuffer command line.
@ 2008-07-02  3:47 Kazuo YAGI
  2009-12-05  0:38 ` Juri Linkov
  2019-06-27 18:05 ` bug#516: [PATCH] Minor Enhancement for grep.el: auto-input the symbol " Lars Ingebrigtsen
  0 siblings, 2 replies; 7+ messages in thread
From: Kazuo YAGI @ 2008-07-02  3:47 UTC (permalink / raw)
  To: bug-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 445 bytes --]

Hi guys,

I'd like to suggest a minor enhancement for "lisp/progmodes/grep.el".

This patch is to let you input the cursor position symbol automatically
into minibuffer command line. I think it makes us easier to use "grep-find"
function.

Also attached is the images for showing how to work "grep-find" function
before and after this patch.

I confirmed that it is possible to apply this patch both 22.1 and 22.2 version.

Thanks,
- Kazuo YAGI

[-- Attachment #2: grep.el.patch --]
[-- Type: text/x-diff, Size: 484 bytes --]

--- cur/grep.el	2007-04-08 11:08:48.000000000 +0900
+++ my/grep.el	2008-07-02 11:19:47.000000000 +0900
@@ -566,7 +566,7 @@ easily repeat a find command."
      (grep-compute-defaults)
      (if grep-find-command
 	 (list (read-from-minibuffer "Run find (like this): "
-				     grep-find-command nil nil
+				     (concat grep-find-command (thing-at-point 'symbol)) nil nil
                                      'grep-find-history))
        ;; No default was set
        (read-string

[-- Attachment #3: before.png --]
[-- Type: image/png, Size: 15397 bytes --]

[-- Attachment #4: after.png --]
[-- Type: image/png, Size: 15506 bytes --]

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

* bug#516: [PATCH] Minor Enhancement for grep.el: auto-input the symbol into minibuffer command line.
  2008-07-02  3:47 bug#516: [PATCH] Minor Enhancement for grep.el: auto-input the symbol into minibuffer command line Kazuo YAGI
@ 2009-12-05  0:38 ` Juri Linkov
  2009-12-05  4:36   ` bug#516: [PATCH] Minor Enhancement for grep.el: auto-input thesymbol " Drew Adams
  2019-06-27 18:05 ` bug#516: [PATCH] Minor Enhancement for grep.el: auto-input the symbol " Lars Ingebrigtsen
  1 sibling, 1 reply; 7+ messages in thread
From: Juri Linkov @ 2009-12-05  0:38 UTC (permalink / raw)
  To: 516

> This patch is to let you input the cursor position symbol automatically
> into minibuffer command line. I think it makes us easier to use "grep-find"
> function.

There is a function `grep-default-command' in grep.el that does this.
I wonder why it's used in `grep', but not in `grep-find'.  I think
we should do the same in `grep-find'.

-- 
Juri Linkov
http://www.jurta.org/emacs/





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

* bug#516: [PATCH] Minor Enhancement for grep.el: auto-input thesymbol into minibuffer command line.
  2009-12-05  0:38 ` Juri Linkov
@ 2009-12-05  4:36   ` Drew Adams
  2009-12-05 19:51     ` Juri Linkov
  0 siblings, 1 reply; 7+ messages in thread
From: Drew Adams @ 2009-12-05  4:36 UTC (permalink / raw)
  To: 'Juri Linkov', 516

> > This patch is to let you input the cursor position symbol 
> > automatically into minibuffer command line. I think it makes
> > us easier to use "grep-find" function.
> 
> There is a function `grep-default-command' in grep.el that does this.
> I wonder why it's used in `grep', but not in `grep-find'.  I think
> we should do the same in `grep-find'.

Yes, and as I've suggested before, if the region is active, then its contents,
surrounded by "s, should be the default search string. Example code:
http://www.emacswiki.org/emacs/grep%2b.el






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

* bug#516: [PATCH] Minor Enhancement for grep.el: auto-input thesymbol into minibuffer command line.
  2009-12-05  4:36   ` bug#516: [PATCH] Minor Enhancement for grep.el: auto-input thesymbol " Drew Adams
@ 2009-12-05 19:51     ` Juri Linkov
  2009-12-05 20:28       ` Drew Adams
  0 siblings, 1 reply; 7+ messages in thread
From: Juri Linkov @ 2009-12-05 19:51 UTC (permalink / raw)
  To: Drew Adams; +Cc: 516

>> > This patch is to let you input the cursor position symbol
>> > automatically into minibuffer command line. I think it makes
>> > us easier to use "grep-find" function.
>>
>> There is a function `grep-default-command' in grep.el that does this.
>> I wonder why it's used in `grep', but not in `grep-find'.  I think
>> we should do the same in `grep-find'.
>
> Yes, and as I've suggested before, if the region is active,
> then its contents, surrounded by "s, should be the default
> search string. Example code:
> http://www.emacswiki.org/emacs/grep%2b.el

`grep-tag-default' already provides the active region.  But it uses
`shell-quote-argument' instead of surrounding by quotes.  I don't know
what is better, since it's harder to edit the command when
`shell-quote-argument' puts a backslash before every space
and some other characters.

Another drawback of `grep-tag-default' is that it provides only
one alternative.  This is unlike `read-regexp' that proposes
a list of possible default values.  So `grep-tag-default' could be
improved to do the same.

-- 
Juri Linkov
http://www.jurta.org/emacs/





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

* bug#516: [PATCH] Minor Enhancement for grep.el: auto-input thesymbol into minibuffer command line.
  2009-12-05 19:51     ` Juri Linkov
@ 2009-12-05 20:28       ` Drew Adams
  2009-12-06  0:35         ` Juri Linkov
  0 siblings, 1 reply; 7+ messages in thread
From: Drew Adams @ 2009-12-05 20:28 UTC (permalink / raw)
  To: 'Juri Linkov'; +Cc: 516

> >> > This patch is to let you input the cursor position symbol
> >> > automatically into minibuffer command line. I think it makes
> >> > us easier to use "grep-find" function.
> >>
> >> There is a function `grep-default-command' in grep.el that 
> >> does this. I wonder why it's used in `grep', but not in
> >> `grep-find'.  I think we should do the same in `grep-find'.
> >
> > Yes, and as I've suggested before, if the region is active,
> > then its contents, surrounded by "s, should be the default
> > search string. Example code:
> > http://www.emacswiki.org/emacs/grep%2b.el
> 
> `grep-tag-default' already provides the active region. But it uses
> `shell-quote-argument' instead of surrounding by quotes.  I don't know
> what is better, since it's harder to edit the command when
> `shell-quote-argument' puts a backslash before every space
> and some other characters.

Not only that, but:

a. You must use M-n to put it in the minibuffer. Not a big deal, but you must
know about this, to think to do that.

b. A default file-name pattern (e.g. "*.el") is also included, as part of what's
inserted.

All of that (especially the backslashing instead of quoting), makes it harder to
edit the text to match and the file names to match.

> Another drawback of `grep-tag-default' is that it provides only
> one alternative.  This is unlike `read-regexp' that proposes
> a list of possible default values.  So `grep-tag-default' could be
> improved to do the same.

FWIW, the code I use inserts the (quoted) region or the symbol name nearest
point (if no active region), and leaves out a file pattern. (You can still get
the vanilla default using `M-n'.)






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

* bug#516: [PATCH] Minor Enhancement for grep.el: auto-input thesymbol into minibuffer command line.
  2009-12-05 20:28       ` Drew Adams
@ 2009-12-06  0:35         ` Juri Linkov
  0 siblings, 0 replies; 7+ messages in thread
From: Juri Linkov @ 2009-12-06  0:35 UTC (permalink / raw)
  To: Drew Adams; +Cc: 516

>> `grep-tag-default' already provides the active region. But it uses
>> `shell-quote-argument' instead of surrounding by quotes.  I don't know
>> what is better, since it's harder to edit the command when
>> `shell-quote-argument' puts a backslash before every space
>> and some other characters.
>
> Not only that, but:
>
> a. You must use M-n to put it in the minibuffer. Not a big deal, but you must
> know about this, to think to do that.

You can use `C-u grep' instead of `M-n' to put it in the minibuffer as
initial input.  However, `C-u grep' is worse than `M-n' because such use
of C-u is non-standard (unlike `M-n' that is the standard key to put the
default value in the minibuffer).

> b. A default file-name pattern (e.g. "*.el") is also included, as part of what's
> inserted.

That's what rgrep/lgrep do.  They provide a default file-name pattern
depending on the buffer's file name.

> All of that (especially the backslashing instead of quoting), makes it harder to
> edit the text to match and the file names to match.

I don't like backslashing too.

>> Another drawback of `grep-tag-default' is that it provides only
>> one alternative.  This is unlike `read-regexp' that proposes
>> a list of possible default values.  So `grep-tag-default' could be
>> improved to do the same.
>
> FWIW, the code I use inserts the (quoted) region or the symbol name nearest
> point (if no active region), and leaves out a file pattern. (You can still get
> the vanilla default using `M-n'.)

I agree it would be better to provide the active region, and the vanilla
default using `M-n'.

-- 
Juri Linkov
http://www.jurta.org/emacs/





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

* bug#516: [PATCH] Minor Enhancement for grep.el: auto-input the symbol into minibuffer command line.
  2008-07-02  3:47 bug#516: [PATCH] Minor Enhancement for grep.el: auto-input the symbol into minibuffer command line Kazuo YAGI
  2009-12-05  0:38 ` Juri Linkov
@ 2019-06-27 18:05 ` Lars Ingebrigtsen
  1 sibling, 0 replies; 7+ messages in thread
From: Lars Ingebrigtsen @ 2019-06-27 18:05 UTC (permalink / raw)
  To: Kazuo YAGI; +Cc: 516

Kazuo YAGI <kyagi@miraclelinux.com> writes:

> This patch is to let you input the cursor position symbol automatically
> into minibuffer command line. I think it makes us easier to use "grep-find"
> function.

[...]

> +				     (concat grep-find-command (thing-at-point 'symbol)) nil nil

This seems to be counter to how these functions usually work, so I don't
think making such a change would make sense, even if having what's under
point readily accessible.  But I'm closing this bug report.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





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

end of thread, other threads:[~2019-06-27 18:05 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-07-02  3:47 bug#516: [PATCH] Minor Enhancement for grep.el: auto-input the symbol into minibuffer command line Kazuo YAGI
2009-12-05  0:38 ` Juri Linkov
2009-12-05  4:36   ` bug#516: [PATCH] Minor Enhancement for grep.el: auto-input thesymbol " Drew Adams
2009-12-05 19:51     ` Juri Linkov
2009-12-05 20:28       ` Drew Adams
2009-12-06  0:35         ` Juri Linkov
2019-06-27 18:05 ` bug#516: [PATCH] Minor Enhancement for grep.el: auto-input the symbol " Lars Ingebrigtsen

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