emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] Changes to emacs/lisp/textmodes/dns-mode.el,v


From: Romain Francoise
Subject: [Emacs-diffs] Changes to emacs/lisp/textmodes/dns-mode.el,v
Date: Thu, 10 Aug 2006 20:06:20 +0000

CVSROOT:        /cvsroot/emacs
Module name:    emacs
Changes by:     Romain Francoise <rfrancoise>   06/08/10 20:06:19

Index: textmodes/dns-mode.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/textmodes/dns-mode.el,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- textmodes/dns-mode.el       6 Feb 2006 12:12:26 -0000       1.5
+++ textmodes/dns-mode.el       10 Aug 2006 20:06:18 -0000      1.6
@@ -90,6 +90,18 @@
   :type 'sexp
   :group 'dns-mode)
 
+(defcustom dns-mode-soa-auto-increment-serial t
+  "Whether to increment the SOA serial number automatically.
+
+If this variable is t, the serial number is incremented upon each save of
+the file.  If it is `ask', Emacs asks for confirmation whether it should
+increment the serial upon saving.  If nil, serials must be incremented
+manually with \\[dns-mode-soa-increment-serial]."
+  :type '(choice (const :tag "Always" t)
+                (const :tag "Ask" ask)
+                (const :tag "Never" nil))
+  :group 'dns-mode)
+
 ;; Syntax table.
 
 (defvar dns-mode-syntax-table
@@ -135,8 +147,12 @@
   (unless (featurep 'xemacs)
     (set (make-local-variable 'font-lock-defaults)
         '(dns-mode-font-lock-keywords nil nil ((?_ . "w")))))
+  (add-hook 'write-contents-functions 'dns-mode-soa-maybe-increment-serial
+           nil t)
   (easy-menu-add dns-mode-menu dns-mode-map))
 
+;;;###autoload (defalias 'zone-mode 'dns-mode)
+
 ;; Tools.
 
 ;;;###autoload
@@ -192,6 +208,19 @@
              (message "Replaced old serial %s with %s" serial new))
          (error "Cannot locate serial number in SOA record"))))))
 
+(defun dns-mode-soa-maybe-increment-serial ()
+  "Increment SOA serial if needed.
+
+This function is run from `write-contents-functions'."
+  (when (and (buffer-modified-p)
+            dns-mode-soa-auto-increment-serial
+            (or (eq dns-mode-soa-auto-increment-serial t)
+                (y-or-n-p "Increment SOA serial? ")))
+    ;; We must return nil.  If `dns-mode-soa-increment-serial' signals
+    ;; an error saving will fail but that probably means that the
+    ;; serial should be fixed to comply with the RFC anyway! -rfr
+    (progn (dns-mode-soa-increment-serial) nil)))
+
 ;;;###autoload(add-to-list 'auto-mode-alist '("\\.soa\\'" . dns-mode))
 
 (provide 'dns-mode)




reply via email to

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