Mercurial > emacs
comparison lisp/net/zone-mode.el @ 41944:66a34741f47c
(zone-mode): Don't use make-local-hook.
author | Pavel Janík <Pavel@Janik.cz> |
---|---|
date | Tue, 11 Dec 2001 06:50:22 +0000 |
parents | b174db545cfd |
children | 72899138fdcb |
comparison
equal
deleted
inserted
replaced
41943:6250dd339aac | 41944:66a34741f47c |
---|---|
50 (old-flag (match-string 3)) | 50 (old-flag (match-string 3)) |
51 (cur-date (format-time-string "%Y%m%d")) | 51 (cur-date (format-time-string "%Y%m%d")) |
52 (new-seq | 52 (new-seq |
53 (cond | 53 (cond |
54 ((not (string= old-date cur-date)) | 54 ((not (string= old-date cur-date)) |
55 "00") ;; reset sequeence number | 55 "00") ;; reset sequence number |
56 ((>= old-seq-num 99) | 56 ((>= old-seq-num 99) |
57 (error "Serial number's sequenece cannot increment beyond 99")) | 57 (error "Serial number's sequence cannot increment beyond 99")) |
58 (t | 58 (t |
59 (format "%02d" (1+ old-seq-num))))) | 59 (format "%02d" (1+ old-seq-num))))) |
60 (old-serial (concat old-date old-seq)) | 60 (old-serial (concat old-date old-seq)) |
61 (new-serial (concat cur-date new-seq))) | 61 (new-serial (concat cur-date new-seq))) |
62 (if (string-lessp new-serial old-serial) | 62 (if (string-lessp new-serial old-serial) |
63 (error (format "Serial numbers want to move backwards from %s to %s!" old-serial new-serial)) | 63 (error (format "Serial numbers want to move backwards from %s to %s" old-serial new-serial)) |
64 (replace-match (concat cur-date new-seq old-flag) t t)))))) | 64 (replace-match (concat cur-date new-seq old-flag) t t)))))) |
65 | 65 |
66 ;;;###autoload | 66 ;;;###autoload |
67 (defun zone-mode-update-serial-hook () | 67 (defun zone-mode-update-serial-hook () |
68 "Update the serial number in a zone if the file was modified" | 68 "Update the serial number in a zone if the file was modified." |
69 (interactive) | 69 (interactive) |
70 (if (buffer-modified-p (current-buffer)) | 70 (if (buffer-modified-p (current-buffer)) |
71 (zone-mode-update-serial)) | 71 (zone-mode-update-serial)) |
72 nil ;; so we can run from write-file-hooks | 72 nil ;; so we can run from write-file-hooks |
73 ) | 73 ) |
74 | 74 |
75 (defvar zone-mode-syntax-table nil | 75 (defvar zone-mode-syntax-table nil |
76 "Zone-mode's syntax table.") | 76 "Zone-mode's syntax table.") |
77 | 77 |
78 (defun zone-mode-load-time-setup () | 78 (defun zone-mode-load-time-setup () |
79 "init zone-mode stuff" | 79 "Initialise `zone-mode' stuff." |
80 (setq zone-mode-syntax-table (make-syntax-table)) | 80 (setq zone-mode-syntax-table (make-syntax-table)) |
81 (modify-syntax-entry ?\; "<" zone-mode-syntax-table) | 81 (modify-syntax-entry ?\; "<" zone-mode-syntax-table) |
82 (modify-syntax-entry ?\n ">" zone-mode-syntax-table)) | 82 (modify-syntax-entry ?\n ">" zone-mode-syntax-table)) |
83 | 83 |
84 ;;;###autoload | 84 ;;;###autoload |
90 - automatically update the serial number for a zone | 90 - automatically update the serial number for a zone |
91 when saving the file | 91 when saving the file |
92 | 92 |
93 - fontification" | 93 - fontification" |
94 | 94 |
95 (make-local-hook 'write-file-hooks) | |
96 (add-hook 'write-file-hooks 'zone-mode-update-serial-hook) | 95 (add-hook 'write-file-hooks 'zone-mode-update-serial-hook) |
97 | 96 |
98 (if (null zone-mode-syntax-table) | 97 (if (null zone-mode-syntax-table) |
99 (zone-mode-load-time-setup)) ;; should have been run at load-time | 98 (zone-mode-load-time-setup)) ;; should have been run at load-time |
100 | 99 |