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 6637013
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:15:34+00:00 2026-05-25T23:15:34+00:00

I want to call some functions when I run emacsclient in a terminal emulator.

  • 0

I want to call some functions when I run emacsclient in a terminal emulator. The code I have works when Emacs is started in a text-only terminal. When I start Emacs in graphical mode and run emacsclient -t in a terminal, the functions do not run so I cannot use the mouse in the terminal emulator.

Here is the code in question:

(defun my-terminal-config (&optional frame)
  "Establish settings for the current terminal."
  (message (format "%s" window-system)) ;; "ns" (Mac OS X) when Emacs is started graphically
  (message (format "%s" (display-graphic-p))) ;; nil when Emacs is started graphically
  (unless (display-graphic-p)
    ;; enable mouse reporting for terminal emulators
    (xterm-mouse-mode 1)
    (global-set-key [mouse-4] '(lambda ()
                                 (interactive)
                                 (scroll-down 1)))
    (global-set-key [mouse-5] '(lambda ()
                                 (interactive)
                                 (scroll-up 1)))))
(add-hook 'after-make-frame-functions 'my-terminal-config)

This is a weird situation. Emacsclient connects to the server and creates a new frame, but because the server is running in a graphical environment, it reports window-system to be “ns” whereas in a terminal environment it would be nil. Therefore when I run emacsclient -t in a terminal, the mouse reporting enabling functions do not run. Once emacsclient is running, if I create a new frame with C-x 5 2, then the mouse reporting enabling functions will run because window-system will be nil in that frame.

It seems that when mixing frames between terminals and window systems, the value of window-system will always be that of the Emacs server.

Is there a way that I can run Emacs graphically and emacsclient in text mode and have the mouse functions run there? In other words, is it possible to detect that a frame being created will end up in a graphical or text environment?

Maybe I should simply always run those functions when a frame is created regardless of the value of window-system?

  • 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-25T23:15:35+00:00Added an answer on May 25, 2026 at 11:15 pm

    the trick is that window-system and display-graphic-p are now frame specific. you need to be in that frame inside your hook function (seems like it should already be the case, but i don’t think it is). i had to add this at the beginning of my after-make-frame-functions hook (to make window-system and display-graphic-p behave correctly):

    (select-frame frame)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to call subroutines in Perl like: sub temp { ---- some code
Actually I have some MVC3 Applications and I want to call this applications from
I have a WinForms Application that I want to run at Mono at some
I have two def functions that I call in a nested fashion and want
What I'm trying to do is run some JavaScript code that will enter text
I want to call a url with passing some parameter and i want to
I'm getting some very wierd errors. The compiler seems to want to call the
I want to create some kind of AJAX script or call that continuously will
I've got a particular function I want to run once, and only after the
I have got some code to pass in a variable into a script from

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.