Git Product home page Git Product logo

terminal-focus-reporting.el's Introduction

terminal-focus-reporting.el

MELPA

Minor mode for terminal focus reporting.

This plugin restores focus-in-hook, focus-out-hook functionality. Now Emacs can, for example, save when the terminal loses a focus, even if it's inside the tmux.

You don't need this plugin for latest Emacs. Since Emacs 27 it now requests and recognizes focus-change notifications from TTYs. You would rather need to hook the after focus change:

(add-function :after after-focus-change-function (lambda () (save-some-buffers t)))

Usage

  1. Install it from Melpa

  2. Add code to the Emacs config file:

(unless (display-graphic-p)
  (terminal-focus-reporting-mode))

How it works

Emacs and terminal communicate by sending and receiving special string sequences.

For example, if the program (emacs) sends to the terminal the text <Esc>[?1004h, terminal enables "focus reporting" feature and sends special sequences to the program when focus lost or restored.

This can be tested directly in the terminal executing this command:

$ echo -e "\e[?1004h" && read

and if we let terminal lose a focus and then restore it, we will see these commands sent back by the terminal:

^[[O^[[I

This plugin is able to enable and disable terminal focus reporting and can read special commands from the terminal and execute needed hooks (focus-in, focus-out) when the terminal fires focus lost or focus restored events respectively.

terminal-focus-reporting.el's People

Contributors

veelenga avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

emacsmirror

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.