Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4549650
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T16:23:23+00:00 2026-05-21T16:23:23+00:00

In my .emacs file, I have commands that only makes sense in graphical mode

  • 0

In my .emacs file, I have commands that only makes sense in graphical mode (like (set-frame-size (selected-frame) 166 100)). How do I run these only in graphical mode and not in terminal mode (i.e. emacs -nw).

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T16:23:24+00:00Added an answer on May 21, 2026 at 4:23 pm

    The window-system variable tells Lisp programs what window system Emacs is running under. The possible values are

    x
    Emacs is displaying the frame using X.
    w32
    Emacs is displaying the frame using native MS-Windows GUI.
    ns
    Emacs is displaying the frame using the Nextstep interface (used on GNUstep and Mac OS X).
    pc
    Emacs is displaying the frame using MS-DOS direct screen writes.
    nil
    Emacs is displaying the frame on a character-based terminal.

    From the doc.

    Edit: it seems that window-system is deprecated in favor of display-graphic-p (source: C-h f window-system RET on emacs 23.3.1).

    (display-graphic-p &optional DISPLAY)
    
    Return non-nil if DISPLAY is a graphic display.
    Graphical displays are those which are capable of displaying several
    frames and several different fonts at once.  This is true for displays
    that use a window system such as X, and false for text-only terminals.
    DISPLAY can be a display name, a frame, or nil (meaning the selected
    frame's display).
    

    So what you want to do is :

    (if (display-graphic-p)
        (progn
        ;; if graphic
          (your)
          (code))
        ;; else (optional)
        (your)
        (code))
    

    And if you don’t have an else clause, you can just:

    ;; more readable :)
    (when (display-graphic-p)
        (your)
        (code))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my .emacs file, I have (setq transient-mark-mode nil) and yet transient-mark-mode is activated
I have the following lines in my ~/.emacs.d/init.el (custom-set-variables '(flymake-allowed-file-name-masks (quote ( (\\.cc\\' flymake-simple-make-init)
I've tried putting (setq term-setup-hook 'vip-mode) in my .emacs file but this only seems
I have written a function init-set-key-mappings that sets all the global keys in .emacs
I have a program that I'd like to debug with gdb via emacs. In
I'm making a table in emacs org-mode of sunrise-commander commands from the .el file
What I must write in my .emacs file so that the *scratch* buffer is
i have the following in my .emacs file(thanks to SOer nikwin), which evaluates the
I have emacs + egg working correctly when accessing repos/dirs/files that are in my
I have an executable file that can be used from the terminal command line.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.