X-Git-Url: http://cgit.sxemacs.org/?p=gnus;a=blobdiff_plain;f=lisp%2Fdns-mode.el;h=bb9fedad206a06e236637ef2053f37cc4fb3605a;hp=e926d8cd0e472a70f8ff2e8b1bfb1c06f952939a;hb=9a8731d6dea8021a10dec1b42f382609336a9aa9;hpb=e2c9efb05a1ae9e65fd40bab80466da331f3981b diff --git a/lisp/dns-mode.el b/lisp/dns-mode.el index e926d8cd0..bb9fedad2 100644 --- a/lisp/dns-mode.el +++ b/lisp/dns-mode.el @@ -1,10 +1,10 @@ ;;; dns-mode.el --- a mode for viewing/editing Domain Name System master files -;; Copyright (C) 2000, 2001, 2004, 2005, 2006, 2007, 2008, 2009 +;; Copyright (C) 2000, 2001, 2004, 2005, 2006, 2007, 2008, 2009, 2010 ;; Free Software Foundation, Inc. ;; Author: Simon Josefsson -;; Keywords: DNS master zone file SOA +;; Keywords: DNS master zone file SOA comm ;; This file is part of GNU Emacs. @@ -49,7 +49,7 @@ (defgroup dns-mode nil "DNS master file mode configuration." - :group 'comm) + :group 'data) (defconst dns-mode-classes '("IN" "CS" "CH" "HS") "List of strings with known DNS classes.") @@ -89,6 +89,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 @@ -134,8 +146,12 @@ Turning on DNS mode runs `dns-mode-hook'." (unless (featurep 'xemacs) (set (make-local-variable 'font-lock-defaults) '(dns-mode-font-lock-keywords nil nil ((?_ . "w"))))) + (add-hook 'before-save-hook '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 @@ -191,7 +207,22 @@ Turning on DNS mode runs `dns-mode-hook'." (message "Replaced old serial %s with %s" serial new)) (error "Cannot locate serial number in SOA record")))))) -;;;###autoload(add-to-list 'auto-mode-alist '("\\.soa\\'" . dns-mode)) +(defun dns-mode-soa-maybe-increment-serial () + "Increment SOA serial if needed. + +This function is run from `before-save-hook'." + (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? "))) + ;; 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) + ;; We return nil in case this is used in write-contents-functions. + nil))) + +;;;###autoload(add-to-list 'auto-mode-alist (purecopy '("\\.soa\\'" . dns-mode))) (provide 'dns-mode)