diff options
| author | Kim F. Storm | 2006-07-28 23:03:18 +0000 |
|---|---|---|
| committer | Kim F. Storm | 2006-07-28 23:03:18 +0000 |
| commit | 7cb0d0ef5aa4369c88e1234e6ddc0cc5d45bd0aa (patch) | |
| tree | c0fb5a3396b257f753f787831918383985e5f40a | |
| parent | 5a6116642e6d614a53ee84c9acf61672759c00b1 (diff) | |
| download | emacs-7cb0d0ef5aa4369c88e1234e6ddc0cc5d45bd0aa.tar.gz emacs-7cb0d0ef5aa4369c88e1234e6ddc0cc5d45bd0aa.zip | |
(grep-tag-default): New function.
(grep-default-command, grep-read-regexp): Use it.
| -rw-r--r-- | lisp/progmodes/grep.el | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/lisp/progmodes/grep.el b/lisp/progmodes/grep.el index e7d85910a63..96f449c2b05 100644 --- a/lisp/progmodes/grep.el +++ b/lisp/progmodes/grep.el | |||
| @@ -455,13 +455,17 @@ Set up `compilation-exit-message-function' and run `grep-setup-hook'." | |||
| 455 | (search-forward "--color" nil t)) | 455 | (search-forward "--color" nil t)) |
| 456 | t))))) | 456 | t))))) |
| 457 | 457 | ||
| 458 | (defun grep-tag-default () | ||
| 459 | (or (and transient-mark-mode mark-active | ||
| 460 | (/= (point) (mark)) | ||
| 461 | (buffer-substring-no-properties (point) (mark))) | ||
| 462 | (funcall (or find-tag-default-function | ||
| 463 | (get major-mode 'find-tag-default-function) | ||
| 464 | 'find-tag-default)) | ||
| 465 | "")) | ||
| 466 | |||
| 458 | (defun grep-default-command () | 467 | (defun grep-default-command () |
| 459 | (let ((tag-default | 468 | (let ((tag-default (shell-quote-argument (grep-tag-default))) |
| 460 | (shell-quote-argument | ||
| 461 | (or (funcall (or find-tag-default-function | ||
| 462 | (get major-mode 'find-tag-default-function) | ||
| 463 | 'find-tag-default)) | ||
| 464 | ""))) | ||
| 465 | (sh-arg-re "\\(\\(?:\"\\(?:[^\"]\\|\\\\\"\\)+\"\\|'[^']+'\\|[^\"' \t\n]\\)+\\)") | 469 | (sh-arg-re "\\(\\(?:\"\\(?:[^\"]\\|\\\\\"\\)+\"\\|'[^']+'\\|[^\"' \t\n]\\)+\\)") |
| 466 | (grep-default (or (car grep-history) grep-command))) | 470 | (grep-default (or (car grep-history) grep-command))) |
| 467 | ;; Replace the thing matching for with that around cursor. | 471 | ;; Replace the thing matching for with that around cursor. |
| @@ -590,15 +594,11 @@ substitution string. Note dynamic scoping of variables.") | |||
| 590 | 594 | ||
| 591 | (defun grep-read-regexp () | 595 | (defun grep-read-regexp () |
| 592 | "Read regexp arg for interactive grep." | 596 | "Read regexp arg for interactive grep." |
| 593 | (let ((default | 597 | (let ((default (grep-tag-default))) |
| 594 | (or (funcall (or find-tag-default-function | ||
| 595 | (get major-mode 'find-tag-default-function) | ||
| 596 | 'find-tag-default)) | ||
| 597 | ""))) | ||
| 598 | (read-string | 598 | (read-string |
| 599 | (concat "Search for" | 599 | (concat "Search for" |
| 600 | (if (and default (> (length default) 0)) | 600 | (if (and default (> (length default) 0)) |
| 601 | (format " (default %s): " default) ": ")) | 601 | (format " (default \"%s\"): " default) ": ")) |
| 602 | nil 'grep-regexp-history default))) | 602 | nil 'grep-regexp-history default))) |
| 603 | 603 | ||
| 604 | (defun grep-read-files (regexp) | 604 | (defun grep-read-files (regexp) |