diff options
author | Masatake YAMATO <jet@gyve.org> | 2004-03-15 07:27:02 +0000 |
---|---|---|
committer | Masatake YAMATO <jet@gyve.org> | 2004-03-15 07:27:02 +0000 |
commit | 9fd76d04e8b93bb6116dffe49b8fdabdac71286f (patch) | |
tree | fe6d8918286e794fb0f8cd66991abf78f3c4f180 /lisp/hl-line.el | |
parent | 6e54fa536d7848031898ae11a228d40ca2c81a61 (diff) | |
download | emacs-9fd76d04e8b93bb6116dffe49b8fdabdac71286f.tar.gz |
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.
Diffstat (limited to 'lisp/hl-line.el')
-rw-r--r-- | lisp/hl-line.el | 36 |
1 files changed, 32 insertions, 4 deletions
diff --git a/lisp/hl-line.el b/lisp/hl-line.el index 58921aaa58a..5ed334f4049 100644 --- a/lisp/hl-line.el +++ b/lisp/hl-line.el @@ -57,6 +57,10 @@ ;; it to nil to avoid highlighting specific buffers, when the global ;; mode is used. +;; In default whole the line is highlighted. The range of highlighting +;; can be changed by defining an appropriate function as the +;; buffer-local value of `hl-line-range-function'. + ;;; Code: (defgroup hl-line nil @@ -78,6 +82,15 @@ the command `hl-line-mode' to turn Hl-Line mode on." :version "21.4" :group 'hl-line) +(defvar hl-line-range-function nil + "If non-nil, function to call to return highlight range. +The function of no args should return a cons cell; its car value +is the beginning position of highlight and its cdr value is the +end position of highlight in the buffer. +It should return nil if there's no region to be highlighted. + +This variable is expected to be made buffer-local by modes.") + (defvar hl-line-overlay nil "Overlay used by Hl-Line mode to highlight the current line.") (make-variable-buffer-local 'hl-line-overlay) @@ -124,8 +137,7 @@ addition to `hl-line-highlight' on `post-command-hook'." (overlay-put hl-line-overlay 'face hl-line-face)) (overlay-put hl-line-overlay 'window (unless hl-line-sticky-flag (selected-window))) - (move-overlay hl-line-overlay - (line-beginning-position) (line-beginning-position 2))) + (hl-line-move hl-line-overlay)) (hl-line-unhighlight))) (defun hl-line-unhighlight () @@ -158,14 +170,30 @@ Global-Hl-Line mode uses the functions `global-hl-line-unhighlight' and (setq global-hl-line-overlay (make-overlay 1 1)) ; to be moved (overlay-put global-hl-line-overlay 'face hl-line-face)) (overlay-put global-hl-line-overlay 'window (selected-window)) - (move-overlay global-hl-line-overlay - (line-beginning-position) (line-beginning-position 2))))) + (hl-line-move global-hl-line-overlay)))) (defun global-hl-line-unhighlight () "Deactivate the Global-Hl-Line overlay on the current line." (if global-hl-line-overlay (delete-overlay global-hl-line-overlay))) +(defun hl-line-move (overlay) + "Move the hl-line-mode overlay. +If `hl-line-range-function' is non-nil, move the OVERLAY to the position +where the function returns. If `hl-line-range-function' is nil, fill +the line including the point by OVERLAY." + (let (tmp b e) + (if hl-line-range-function + (setq tmp (funcall hl-line-range-function) + b (car tmp) + e (cdr tmp)) + (setq tmp t + b (line-beginning-position) + e (line-beginning-position 2))) + (if tmp + (move-overlay overlay b e) + (move-overlay overlay 1 1)))) + (provide 'hl-line) ;;; arch-tag: ac806940-0876-4959-8c89-947563ee2833 |