• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /macosx-10.9.5/emacs-92/emacs/lisp/

Lines Matching defs:line

1 ;;; hl-line.el --- highlight the current line
30 ;; Provides a local minor mode (toggled by M-x hl-line-mode) and
31 ;; a global minor mode (toggled by M-x global-hl-line-mode) to
32 ;; highlight, on a suitable terminal, the line on which point is. The
33 ;; global mode highlights the current line in the selected window only
36 ;; The local mode is sticky: it highlights the line about the buffer's
39 ;; window. Set the variable `hl-line-sticky-flag' to nil to make the
50 ;; `post-command-hook' to activate the overlay and move it to the line
51 ;; about point. To get the non-sticky behavior, `hl-line-unhighlight'
57 ;; You could make variable `global-hl-line-mode' buffer-local and set
61 ;; By default the whole line is highlighted. The range of highlighting
63 ;; buffer-local value of `hl-line-range-function'.
67 (defvar hl-line-overlay nil
68 "Overlay used by Hl-Line mode to highlight the current line.")
69 (make-variable-buffer-local 'hl-line-overlay)
71 (defvar global-hl-line-overlay nil
72 "Overlay used by Global-Hl-Line mode to highlight the current line.")
74 (defgroup hl-line nil
75 "Highlight the current line."
79 (defface hl-line
81 "Default face for highlighting the current line in Hl-Line mode."
83 :group 'hl-line)
85 (defcustom hl-line-face 'hl-line
86 "Face with which to highlight the current line in Hl-Line mode."
88 :group 'hl-line
93 (when hl-line-overlay
94 (overlay-put hl-line-overlay 'face hl-line-face))))
95 (when global-hl-line-overlay
96 (overlay-put global-hl-line-overlay 'face hl-line-face))))
98 (defcustom hl-line-sticky-flag t
99 "*Non-nil means highlight the current line in all windows.
102 the command `hl-line-mode' to turn Hl-Line mode on."
105 :group 'hl-line)
107 (defvar hl-line-range-function nil
117 (define-minor-mode hl-line-mode
118 "Buffer-local minor mode to highlight the line about point.
121 If `hl-line-sticky-flag' is non-nil, Hl-Line mode highlights the
122 line about the buffer's point in all windows. Caveat: the
125 `hl-line-highlight' on `post-command-hook' in this case.
127 When `hl-line-sticky-flag' is nil, Hl-Line mode highlights the
128 line about point in the selected window only. In this case, it
129 uses the function `hl-line-unhighlight' on `pre-command-hook' in
130 addition to `hl-line-highlight' on `post-command-hook'."
131 :group 'hl-line
132 (if hl-line-mode
135 (add-hook 'change-major-mode-hook #'hl-line-unhighlight nil t)
136 (if hl-line-sticky-flag
137 (remove-hook 'pre-command-hook #'hl-line-unhighlight t)
138 (add-hook 'pre-command-hook #'hl-line-unhighlight nil t))
139 (hl-line-highlight)
140 (add-hook 'post-command-hook #'hl-line-highlight nil t))
141 (remove-hook 'post-command-hook #'hl-line-highlight t)
142 (hl-line-unhighlight)
143 (remove-hook 'change-major-mode-hook #'hl-line-unhighlight t)
144 (remove-hook 'pre-command-hook #'hl-line-unhighlight t)))
146 (defun hl-line-highlight ()
147 "Activate the Hl-Line overlay on the current line."
148 (if hl-line-mode ; Might be changed outside the mode function.
150 (unless hl-line-overlay
151 (setq hl-line-overlay (make-overlay 1 1)) ; to be moved
152 (overlay-put hl-line-overlay 'face hl-line-face))
153 (overlay-put hl-line-overlay
154 'window (unless hl-line-sticky-flag (selected-window)))
155 (hl-line-move hl-line-overlay))
156 (hl-line-unhighlight)))
158 (defun hl-line-unhighlight ()
159 "Deactivate the Hl-Line overlay on the current line."
160 (if hl-line-overlay
161 (delete-overlay hl-line-overlay)))
164 (define-minor-mode global-hl-line-mode
165 "Global minor mode to highlight the line about point in the current window.
168 Global-Hl-Line mode uses the functions `global-hl-line-unhighlight' and
169 `global-hl-line-highlight' on `pre-command-hook' and `post-command-hook'."
171 :group 'hl-line
172 (if global-hl-line-mode
174 (add-hook 'pre-command-hook #'global-hl-line-unhighlight)
175 (add-hook 'post-command-hook #'global-hl-line-highlight))
176 (global-hl-line-unhighlight)
177 (remove-hook 'pre-command-hook #'global-hl-line-unhighlight)
178 (remove-hook 'post-command-hook #'global-hl-line-highlight)))
180 (defun global-hl-line-highlight ()
181 "Active the Global-Hl-Line overlay on the current line in the current window."
182 (when global-hl-line-mode ; Might be changed outside the mode function.
184 (unless global-hl-line-overlay
185 (setq global-hl-line-overlay (make-overlay 1 1)) ; to be moved
186 (overlay-put global-hl-line-overlay 'face hl-line-face))
187 (overlay-put global-hl-line-overlay 'window (selected-window))
188 (hl-line-move global-hl-line-overlay))))
190 (defun global-hl-line-unhighlight ()
191 "Deactivate the Global-Hl-Line overlay on the current line."
192 (if global-hl-line-overlay
193 (delete-overlay global-hl-line-overlay)))
195 (defun hl-line-move (overlay)
197 If `hl-line-range-function' is non-nil, move the OVERLAY to the position
198 where the function returns. If `hl-line-range-function' is nil, fill
199 the line including the point by OVERLAY."
201 (if hl-line-range-function
202 (setq tmp (funcall hl-line-range-function)
206 b (line-beginning-position)
207 e (line-beginning-position 2)))
212 (provide 'hl-line)
215 ;;; hl-line.el ends here