changeset 49701:77c73732b535

(pages-directory-mode-map): New. (pages-directory-map): Redefine as an varalias. (pages-directory-mode): Use new map var and run mode hook. (pages-directory-address-mode): Use define-derived-mode.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Tue, 11 Feb 2003 00:44:08 +0000
parents 176bfa5ffebf
children 369dbdebd88a
files lisp/textmodes/page-ext.el
diffstat 1 files changed, 13 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/textmodes/page-ext.el	Tue Feb 11 00:37:28 2003 +0000
+++ b/lisp/textmodes/page-ext.el	Tue Feb 11 00:44:08 2003 +0000
@@ -475,16 +475,14 @@
 
 (defvar pages-target-buffer)
 
-(defvar pages-directory-map nil
+(defvar pages-directory-mode-map
+  (let ((map (make-sparse-keymap)))
+    (define-key map "\C-c\C-c" 'pages-directory-goto)
+    (define-key map "\C-c\C-p\C-a" 'add-new-page)
+    (define-key map [mouse-2] 'pages-directory-goto-with-mouse)
+    map)
   "Keymap for the pages-directory-buffer.")
-
-(if pages-directory-map
-    ()
-  (setq pages-directory-map (make-sparse-keymap))
-  (define-key pages-directory-map "\C-c\C-c"
-    'pages-directory-goto)
-  (define-key pages-directory-map "\C-c\C-p\C-a" 'add-new-page)
-  (define-key pages-directory-map [mouse-2] 'pages-directory-goto-with-mouse))
+(defvaralias 'pages-directory-map 'pages-directory-mode-map)
 
 (defvar original-page-delimiter "^\f"
   "Default page delimiter.")
@@ -703,12 +701,13 @@
 to the same line in the pages buffer."
 
   (kill-all-local-variables)
-  (use-local-map pages-directory-map)
+  (use-local-map pages-directory-mode-map)
   (setq major-mode 'pages-directory-mode)
   (setq mode-name "Pages-Directory")
   (make-local-variable 'pages-buffer)
   (make-local-variable 'pages-pos-list)
-  (make-local-variable 'pages-directory-buffer-narrowing-p))
+  (make-local-variable 'pages-directory-buffer-narrowing-p)
+  (run-mode-hooks 'pages-directory-mode-hook))
 
 (defun pages-directory-goto ()
   "Go to the corresponding line in the pages buffer."
@@ -791,22 +790,14 @@
           ))
     (error "No addresses file found!")))
 
-(defun pages-directory-address-mode ()
+(define-derived-mode pages-directory-address-mode pages-directory-mode
+  "Addresses Directory"
   "Mode for handling the Addresses Directory buffer.
 
 Move point to one of the lines in this buffer,
 then use \\[pages-directory-goto] to go
 to the same line in the pages buffer."
+  :syntax-table nil)
 
-  (use-local-map pages-directory-map)
-  (setq major-mode 'pages-directory-address-mode)
-  (setq mode-name "Addresses Directory")
-  (make-local-variable 'pages-buffer)
-  (make-local-variable 'pages-pos-list)
-  (make-local-variable 'pages-directory-buffer-narrowing-p))
-
-
-;;; Place `provide' at end of file.
 (provide 'page-ext)
-
 ;;; page-ext.el ends here