help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Modifying default grep prompt (cursor movement, etc)


From: address@hidden
Subject: Modifying default grep prompt (cursor movement, etc)
Date: 8 May 2007 02:15:42 -0700
User-agent: G2/1.0

I usually grep with *, so I'd like to insert a * at the end of the
grep prompt and move the cursor to the end of te default search string
provided from the current context by grep.

I came up with the solution below, but it's not very nice checking the
current minibuffer contents to see if we're in the grep command.

Advising the grep command didn't work, because the prompt is handled
by interactive which seemingly runs before advise kicks in.

Is there a better way way to do this?



(add-hook 'minibuffer-setup-hook 'my-grep-hook)

(defun my-grep-hook ()
  (when (eq (string-match "^grep" (minibuffer-contents)) 0)
    (insert "*")
    (setq unread-command-events (cons 'left
                                      (cons 'left
                                            (cons 'left unread-command-
events))))))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]