aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/textmodes
diff options
context:
space:
mode:
authorRomain Francoise2006-08-10 20:06:19 +0000
committerRomain Francoise2006-08-10 20:06:19 +0000
commitc40408fbe7d325d81ebe784f9565edb39ca23d9f (patch)
treee8e9e6b19eef6dcb9a80597a1eee419c3a4ef8c7 /lisp/textmodes
parent43901444a44d09f2fab59a1127e2659426dcd53e (diff)
downloademacs-c40408fbe7d325d81ebe784f9565edb39ca23d9f.tar.gz
emacs-c40408fbe7d325d81ebe784f9565edb39ca23d9f.zip
* textmodes/dns-mode.el: Alias `zone-mode' to `dns-mode'.
(dns-mode-soa-auto-increment-serial): New user option. (dns-mode-soa-maybe-increment-serial): New function. (dns-mode): Add the latter to `write-contents-functions'. * obsolete/zone-mode.el: Move to obsolete/ from net/. Delete autoload cookies.
Diffstat (limited to 'lisp/textmodes')
-rw-r--r--lisp/textmodes/dns-mode.el29
1 files changed, 29 insertions, 0 deletions
diff --git a/lisp/textmodes/dns-mode.el b/lisp/textmodes/dns-mode.el
index a323d4c4468..78be0f888a3 100644
--- a/lisp/textmodes/dns-mode.el
+++ b/lisp/textmodes/dns-mode.el
@@ -90,6 +90,18 @@
90 :type 'sexp 90 :type 'sexp
91 :group 'dns-mode) 91 :group 'dns-mode)
92 92
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
93;; Syntax table. 105;; Syntax table.
94 106
95(defvar dns-mode-syntax-table 107(defvar dns-mode-syntax-table
@@ -135,8 +147,12 @@ Turning on DNS mode runs `dns-mode-hook'."
135 (unless (featurep 'xemacs) 147 (unless (featurep 'xemacs)
136 (set (make-local-variable 'font-lock-defaults) 148 (set (make-local-variable 'font-lock-defaults)
137 '(dns-mode-font-lock-keywords nil nil ((?_ . "w"))))) 149 '(dns-mode-font-lock-keywords nil nil ((?_ . "w")))))
150 (add-hook 'write-contents-functions 'dns-mode-soa-maybe-increment-serial
151 nil t)
138 (easy-menu-add dns-mode-menu dns-mode-map)) 152 (easy-menu-add dns-mode-menu dns-mode-map))
139 153
154;;;###autoload (defalias 'zone-mode 'dns-mode)
155
140;; Tools. 156;; Tools.
141 157
142;;;###autoload 158;;;###autoload
@@ -192,6 +208,19 @@ Turning on DNS mode runs `dns-mode-hook'."
192 (message "Replaced old serial %s with %s" serial new)) 208 (message "Replaced old serial %s with %s" serial new))
193 (error "Cannot locate serial number in SOA record")))))) 209 (error "Cannot locate serial number in SOA record"))))))
194 210
211(defun dns-mode-soa-maybe-increment-serial ()
212 "Increment SOA serial if needed.
213
214This function is run from `write-contents-functions'."
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 ;; We must return nil. If `dns-mode-soa-increment-serial' signals
220 ;; an error saving will fail but that probably means that the
221 ;; serial should be fixed to comply with the RFC anyway! -rfr
222 (progn (dns-mode-soa-increment-serial) nil)))
223
195;;;###autoload(add-to-list 'auto-mode-alist '("\\.soa\\'" . dns-mode)) 224;;;###autoload(add-to-list 'auto-mode-alist '("\\.soa\\'" . dns-mode))
196 225
197(provide 'dns-mode) 226(provide 'dns-mode)