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

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

Re: How to recompile single file or rerun single compilation command in


From: Thien-Thi Nguyen
Subject: Re: How to recompile single file or rerun single compilation command in compilation mode ?
Date: Thu, 08 Mar 2012 09:01:24 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.92 (gnu/linux)

() Nash Steve <nash11228@gmail.com>
() Wed, 7 Mar 2012 10:44:40 -0500

   I want to run a line in compilation-mode buffer as a compile
   command.  e.g. after M-x compile RET make, I just want to pick
   a line of make output as a command to run.

Maybe something like this (only lightly tested)?

(require 'thingatpt)

(defun compilation-compile-with-current-line (dir)
  "Extract the current line as a command and execute it in DIR."
  (interactive "DExecute command in directory: ")
  (let ((command (substring-no-properties (thing-at-point 'line) 0 -1)))
    ;; Do it this way instead of using "cd DIR; COMMAND"
    ;; to avoid outrageous prefixing on repeated invocations.
    (let ((default-directory dir))
      (compile (format "%s" command)))))

(define-key compilation-mode-map "\C-c\C-a" ; "a" for "again"
  'compilation-compile-with-current-line)



reply via email to

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