[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Highlighting current window
From: |
Francesco Mazzoli |
Subject: |
Re: Highlighting current window |
Date: |
Sun, 01 Jul 2012 12:49:13 +0100 |
User-agent: |
Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (Gojō) APEL/10.8 Emacs/23.3 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) |
Hi Christopher,
At Sat, 30 Jun 2012 16:16:21 -0400,
Christopher Grubert wrote:
> I use a combination of the three faces mode-line, mode-line-inactive,
> mode-line-buffer-id and the hl-line+ package which gives current line
> highlighting but only in the active window. I've found this combination
> to work pretty well for me. I also use a fairly innocuous line
> highlighting color (:background "#222") so that it doesn't really
> conflict with any other fontification colors, but still draws attention
> to where I am. It draws your attention to the exact line you're on as
> opposed to just the window you're in, but I've found that useful.
> Chris.
I looked at hl-line mode and it supports that functionality as well. I
looked at the source and the trick is using overlays. Knowing that, I
was able to do what I want quite quickly:
----------------8<-------------------------------
;;; Darker background for current buffer
(set-face-attribute 'default nil :background "#1e1e1e")
(set-cursor-color "#ffffff")
(defvar current-buffer-backround-overlay
nil)
(defun darken-current-buffer-background ()
(unless (window-minibuffer-p (selected-window))
(unless current-buffer-backround-overlay
(setq current-buffer-backround-overlay (make-overlay 1 1))
(overlay-put current-buffer-backround-overlay 'face '(:background
"black")))
(overlay-put current-buffer-backround-overlay 'window
(selected-window))
(move-overlay current-buffer-backround-overlay
(point-min) (point-max))))
(defun undarken-current-buffer-background ()
(when darken-current-buffer-background
(delete-overlay current-buffer-backround-overlay)))
(add-hook 'pre-command-hook #'undarken-current-buffer-background)
(add-hook 'post-command-hook #'darken-current-buffer-background)
---------------->8-------------------------------
However, I think that using hl-line might be an even better solution,
I'll try both a bit and see what I prefer.
--
Francesco * Often in error, never in doubt
- Re: Highlighting current window,
Francesco Mazzoli <=