(hilit-mode): New function.
authorStefan Monnier <monnier@iro.umontreal.ca>
Wed, 27 Oct 2004 19:51:13 +0000 (19:51 +0000)
committerStefan Monnier <monnier@iro.umontreal.ca>
Wed, 27 Oct 2004 19:51:13 +0000 (19:51 +0000)
Move all the toplevel side-effecting stuff into it, so that loading
hilit19 doesn't mess everything up any more.

lisp/obsolete/hilit19.el

index 4d8af4b..b1aef20 100644 (file)
@@ -1,6 +1,6 @@
 ;;; hilit19.el --- customizable highlighting for Emacs 19
 
-;; Copyright (c) 1993, 1994, 2001 Free Software Foundation, Inc.
+;; Copyright (c) 1993, 1994, 2001, 2004 Free Software Foundation, Inc.
 
 ;; Author:   Jonathan Stigelman <stig@hackvan.com>
 ;; Maintainer: FSF
@@ -397,8 +397,6 @@ See the hilit-lookup-face-create documentation for valid face names.")
 If hilit19 is dumped into emacs at your site, you may have to set this in
 your init file.")
 
-(eval-when-compile (setq byte-optimize t))
-
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Use this to report bugs:
 
@@ -945,47 +943,61 @@ the entire buffer is forced."
 ;; Initialization.
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
-(and (not hilit-inhibit-rebinding)
-     (progn
-       (substitute-key-definition 'yank     'hilit-yank
-                                 (current-global-map))
-       (substitute-key-definition 'yank-pop 'hilit-yank-pop
-                                 (current-global-map))
-       (substitute-key-definition 'recenter 'hilit-recenter
-                                 (current-global-map))))
-
-(global-set-key [?\C-\S-l] 'hilit-repaint-command)
-
-(add-hook 'find-file-hook 'hilit-find-file-hook t)
+(define-minor-mode hilit-mode
+  "Obsolete minor mode.  Use `global-font-lock-mode' instead."
+  :global t
+
+  (unless (and hilit-inhibit-rebinding hilit-mode)
+    (substitute-key-definition
+     (if hilit-mode 'yank 'hilit-yank)
+     (if hilit-mode 'hilit-yank 'yank)
+     (current-global-map))
+    (substitute-key-definition
+     (if hilit-mode 'yank-pop 'hilit-yank-pop)
+     (if hilit-mode 'hilit-yank-pop 'yank-pop)
+     (current-global-map))
+    (substitute-key-definition
+     (if hilit-mode 'recenter 'hilit-recenter)
+     (if hilit-mode 'hilit-recenter 'recenter)
+     (current-global-map)))
+
+  (if hilit-mode
+      (global-set-key [?\C-\S-l] 'hilit-repaint-command)
+    (global-unset-key [?\C-\S-l]))
+
+  (if hilit-mode
+      (add-hook 'find-file-hook 'hilit-find-file-hook t)
+    (remove-hook 'find-file-hook 'hilit-find-file-hook t))
+
+  (unless (and hilit-inhibit-hooks hilit-mode)
+    (condition-case c
+       (progn
+
+         ;; BUFFER highlights...
+         (mapcar (lambda (hook)
+                   (if hilit-mode
+                       (add-hook hook 'hilit-rehighlight-buffer-quietly)
+                     (remove-hook hook 'hilit-rehighlight-buffer-quietly)))
+                 '(
+                   Info-selection-hook
+
+                   ;; runs too early                vm-summary-mode-hooks
+                   vm-summary-pointer-hook
+                   vm-preview-message-hook
+                   vm-show-message-hook
+
+                   rmail-show-message-hook
+                   mail-setup-hook
+                   mh-show-mode-hook
+
+                   dired-after-readin-hook
+                   ))
+         )
+      (error (message "Error loading highlight hooks: %s" c)
+            (ding) (sit-for 1)))))
 
 (eval-when-compile (require 'gnus))    ; no compilation gripes
 
-(and (not hilit-inhibit-hooks)
-     (condition-case c
-        (progn
-
-          ;; BUFFER highlights...
-          (mapcar (function
-                   (lambda (hook)
-                     (add-hook hook 'hilit-rehighlight-buffer-quietly)))
-                  '(
-                    Info-selection-hook
-
-;; runs too early                   vm-summary-mode-hooks
-                    vm-summary-pointer-hook
-                    vm-preview-message-hook
-                    vm-show-message-hook
-
-                    rmail-show-message-hook
-                    mail-setup-hook
-                    mh-show-mode-hook
-
-                    dired-after-readin-hook
-                    ))
-          )
-       (error (message "Error loading highlight hooks: %s" c)
-             (ding) (sit-for 1))))
-
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Default patterns for various modes.
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -1510,5 +1522,5 @@ number of backslashes."
 
 (provide 'hilit19)
 
-;;; arch-tag: db99739a-4837-41ee-ad02-3baced8ae71d
+;; arch-tag: db99739a-4837-41ee-ad02-3baced8ae71d
 ;;; hilit19.el ends here