=== modified file 'lisp/arc-mode.el' --- lisp/arc-mode.el 2010-07-10 18:52:53 +0000 +++ lisp/arc-mode.el 2010-09-13 00:49:20 +0000 @@ -341,7 +341,6 @@ (defvar archive-mode-map (let ((map (make-keymap))) (suppress-keymap map) - (define-key map " " 'archive-next-line) (define-key map "a" 'archive-alternate-display) ;;(define-key map "c" 'archive-copy) (define-key map "d" 'archive-flag-deleted) @@ -349,15 +348,12 @@ (define-key map "e" 'archive-extract) (define-key map "f" 'archive-extract) (define-key map "\C-m" 'archive-extract) - (define-key map "g" 'revert-buffer) - (define-key map "h" 'describe-mode) (define-key map "m" 'archive-mark) (define-key map "n" 'archive-next-line) (define-key map "\C-n" 'archive-next-line) (define-key map [down] 'archive-next-line) (define-key map "o" 'archive-extract-other-window) (define-key map "p" 'archive-previous-line) - (define-key map "q" 'quit-window) (define-key map "\C-p" 'archive-previous-line) (define-key map [up] 'archive-previous-line) (define-key map "r" 'archive-rename-entry) @@ -632,31 +628,16 @@ (error "Entry is not a regular member of the archive")))) (if (not noerror) (error "Line does not describe a member of the archive"))))) -;; ------------------------------------------------------------------------- -;;; Section: the mode definition - -;;;###autoload -(defun archive-mode (&optional force) - "Major mode for viewing an archive file in a dired-like way. -You can move around using the usual cursor motion commands. -Letters no longer insert themselves. -Type `e' to pull a file out of the archive and into its own buffer; -or click mouse-2 on the file's line in the archive mode buffer. - -If you edit a sub-file of this archive (as with the `e' command) and -save it, the contents of that buffer will be saved back into the -archive. - -\\{archive-mode-map}" - ;; This is not interactive because you shouldn't be turning this - ;; mode on and off. You can corrupt things that way. + +(defun archive-setup-mode (&optional force) + "Wrap all the mode setup code into separate function callable from +the package code." (if (zerop (buffer-size)) ;; At present we cannot create archives from scratch (funcall (or (default-value 'major-mode) 'fundamental-mode)) (if (and (not force) archive-files) nil (let* ((type (archive-find-type)) (typename (capitalize (symbol-name type)))) - (kill-all-local-variables) (make-local-variable 'archive-subtype) (setq archive-subtype type) @@ -701,8 +682,7 @@ (setq major-mode 'archive-mode) (setq mode-name (concat typename "-Archive")) ;; Run archive-foo-mode-hook and archive-mode-hook - (run-mode-hooks (archive-name "mode-hook") 'archive-mode-hook) - (use-local-map archive-mode-map)) + (run-mode-hooks (archive-name "mode-hook") 'archive-mode-hook)) (make-local-variable 'archive-proper-file-start) (make-local-variable 'archive-file-list-start) @@ -717,6 +697,30 @@ (archive-summarize nil) (setq buffer-read-only t)))) +;; ------------------------------------------------------------------------- +;;; Section: the mode definition + +;;;###autoload +(define-derived-mode archive-mode special-mode "Archive mode" + "Major mode for viewing an archive file in a dired-like way. +You can move around using the usual cursor motion commands. +Letters no longer insert themselves. +Type `e' to pull a file out of the archive and into its own buffer; +or click mouse-2 on the file's line in the archive mode buffer. + +If you edit a sub-file of this archive (as with the `e' command) and +save it, the contents of that buffer will be saved back into the +archive. + +\\{archive-mode-map}" + ;; This is not interactive because you shouldn't be turning this + ;; mode on and off. You can corrupt things that way. + ;; + ;; Now it's derived mode, so therefore it is interactive. + ;; + (archive-setup-mode)) + + ;; Archive mode is suitable only for specially formatted data. (put 'archive-mode 'mode-class 'special) @@ -888,7 +892,7 @@ (setq archive-files nil) (erase-buffer) (insert-file-contents name) - (archive-mode t) + (archive-setup-mode t) (goto-char archive-file-list-start) (archive-next-line lno)) (archive-delete-local name) @@ -1396,7 +1400,7 @@ (let ((revert-buffer-function nil) (coding-system-for-read 'no-conversion)) (revert-buffer t t)) - (archive-mode) + (archive-setup-mode) (goto-char archive-file-list-start) (archive-next-line no)))