--- rpm-spec-mode.el~ 2008-04-22 15:14:40.000000000 -0400 +++ rpm-spec-mode.el 2008-04-22 16:19:09.000000000 -0400 @@ -63,7 +63,9 @@ ;;; Code: -(defconst rpm-spec-mode-version "0.12.3x" "Version of `rpm-spec-mode'.") +(require 'compile) + +(defconst rpm-spec-mode-version "0.12.3x.rh1" "Version of `rpm-spec-mode'.") (defgroup rpm-spec nil "RPM spec mode with Emacs/XEmacs enhancements." @@ -189,11 +191,6 @@ :type 'boolean :group 'rpm-spec) -(defcustom rpm-spec-use-compilation-mode t - "*If non-nil, build in `compilation-mode' if it's available." - :type 'boolean - :group 'rpm-spec) - (defcustom rpm-spec-default-release "1" "*Default value for the Release tag in new spec files." :type 'string @@ -225,6 +222,11 @@ :type 'string :group 'rpm-spec) +(defcustom rpm-spec-auto-topdir nil + "*Automatically detect an rpm build directory tree and define _topdir." + :type 'boolean + :group 'rpm-spec) + (defgroup rpm-spec-faces nil "Font lock faces for `rpm-spec-mode'." :prefix "rpm-spec-" @@ -1025,20 +1027,30 @@ (setq buildoptions (cons "--nodeps" buildoptions))) (if (and rpm-spec-sign-gpg (not rpm-no-gpg)) (setq buildoptions (cons "--sign" buildoptions))) - (save-excursion - (set-buffer (get-buffer rpm-buffer-name)) - (and rpm-spec-use-compilation-mode - (fboundp 'compilation-mode) - (compilation-mode)) - (goto-char (point-max))) - (let* ((process-environment (cons "EMACS=t" process-environment)) - (process - (apply 'start-process rpm-spec-build-command rpm-buffer-name - rpm-spec-build-command buildoptions))) - (if (and rpm-spec-sign-gpg (not rpm-no-gpg)) - (let ((rpm-passwd-cache (read-passwd "GPG passphrase: "))) - (process-send-string process (concat rpm-passwd-cache "\n")))) - (set-process-filter process 'rpm-command-filter))) + + (if rpm-spec-auto-topdir + (if (string-match ".*/SPECS/$" default-directory) + (let ((topdir (expand-file-name default-directory))) + (setq buildoptions + (cons + (concat "--define \"_topdir " + (replace-regexp-in-string "/SPECS/$" "" topdir) + "\"") + buildoptions))))) + + (progn + (defun list->string (lst) + (if (cdr lst) + (concat (car lst) " " (list->string (cdr lst))) + (car lst))) + (compilation-start (list->string (cons rpm-spec-build-command buildoptions)) 'rpmbuild-mode)) + + (if (and rpm-spec-sign-gpg (not rpm-no-gpg)) + (let ((build-proc (get-buffer-process + (get-buffer + (compilation-buffer-name "rpmbuild" nil nil)))) + (rpm-passwd-cache (read-passwd "GPG passphrase: "))) + (process-send-string build-proc (concat rpm-passwd-cache "\n"))))) (defun rpm-build-prepare (&optional arg) "Run a `rpmbuild -bp'." @@ -1409,5 +1421,8 @@ ;;;###autoload(add-to-list 'auto-mode-alist '("\\.spec\\(\\.in\\)?$" . rpm-spec-mode)) (provide 'rpm-spec-mode) +;;;###autoload +(define-compilation-mode rpmbuild-mode "RPM build" "" + (set (make-local-variable 'compilation-disable-input) t)) ;;; rpm-spec-mode.el ends here