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

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

Re: M-x grep prompt: fill in the * for us


From: Kevin Rodgers
Subject: Re: M-x grep prompt: fill in the * for us
Date: Thu, 19 Jun 2003 11:44:38 -0600
User-agent: Mozilla/5.0 (X11; U; SunOS i86pc; en-US; rv:0.9.4.1) Gecko/20020406 Netscape6/6.2.2

Dan Jacobson wrote:

J> And that's what C-u M-x grep already does.

Hmmm, like nifteaux (nifto (nifty)).  OK, I wish C-u M-x compile would
notice current target the cursor is in in a makefile and use that as
the default argument for make.

Ask and ye shall receive...


--
<a href="mailto:&lt;kevin.rodgers&#64;ihs.com&gt;";>Kevin Rodgers</a>
*** /usr/local/emacs-21.3/lisp/progmodes/compile.el     Fri Jan 17 06:45:11 2003
--- /usr/tmp/kevinr/compile.el  Thu Jun 19 11:35:33 2003
***************
*** 571,577 ****
  and move to the source code that caused it.
  
  Interactively, prompts for the command if `compilation-read-command' is
! non-nil; otherwise uses `compile-command'.  With prefix arg, always prompts.
  
  To run more than one compilation at once, start one and rename the
  \`*compilation*' buffer to some other name with \\[rename-buffer].
--- 571,578 ----
  and move to the source code that caused it.
  
  Interactively, prompts for the command if `compilation-read-command' is
! non-nil; otherwise uses `compile-command'.  With prefix arg, append the
! default target to `compile-command'.
  
  To run more than one compilation at once, start one and rename the
  \`*compilation*' buffer to some other name with \\[rename-buffer].
***************
*** 581,596 ****
  the function in `compilation-buffer-name-function', so you can set that
  to a function that generates a unique name."
    (interactive
!    (if (or compilation-read-command current-prefix-arg)
         (list (read-from-minibuffer "Compile command: "
!                                  (eval compile-command) nil nil
!                                  '(compile-history . 1)))
!      (list (eval compile-command))))
    (unless (equal command (eval compile-command))
      (setq compile-command command))
    (save-some-buffers (not compilation-ask-about-save) nil)
    (compile-internal command "No more errors"))
  
  ;; run compile with the default command line
  (defun recompile ()
    "Re-compile the program including the current buffer."
--- 582,614 ----
  the function in `compilation-buffer-name-function', so you can set that
  to a function that generates a unique name."
    (interactive
!    (if compilation-read-command
         (list (read-from-minibuffer "Compile command: "
!                                  (eval compile-command) nil nil
!                                  '(compile-history . 1)))
!      (if current-prefix-arg
!          (list (concat (eval compile-command)
!                        " "
!                        (or compile-default-target "")))
!        (list (eval compile-command)))))
    (unless (equal command (eval compile-command))
      (setq compile-command command))
    (save-some-buffers (not compilation-ask-about-save) nil)
    (compile-internal command "No more errors"))
  
+ (defun compile-default-target ()
+   "Return the default target for `compile'."
+   (cond ((eq major-mode 'makefile-mode)
+        (save-excursion
+          (if (re-search-backward makefile-dependency-regex nil t)
+              (match-string 1))))
+       (buffer-file-name               ; generate an executable name:
+        (file-name-sans-extension (file-name-nondirectory buffer-file-name)))
+       (t                              ; see grep:
+        (funcall (or find-tag-default-function
+                     (get major-mode 'find-tag-default-function)
+                     'grep-tag-default)))))
+ 
  ;; run compile with the default command line
  (defun recompile ()
    "Re-compile the program including the current buffer."

reply via email to

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