3

I am using Emacs 24, console (8 colors) with the Solarized theme.

Emacs 24 with Solarized theme

I want to make the comments less intrusive using:

(set-face-foreground 'font-lock-comment-delimiter-face "black")
(set-face-foreground 'font-lock-comment-face "black")

That way the comments would be colored with the same color as the hl-line face we can see on the picture. However, when moving to a line containing comments, I would like them to be inverted (black background from the hl-line, normal foreground instead of black) so I can still read them.

Drew
  • 29,895
  • 7
  • 74
  • 104
Mathieu Marques
  • 1,678
  • 15
  • 33
  • There is `highlight-current-line-hook` in highlight-current-line mode http://www.emacswiki.org/emacs/highlight-current-line.el maybe you can use it – jcubic Aug 14 '13 at 12:40
  • Can you elaborate about what to do, how do I use this function ? I am far from being very competent with this technology, but I'm guessing it needs a condition which would be used to either highlight the line or not. – Mathieu Marques Aug 14 '13 at 14:01
  • You change your face in a hook, `(add-hook 'highlight-current-line-hook (lambda() (set-face-foreground 'font-lock-comment-delimiter-face "") (set-face-foreground 'font-lock-comment-face "")))` you can read about hooks in manual https://www.gnu.org/software/emacs/manual/html_node/emacs/Hooks.html – jcubic Aug 14 '13 at 16:48
  • I did enable `highlight-current-line` but the hook doesn't seem to be catching anything. There are no error though. – Mathieu Marques Oct 07 '13 at 08:43

2 Answers2

1

As an alternative, you can also temporarily hide comments. See command hide/show-comments-toggle in library hide-comnt.el. Bind it to a handy key --- pretty simple.

Drew
  • 29,895
  • 7
  • 74
  • 104
0

Please see the code in the attached link: Emacs colors. why it is gray on current line? zenburn theme

Community
  • 1
  • 1
lawlist
  • 13,099
  • 3
  • 49
  • 158
  • I'm afraid you didn't understand my issue. I want the background of the `hl-line` to be black, and the foreground of comments too. However when comments are on the `hl-line` I want them to revert to the standard color (so I can read them). Also I cannot use 256 colors, I'm stuck with 8. – Mathieu Marques Aug 14 '13 at 14:26
  • Try out some of the code in the answers of the attached link in your .emacs file, and then report back if you still have any questions. The original poster stated that `nil` for the foreground lets the other colors shine through. If you want to alter the behavior of hl-line, then you will need to look at its source code. – lawlist Aug 14 '13 at 14:27
  • What you linked doesn't help me. The provided solutions use background, foreground and bold'ness only. – Mathieu Marques Aug 14 '13 at 14:31
  • `nil` foreground lets the other definitions shine through. If your goal is to suppress all other font definitions everywhere `except` on the current line being viewed, well, you will likely need to substantially modify the source code of hl-line.el – lawlist Aug 14 '13 at 14:34
  • Now I see what you meant. My goal is to suppress existing foreground rules for the comments which are on the current line **only**. – Mathieu Marques Aug 14 '13 at 14:40
  • Perhaps you could write something special to alter the default behavior: "By default the whole 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'." – lawlist Aug 14 '13 at 17:18
  • With a foreground `highlight` setting of a color (e.g., black), very little else ever shines through except something like flyspell misspelled words. For example, in `emacs-lisp-mode`, nothing shines through on the highlighted line -- i.e., the foreground of everything is black / bold, and the background is grey. – lawlist Aug 14 '13 at 17:33