diff options
| author | Dave Love | 2000-06-01 18:26:34 +0000 |
|---|---|---|
| committer | Dave Love | 2000-06-01 18:26:34 +0000 |
| commit | 3a850efae691370fb750bbc59027081822a323ca (patch) | |
| tree | 1f11ec0dea1dda88104152c96f0cf8f1064a7101 | |
| parent | dd432f166349ee8eb875d95cf68e3669456ee502 (diff) | |
| download | emacs-3a850efae691370fb750bbc59027081822a323ca.tar.gz emacs-3a850efae691370fb750bbc59027081822a323ca.zip | |
Rewritten using define-minor-mode.
| -rw-r--r-- | lisp/hl-line.el | 43 |
1 files changed, 13 insertions, 30 deletions
diff --git a/lisp/hl-line.el b/lisp/hl-line.el index a3fbfb8ab09..8a5d839c384 100644 --- a/lisp/hl-line.el +++ b/lisp/hl-line.el | |||
| @@ -4,7 +4,7 @@ | |||
| 4 | 4 | ||
| 5 | ;; Author: Dave Love <fx@gnu.org> | 5 | ;; Author: Dave Love <fx@gnu.org> |
| 6 | ;; Created: 1998-09-13 | 6 | ;; Created: 1998-09-13 |
| 7 | ;; Keywords: faces, frames | 7 | ;; Keywords: faces, frames, emulation |
| 8 | 8 | ||
| 9 | ;; This file is part of GNU Emacs. | 9 | ;; This file is part of GNU Emacs. |
| 10 | 10 | ||
| @@ -31,8 +31,8 @@ | |||
| 31 | ;; a request for a feature of Lesser Editors. | 31 | ;; a request for a feature of Lesser Editors. |
| 32 | 32 | ||
| 33 | ;; You probably don't really want this; if the cursor is difficult to | 33 | ;; You probably don't really want this; if the cursor is difficult to |
| 34 | ;; spot, try changing its colour or relying on `blink-cursor-mode' The | 34 | ;; spot, try changing its colour, relying on `blink-cursor-mode' or |
| 35 | ;; hookery involved here might slow Emacs noticeably on a slow | 35 | ;; both. The hookery used might affect repsonse noticeably on a slow |
| 36 | ;; machine. | 36 | ;; machine. |
| 37 | 37 | ||
| 38 | ;; An overlay is used, active only on the selected window. Hooks are | 38 | ;; An overlay is used, active only on the selected window. Hooks are |
| @@ -51,18 +51,6 @@ | |||
| 51 | :version "21.1" | 51 | :version "21.1" |
| 52 | :group 'editing) | 52 | :group 'editing) |
| 53 | 53 | ||
| 54 | ;;;###autoload | ||
| 55 | (defcustom hl-line-mode nil | ||
| 56 | "Toggle Hl-Line mode. | ||
| 57 | Setting this variable directly does not take effect; | ||
| 58 | use either \\[customize] or the function `hl-line-mode'." | ||
| 59 | :set (lambda (symbol value) | ||
| 60 | (hl-line-mode (or value 0))) | ||
| 61 | :initialize 'custom-initialize-default | ||
| 62 | :type 'boolean | ||
| 63 | :group 'hl-line | ||
| 64 | :require 'hl-line) | ||
| 65 | |||
| 66 | (defcustom hl-line-face 'highlight | 54 | (defcustom hl-line-face 'highlight |
| 67 | "Face with which to highlight the current line." | 55 | "Face with which to highlight the current line." |
| 68 | :type 'face | 56 | :type 'face |
| @@ -88,25 +76,20 @@ use either \\[customize] or the function `hl-line-mode'." | |||
| 88 | (delete-overlay hl-line-overlay))) | 76 | (delete-overlay hl-line-overlay))) |
| 89 | 77 | ||
| 90 | ;;;###autoload | 78 | ;;;###autoload |
| 91 | (defun hl-line-mode (&optional arg) | 79 | (define-minor-mode hl-line-mode |
| 92 | "Global minor mode to highlight the line about point in the current window. | 80 | "Global minor mode to highlight the line about point in the current window. |
| 93 | |||
| 94 | With ARG, turn Hl-Line mode on if ARG is positive, off otherwise. | 81 | With ARG, turn Hl-Line mode on if ARG is positive, off otherwise. |
| 95 | Uses functions `hl-line-unhighlight' and `hl-line-highlight' on | 82 | Uses functions `hl-line-unhighlight' and `hl-line-highlight' on |
| 96 | `pre-command-hook' and `post-command-hook'." | 83 | `pre-command-hook' and `post-command-hook'." |
| 97 | (interactive "P") | 84 | (global . nil) nil nil |
| 98 | (setq hl-line-mode (if (null arg) | 85 | |
| 99 | (not hl-line-mode) | 86 | (if hl-line-mode |
| 100 | (> (prefix-numeric-value arg) 0))) | 87 | (progn |
| 101 | (cond (hl-line-mode | 88 | (add-hook 'pre-command-hook #'hl-line-unhighlight) |
| 102 | (add-hook 'pre-command-hook #'hl-line-unhighlight) | 89 | (add-hook 'post-command-hook #'hl-line-highlight)) |
| 103 | (add-hook 'post-command-hook #'hl-line-highlight)) | 90 | (hl-line-unhighlight) |
| 104 | (t | 91 | (remove-hook 'pre-command-hook #'hl-line-unhighlight) |
| 105 | (hl-line-unhighlight) | 92 | (remove-hook 'post-command-hook #'hl-line-highlight))) |
| 106 | (remove-hook 'pre-command-hook #'hl-line-unhighlight) | ||
| 107 | (remove-hook 'post-command-hook #'hl-line-highlight))) | ||
| 108 | (if (interactive-p) | ||
| 109 | (message "Hl-Line mode %sabled" (if hl-line-mode "en" "dis")))) | ||
| 110 | 93 | ||
| 111 | (provide 'hl-line) | 94 | (provide 'hl-line) |
| 112 | 95 | ||