Commits

Anonymous committed 18629fa

Improve rpm-spec-mode customization, auto-mode-alist <1056798438.11345.277.camel@bobcat.ods.org>.

  • Participants
  • Parent commits 3c82c45

Comments (0)

Files changed (2)

+2003-06-27  Damien Nade  <anvil@livna.org>
+
+	* rpm-spec-mode.el: New customization options.
+	(rpm-spec-default-release): New.
+	(rpm-spec-default-epoch): New.
+	(rpm-spec-default-build-section): New.
+	(rpm-spec-default-install-section): New.
+	(rpm-spec-default-clean-section): New.
+	(rpm-spec-default-buildroot): New.
+	(rpm-spec-mode-new-file-hook): New.
+
+2003-06-27  Ville Skyttä  <scop@xemacs.org>
+
+	* rpm-spec-mode.el (rpm-spec-font-lock-keywords):
+	Allow underscores in tags (eg. for Summary(en_US)).
+	(auto-mode-alist): Use rpm-spec-mode for *.spec.in too.
+
 2003-06-20  Norbert Koch  <viteno@xemacs.org>
 
 	* Makefile (VERSION): XEmacs package 1.79 released.
   :group 'rpm-spec)
 
 (defcustom rpm-spec-buildroot ""
-  "Override the BuildRoot tag with directory <dir>."
+  "When building, override the BuildRoot tag with directory <dir>."
   :type 'string
   :group 'rpm-spec)
 
   :type 'boolean
   :group 'rpm-spec)
 
+(defcustom rpm-spec-default-release "1"
+  "*Default value for the Release tag in new spec files."
+  :type 'string
+  :group 'rpm-spec)
+
+(defcustom rpm-spec-default-epoch nil
+  "*If non-nil, default value for the Epoch tag in new spec files."
+  :type '(choice (const :tag "No Epoch" nil) integer)
+  :group 'rpm-spec)
+
+(defcustom rpm-spec-default-buildroot
+  "%{_tmppath}/%{name}-%{version}-%{release}-root"
+  "*Default value for the BuildRoot tag in new spec files."
+  :type 'integer
+  :group 'rpm-spec)
+
+(defcustom rpm-spec-default-build-section ""
+  "*Default %build section in new spec files."
+  :type 'string
+  :group 'rpm-spec)
+
+(defcustom rpm-spec-default-install-section "rm -rf $RPM_BUILD_ROOT\n"
+  "*Default %install section in new spec files."
+  :type 'string
+  :group 'rpm-spec)
+
+(defcustom rpm-spec-default-clean-section "rm -rf $RPM_BUILD_ROOT\n"
+  "*Default %clean section in new spec files."
+  :type 'string
+  :group 'rpm-spec)
+
 (defgroup rpm-spec-faces nil
   "Font lock faces for `rpm-spec-mode'."
   :group 'rpm-spec
 (defvar rpm-spec-font-lock-keywords
   '(
     ("%[a-zA-Z0-9_]+" 0 rpm-spec-macro-face)
-    ("^\\([a-zA-Z0-9]+\\)\\(\([a-zA-Z0-9,]+\)\\):"
+    ("^\\([a-zA-Z0-9]+\\)\\(\([a-zA-Z0-9,_]+\)\\):"
      (1 rpm-spec-tag-face)
      (2 rpm-spec-ghost-face))
     ("^\\([a-zA-Z0-9]+\\):" 1 rpm-spec-tag-face)
 
 ;;------------------------------------------------------------
 
+(add-hook 'rpm-spec-mode-new-file-hook 'rpm-spec-initialize)
+
 ;;;###autoload
 (defun rpm-spec-mode ()
   "Major mode for editing RPM spec files.
   (easy-menu-add rpm-spec-mode-menu)
 
   (if (and (= (buffer-size) 0) rpm-spec-initialize-sections)
-      (rpm-spec-initialize))
+      (run-hooks 'rpm-spec-mode-new-file-hook))
 
   (if (not (executable-find "rpmbuild"))
       (progn
 
 (defun rpm-spec-initialize ()
   "Create a default spec file if one does not exist or is empty."
-  (let (file name version (release "1"))
+  (let (file name version (release rpm-spec-default-release))
     (setq file (if (buffer-file-name)
                    (file-name-nondirectory (buffer-file-name))
                  (buffer-name)))
 	 "\nName:           " (or name "")
 	 "\nVersion:        " (or version "")
 	 "\nRelease:        " (or release "")
+	 (if rpm-spec-default-epoch
+	     (concat "\nEpoch:          " rpm-spec-default-epoch)
+	   "")
 	 "\nLicense:        "
 	 "\nGroup:          "
 	 "\nURL:            "
 	 "\nSource0:        %{name}-%{version}.tar.gz"
-	 "\nBuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-buildroot")
+	 "\nBuildRoot:      " rpm-spec-default-buildroot)
       (insert
        "Summary: "
        "\nName: " (or name "")
        "\nVersion: " (or version "")
        "\nRelease: " (or release "")
+       (if rpm-spec-default-epoch
+	   (concat "\nEpoch: " rpm-spec-default-epoch)
+	 "")
        "\nLicense: "
        "\nGroup: "
        "\nURL: "
        "\nSource0: %{name}-%{version}.tar.gz"
-       "\nBuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot"))
-       
+       "\nBuildRoot: " rpm-spec-default-buildroot))
+
     (insert
      "\n\n%description\n"
      "\n%prep"
      "\n%setup -q"
-     "\n\n%build"
-     "\n\n%install"
-     "\nrm -rf $RPM_BUILD_ROOT"
-     "\n\n%clean"
-     "\nrm -rf $RPM_BUILD_ROOT"
+     "\n\n%build\n"
+     (or rpm-spec-default-build-section "")
+     "\n%install\n"
+     (or rpm-spec-default-install-section "")
+     "\n%clean\n"
+     (or rpm-spec-default-clean-section "")
      "\n\n%files"
      "\n%defattr(-,root,root,-)"
      "\n%doc\n"
            rpm-spec-mode-version
            " by Stig Bjřrlykke, <stigb@tihlde.org>")))
 
-;;;###autoload(add-to-list 'auto-mode-alist '("\\.spec$" . rpm-spec-mode))
+;;;###autoload(add-to-list 'auto-mode-alist '("\\.spec\\(\\.in\\)?$" . rpm-spec-mode))
 
 (provide 'rpm-spec-mode)