Show
Ignore:
Timestamp:
08/18/06 08:35:31 (2 years ago)
Author:
miyoshi
Message:

Sync up with Emacs CVS HEAD.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lisp/textmodes/dns-mode.el

    r4037 r4148  
    9191  :group 'dns-mode) 
    9292 
     93(defcustom dns-mode-soa-auto-increment-serial t 
     94  "Whether to increment the SOA serial number automatically. 
     95 
     96If this variable is t, the serial number is incremented upon each save of 
     97the file.  If it is `ask', Emacs asks for confirmation whether it should 
     98increment the serial upon saving.  If nil, serials must be incremented 
     99manually with \\[dns-mode-soa-increment-serial]." 
     100  :type '(choice (const :tag "Always" t) 
     101                 (const :tag "Ask" ask) 
     102                 (const :tag "Never" nil)) 
     103  :group 'dns-mode) 
     104 
    93105;; Syntax table. 
    94106 
     
    136148    (set (make-local-variable 'font-lock-defaults) 
    137149         '(dns-mode-font-lock-keywords nil nil ((?_ . "w"))))) 
     150  (add-hook 'before-save-hook 'dns-mode-soa-maybe-increment-serial 
     151            nil t) 
    138152  (easy-menu-add dns-mode-menu dns-mode-map)) 
     153 
     154;;;###autoload (defalias 'zone-mode 'dns-mode) 
    139155 
    140156;; Tools. 
     
    193209          (error "Cannot locate serial number in SOA record")))))) 
    194210 
     211(defun dns-mode-soa-maybe-increment-serial () 
     212  "Increment SOA serial if needed. 
     213 
     214This function is run from `before-save-hook'." 
     215  (when (and (buffer-modified-p) 
     216             dns-mode-soa-auto-increment-serial 
     217             (or (eq dns-mode-soa-auto-increment-serial t) 
     218                 (y-or-n-p "Increment SOA serial? "))) 
     219    ;; If `dns-mode-soa-increment-serial' signals an error saving will 
     220    ;; fail but that probably means that the serial should be fixed to 
     221    ;; comply with the RFC anyway! -rfr 
     222    (progn (dns-mode-soa-increment-serial) 
     223           ;; We return nil in case this is used in write-contents-functions. 
     224           nil))) 
     225 
    195226;;;###autoload(add-to-list 'auto-mode-alist '("\\.soa\\'" . dns-mode)) 
    196227