comparison lisp/hl-line.el @ 54399:ad02f6299e9a

2004-03-15 Masatake YAMATO <jet@gyve.org> * hl-line.el (hl-line-range-function): New variable. (hl-line-move): New function. (global-hl-line-highlight): Use `hl-line-move'. (hl-line-highlight): Ditto. * scroll-bar.el (scroll-bar-columns): New function derived from ruler-mode.el. * fringe.el (fringe-columns): New function derived from ruler-mode.el. * ruler-mode.el (top-level): Require scroll-bar and fringe. (ruler-mode-left-fringe-cols) (ruler-mode-right-fringe-cols): Use `fringe-columns'. (ruler-mode-right-scroll-bar-cols) (ruler-mode-left-scroll-bar-cols): Use `scroll-bar-columns'. (ruler-mode-ruler-function): New variable. (ruler-mode-header-line-format): Call `ruler-mode-ruler-function' if the value for `ruler-mode-ruler-function'is given. * hexl.el (hexl-mode-hook): Make the hook customizable. (hexl-address-area, hexl-ascii-area, hexl-ascii-cursor): New customize variables. (hexlify-buffer): Put font-lock-faces on the address area and the ascii area. (hexl-activate-ruler): New function. (hexl-follow-line): New function. (hexl-highlight-line-range): New function. (hexl-mode-ruler): New function.
author Masatake YAMATO <jet@gyve.org>
date Mon, 15 Mar 2004 07:27:02 +0000
parents 7d40f75d6c53
children aac0a33f5772
comparison
equal deleted inserted replaced
54398:2decd50569f3 54399:ad02f6299e9a
55 55
56 ;; You could make variable `global-hl-line-mode' buffer-local and set 56 ;; You could make variable `global-hl-line-mode' buffer-local and set
57 ;; it to nil to avoid highlighting specific buffers, when the global 57 ;; it to nil to avoid highlighting specific buffers, when the global
58 ;; mode is used. 58 ;; mode is used.
59 59
60 ;; In default whole the line is highlighted. The range of highlighting
61 ;; can be changed by defining an appropriate function as the
62 ;; buffer-local value of `hl-line-range-function'.
63
60 ;;; Code: 64 ;;; Code:
61 65
62 (defgroup hl-line nil 66 (defgroup hl-line nil
63 "Highlight the current line." 67 "Highlight the current line."
64 :version "21.1" 68 :version "21.1"
75 window. Setting this variable takes effect the next time you use 79 window. Setting this variable takes effect the next time you use
76 the command `hl-line-mode' to turn Hl-Line mode on." 80 the command `hl-line-mode' to turn Hl-Line mode on."
77 :type 'boolean 81 :type 'boolean
78 :version "21.4" 82 :version "21.4"
79 :group 'hl-line) 83 :group 'hl-line)
84
85 (defvar hl-line-range-function nil
86 "If non-nil, function to call to return highlight range.
87 The function of no args should return a cons cell; its car value
88 is the beginning position of highlight and its cdr value is the
89 end position of highlight in the buffer.
90 It should return nil if there's no region to be highlighted.
91
92 This variable is expected to be made buffer-local by modes.")
80 93
81 (defvar hl-line-overlay nil 94 (defvar hl-line-overlay nil
82 "Overlay used by Hl-Line mode to highlight the current line.") 95 "Overlay used by Hl-Line mode to highlight the current line.")
83 (make-variable-buffer-local 'hl-line-overlay) 96 (make-variable-buffer-local 'hl-line-overlay)
84 97
122 (unless hl-line-overlay 135 (unless hl-line-overlay
123 (setq hl-line-overlay (make-overlay 1 1)) ; to be moved 136 (setq hl-line-overlay (make-overlay 1 1)) ; to be moved
124 (overlay-put hl-line-overlay 'face hl-line-face)) 137 (overlay-put hl-line-overlay 'face hl-line-face))
125 (overlay-put hl-line-overlay 138 (overlay-put hl-line-overlay
126 'window (unless hl-line-sticky-flag (selected-window))) 139 'window (unless hl-line-sticky-flag (selected-window)))
127 (move-overlay hl-line-overlay 140 (hl-line-move hl-line-overlay))
128 (line-beginning-position) (line-beginning-position 2)))
129 (hl-line-unhighlight))) 141 (hl-line-unhighlight)))
130 142
131 (defun hl-line-unhighlight () 143 (defun hl-line-unhighlight ()
132 "Deactivate the Hl-Line overlay on the current line." 144 "Deactivate the Hl-Line overlay on the current line."
133 (if hl-line-overlay 145 (if hl-line-overlay
156 (unless (window-minibuffer-p (selected-window)) 168 (unless (window-minibuffer-p (selected-window))
157 (unless global-hl-line-overlay 169 (unless global-hl-line-overlay
158 (setq global-hl-line-overlay (make-overlay 1 1)) ; to be moved 170 (setq global-hl-line-overlay (make-overlay 1 1)) ; to be moved
159 (overlay-put global-hl-line-overlay 'face hl-line-face)) 171 (overlay-put global-hl-line-overlay 'face hl-line-face))
160 (overlay-put global-hl-line-overlay 'window (selected-window)) 172 (overlay-put global-hl-line-overlay 'window (selected-window))
161 (move-overlay global-hl-line-overlay 173 (hl-line-move global-hl-line-overlay))))
162 (line-beginning-position) (line-beginning-position 2)))))
163 174
164 (defun global-hl-line-unhighlight () 175 (defun global-hl-line-unhighlight ()
165 "Deactivate the Global-Hl-Line overlay on the current line." 176 "Deactivate the Global-Hl-Line overlay on the current line."
166 (if global-hl-line-overlay 177 (if global-hl-line-overlay
167 (delete-overlay global-hl-line-overlay))) 178 (delete-overlay global-hl-line-overlay)))
168 179
180 (defun hl-line-move (overlay)
181 "Move the hl-line-mode overlay.
182 If `hl-line-range-function' is non-nil, move the OVERLAY to the position
183 where the function returns. If `hl-line-range-function' is nil, fill
184 the line including the point by OVERLAY."
185 (let (tmp b e)
186 (if hl-line-range-function
187 (setq tmp (funcall hl-line-range-function)
188 b (car tmp)
189 e (cdr tmp))
190 (setq tmp t
191 b (line-beginning-position)
192 e (line-beginning-position 2)))
193 (if tmp
194 (move-overlay overlay b e)
195 (move-overlay overlay 1 1))))
196
169 (provide 'hl-line) 197 (provide 'hl-line)
170 198
171 ;;; arch-tag: ac806940-0876-4959-8c89-947563ee2833 199 ;;; arch-tag: ac806940-0876-4959-8c89-947563ee2833
172 ;;; hl-line.el ends here 200 ;;; hl-line.el ends here