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.

1 Answer 1

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.

4
  • 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
    Commented Jul 1, 2016 at 3:53
  • @Drew Thanks. I'll update my answer accordingly.
    – Hariharan
    Commented Jul 1, 2016 at 4: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
    Commented Jul 1, 2016 at 8: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
    Commented Jul 2, 2016 at 6:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.