diff lisp/obsolete/hilit19.el @ 57754:5062636cfe37

(hilit-mode): New function. Move all the toplevel side-effecting stuff into it, so that loading hilit19 doesn't mess everything up any more.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Wed, 27 Oct 2004 19:51:13 +0000
parents 695cf19ef79e
children 6e18b0aebeb3
line wrap: on
line diff
--- a/lisp/obsolete/hilit19.el	Wed Oct 27 17:51:08 2004 +0000
+++ b/lisp/obsolete/hilit19.el	Wed Oct 27 19:51:13 2004 +0000
@@ -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 @@
 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 @@
 ;; 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))))
+(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))
 
-(global-set-key [?\C-\S-l] 'hilit-repaint-command)
+  (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
 
-(add-hook 'find-file-hook 'hilit-find-file-hook t)
+		    ;; 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 @@
 
 (provide 'hilit19)
 
-;;; arch-tag: db99739a-4837-41ee-ad02-3baced8ae71d
+;; arch-tag: db99739a-4837-41ee-ad02-3baced8ae71d
 ;;; hilit19.el ends here