6

I'm currenty using emacs line highlighting and I found it useful when doing my work in GUI version of emacs. However, I find it uncomfortable to have such mode during my work in terminal. The color of higlight there makes current line being edited almost impossible to read.

The line in my .emacs file which is responsible for enabling this mode globally is: (global-hl-line-mode t).

My question is: is there a way to disable hl-line-mode only in terminal? I'm using xfce4-terminal and guake.

threaz
  • 163
  • 5

1 Answers1

4

Enable highlight mode only in gui version of emacs by wrapping the command inside if window-system.

The value of the window system variable is nil incase of terminals

(if window-system (global-hl-line-mode t))

Reference https://www.gnu.org/software/emacs/manual/html_node/elisp/Window-Systems.html

NOTE : use (display-graphic-p) instead of window-system. For more information refer the comments by Drew.

graywolf
  • 103
  • 3
Hariharan
  • 473
  • 3
  • 7
  • 1
    FWIW: Emacs Dev generally recommends that we use display-graphic-p now, instead of window-system. I can't give you the reasons why. See the Elisp manual, node Display Feature Testing. – Drew Jul 01 '16 at 03:53
  • @Drew Thanks. I'll update my answer accordingly. – Hariharan Jul 01 '16 at 04:08
  • Thank you guys. I don't really know why I had to use (display-graphic-p) (with brackets) but window-system (without brackets). Nonetheless, both solutions seem to work fine. – threaz Jul 01 '16 at 08:59
  • 1
    @threaz: That's because the older window-system is a single variable that tells if there is a window system for the original frame of emacs. display-graphic-p is a function that can tell you if a particular frame is graphical. With emacs-client/server, you can actually have frames on both graphic and text-only displays. – MAP Jul 02 '16 at 06:28