comparison lisp/progmodes/grep.el @ 57908:a4ed247d476f

(grep-default-command): Take empty string for tag if all other methods yield nil. Shell-quote the tag.
author Thien-Thi Nguyen <ttn@gnuvola.org>
date Wed, 03 Nov 2004 11:43:36 +0000
parents e663f6b659a6
children 9acfc0fb9410 e24e2e78deda
comparison
equal deleted inserted replaced
57907:436b42c65828 57908:a4ed247d476f
434 (search-forward "--color" nil t)) 434 (search-forward "--color" nil t))
435 t))))) 435 t)))))
436 436
437 (defun grep-default-command () 437 (defun grep-default-command ()
438 (let ((tag-default 438 (let ((tag-default
439 (funcall (or find-tag-default-function 439 (shell-quote-argument
440 (get major-mode 'find-tag-default-function) 440 (or (funcall (or find-tag-default-function
441 'find-tag-default))) 441 (get major-mode 'find-tag-default-function)
442 'find-tag-default))
443 "")))
442 (sh-arg-re "\\(\\(?:\"\\(?:[^\"]\\|\\\\\"\\)+\"\\|'[^']+'\\|[^\"' \t\n]\\)+\\)") 444 (sh-arg-re "\\(\\(?:\"\\(?:[^\"]\\|\\\\\"\\)+\"\\|'[^']+'\\|[^\"' \t\n]\\)+\\)")
443 (grep-default (or (car grep-history) grep-command))) 445 (grep-default (or (car grep-history) grep-command)))
444 ;; Replace the thing matching for with that around cursor. 446 ;; Replace the thing matching for with that around cursor.
445 (when (or (string-match 447 (when (or (string-match
446 (concat "[^ ]+\\s +\\(?:-[^ ]+\\s +\\)*" 448 (concat "[^ ]+\\s +\\(?:-[^ ]+\\s +\\)*"
458 (file-name-nondirectory buffer-file-name))))) 460 (file-name-nondirectory buffer-file-name)))))
459 (setq grep-default (concat (substring grep-default 461 (setq grep-default (concat (substring grep-default
460 0 (match-beginning 2)) 462 0 (match-beginning 2))
461 " *." 463 " *."
462 (file-name-extension buffer-file-name)))) 464 (file-name-extension buffer-file-name))))
463 (replace-match (or tag-default "") t t grep-default 1)))) 465 (replace-match tag-default t t grep-default 1))))
464 466
465 ;;;###autoload 467 ;;;###autoload
466 (defun grep (command-args &optional highlight-regexp) 468 (defun grep (command-args &optional highlight-regexp)
467 "Run grep, with user-specified args, and collect output in a buffer. 469 "Run grep, with user-specified args, and collect output in a buffer.
468 While grep runs asynchronously, you can use \\[next-error] (M-x next-error), 470 While grep runs asynchronously, you can use \\[next-error] (M-x next-error),