46 |
;; `hl-line-highlight', on `post-command-hook', activates it again |
;; `hl-line-highlight', on `post-command-hook', activates it again |
47 |
;; across the window width. |
;; across the window width. |
48 |
|
|
|
;; You could make variable `hl-line-mode' buffer-local to avoid |
|
|
;; highlighting specific buffers, when the global mode is used. |
|
|
|
|
49 |
;;; Code: |
;;; Code: |
50 |
|
|
51 |
(defgroup hl-line nil |
(defgroup hl-line nil |
69 |
nil nil nil |
nil nil nil |
70 |
(if hl-line-mode |
(if hl-line-mode |
71 |
(progn |
(progn |
72 |
(add-hook 'pre-command-hook #'hl-line-unhighlight) |
(add-hook 'pre-command-hook #'hl-line-unhighlight nil t) |
73 |
(add-hook 'post-command-hook #'hl-line-highlight)) |
(add-hook 'post-command-hook #'hl-line-highlight nil t)) |
74 |
(hl-line-unhighlight) |
(hl-line-unhighlight) |
75 |
(remove-hook 'pre-command-hook #'hl-line-unhighlight) |
(remove-hook 'pre-command-hook #'hl-line-unhighlight t) |
76 |
(remove-hook 'post-command-hook #'hl-line-highlight))) |
(remove-hook 'post-command-hook #'hl-line-highlight t))) |
77 |
|
|
78 |
;;;###autoload |
;;;###autoload |
79 |
(easy-mmode-define-global-mode |
(easy-mmode-define-global-mode |
80 |
global-hl-line-mode hl-line-mode hl-line-mode |
global-hl-line-mode hl-line-mode (lambda () (hl-line-mode 1)) |
81 |
:group 'hl-line) |
:group 'hl-line) |
82 |
|
|
83 |
(defun hl-line-highlight () |
(defun hl-line-highlight () |
84 |
"Active the Hl-Line overlay on the current line in the current window. |
"Active the Hl-Line overlay on the current line in the current window. |
85 |
\(Unless it's a minibuffer window.)" |
\(Unless it's a minibuffer window.)" |
86 |
(when hl-line-mode ; Could be made buffer-local. |
(when hl-line-mode ; Might be changed outside the mode function. |
87 |
(unless (window-minibuffer-p (selected-window)) ; silly in minibuffer |
(unless (window-minibuffer-p (selected-window)) ; silly in minibuffer |
88 |
(unless hl-line-overlay |
(unless hl-line-overlay |
89 |
(setq hl-line-overlay (make-overlay 1 1)) ; to be moved |
(setq hl-line-overlay (make-overlay 1 1)) ; to be moved |