1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
| | ;;; hl-line.el --- highlight the current line -*- lexical-binding:t -*-
;; Copyright (C) 1998, 2000-2022 Free Software Foundation, Inc.
;; Author: Dave Love <fx@gnu.org>
;; Maintainer: emacs-devel@gnu.org
;; Created: 1998-09-13
;; Keywords: faces, frames, emulations
;; This file is part of GNU Emacs.
;; GNU Emacs is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
;;; Commentary:
;;; Code:
(make-obsolete-variable 'hl-line-overlay nil "29.1")
(make-obsolete-variable 'global-hl-line-overlay nil "29.1")
(make-obsolete-variable 'global-hl-line-overlays nil "29.1")
(make-obsolete-variable 'global-hl-line-sticky-flag nil "29.1")
(make-obsolete-variable 'hl-line-overlay-buffer nil "29.1")
(make-obsolete-variable 'hl-line-range-function nil "29.1")
(defvar-local hl-line--overlay nil
"Keep state else scan entire buffer in `post-command-hook'.")
;; 1. define-minor-mode creates buffer-local hl-line--overlay
;; 2. overlay wiped by kill-all-local-variables
;; 3. post-command-hook dupes overlay
;; Solution: prevent step 2.
(put 'hl-line--overlay 'permanent-local t)
(defgroup hl-line nil
"Highlight the current line."
:version "21.1"
:group 'convenience)
(defface hl-line-face '((t :inherit highlight :extend t))
"Default face for highlighting the current line in hl-line-mode."
:version "22.1"
:group 'hl-line)
(defcustom hl-line-sticky-flag t
"Non-nil to preserve highlighting overlay when focus leaves window."
:type 'boolean
:version "22.1"
:group 'hl-line
:set (lambda (symbol value)
(set-default symbol value)
(unless value
(let ((selected (window-buffer (selected-window))))
(dolist (buffer (buffer-list))
(unless (eq buffer selected)
(with-current-buffer buffer
(hl-line-unhighlight))))))))
(defcustom hl-line-overlay-priority -50
"Priority used on the overlay used by hl-line."
:type 'integer
:version "22.1"
:group 'hl-line)
(defcustom hl-line-highlight-hook nil
"After hook for `hl-line-highlight'.
Currently used in calendar/todo-mode."
:type 'hook
:group 'hl-line)
;;;###autoload
(define-minor-mode hl-line-mode
"Toggle highlighting of the current line."
:group 'hl-line
(if hl-line-mode
(progn
(hl-line-highlight)
(add-hook 'change-major-mode-hook #'hl-line-unhighlight nil t)
(add-hook 'post-command-hook #'hl-line-highlight nil t))
(remove-hook 'post-command-hook #'hl-line-highlight t)
(remove-hook 'change-major-mode-hook #'hl-line-unhighlight t)
(let (hl-line-sticky-flag)
(hl-line-unhighlight))))
(defun hl-line-unhighlight ()
(unless hl-line-sticky-flag
(when hl-line--overlay
(delete-overlay hl-line--overlay)
(setq hl-line--overlay nil))))
(defun hl-line-highlight ()
(unless (minibufferp)
(unless hl-line--overlay
(setq hl-line--overlay
(let ((ol (make-overlay (point) (point))))
(prog1 ol
(overlay-put ol 'priority hl-line-overlay-priority)
(overlay-put ol 'face 'hl-line-face)))))
(move-overlay hl-line--overlay
(line-beginning-position)
(line-beginning-position 2))
(run-hooks 'hl-line-highlight-hook)))
(defun hl-line-turn-on ()
(unless (minibufferp)
(let (inhibit-quit)
(hl-line-mode 1))))
;;;###autoload
(define-globalized-minor-mode global-hl-line-mode
hl-line-mode hl-line-turn-on
:group 'hl-line
:version "29.1")
(provide 'hl-line)
;;; hl-line.el ends here
|