Add :os tty module

- Moves clipetty to its own, opt-in module (#2671, #3195, #3498)
- Fix cursor shape changing between evil states (#1994)
- Moves `xterm-mouse-mode` and `visible-cursor` config out of core.
This commit is contained in:
Henrik Lissner 2020-08-07 23:40:06 -04:00
parent ef09695f57
commit 0a4841b247
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
7 changed files with 115 additions and 13 deletions

View file

@ -161,15 +161,6 @@ possible."
;; non-X systems (like Windows or macOS), where only `STRING' is used. ;; non-X systems (like Windows or macOS), where only `STRING' is used.
(setq x-select-request-type '(UTF8_STRING COMPOUND_TEXT TEXT STRING)) (setq x-select-request-type '(UTF8_STRING COMPOUND_TEXT TEXT STRING))
;; Fixes the clipboard in tty Emacs by piping clipboard I/O through xclip, xsel,
;; pb{copy,paste}, wl-copy, termux-clipboard-get, or getclip (cygwin); depending
;; on what is available.
(unless IS-WINDOWS
(add-hook! 'tty-setup-hook
(defun doom-init-clipboard-in-tty-emacs-h ()
(and (require 'clipetty nil t)
(global-clipetty-mode +1)))))
;; ;;
;;; Extra file extensions to support ;;; Extra file extensions to support

View file

@ -48,10 +48,6 @@
;; optimizations (the original has been abandoned). ;; optimizations (the original has been abandoned).
:recipe (:host github :repo "hlissner/ws-butler") :recipe (:host github :repo "hlissner/ws-butler")
:pin "2bb49d3ee7d2cba133bc7e9cdac416cd1c5e4fe0") :pin "2bb49d3ee7d2cba133bc7e9cdac416cd1c5e4fe0")
(unless IS-WINDOWS
(package! clipetty
:recipe (:host github :repo "spudlyo/clipetty")
:pin "01b39044b9b65fa4ea7d3166f8b1ffab6f740362"))
;; core-projects.el ;; core-projects.el
(package! projectile :pin "bbcf781d3fddb8e00d0dc10eb68bc2528fb409b3") (package! projectile :pin "bbcf781d3fddb8e00d0dc10eb68bc2528fb409b3")

View file

@ -16,6 +16,7 @@ removing them from your ~doom!~ block in =$DOOMDIR/init.el=.
- [[#email][:email]] - [[#email][:email]]
- [[#input][:input]] - [[#input][:input]]
- [[#lang][:lang]] - [[#lang][:lang]]
- [[#os][:os]]
- [[#term][:term]] - [[#term][:term]]
- [[#tools][:tools]] - [[#tools][:tools]]
- [[#ui][:ui]] - [[#ui][:ui]]
@ -149,6 +150,12 @@ Modules that bring support for a language or group of languages to Emacs.
+ web =+lsp= - HTML and CSS (SCSS/SASS/LESS/Stylus) support. + web =+lsp= - HTML and CSS (SCSS/SASS/LESS/Stylus) support.
+ [[file:../modules/lang/yaml/README.org][yaml]] =+lsp= - TODO + [[file:../modules/lang/yaml/README.org][yaml]] =+lsp= - TODO
* :os
Modules to improve integration into your OS, system, or devices.
+ tty =+osc= - Improves the terminal Emacs experience.
* :term * :term
Modules that offer terminal emulation. Modules that offer terminal emulation.

View file

@ -104,6 +104,9 @@
;;tmux ; an API for interacting with tmux ;;tmux ; an API for interacting with tmux
;;upload ; map local to remote projects via ssh/ftp ;;upload ; map local to remote projects via ssh/ftp
:os
;;tty ; improve the terminal Emacs experience
:lang :lang
;;agda ; types of types of types of types... ;;agda ; types of types of types of types...
;;cc ; C/C++/Obj-C madness ;;cc ; C/C++/Obj-C madness

59
modules/os/tty/README.org Normal file
View file

@ -0,0 +1,59 @@
#+TITLE: os/tty
#+DATE: August 7, 2020
#+SINCE: v3.0.0
#+STARTUP: inlineimages nofold
* Table of Contents :TOC_3:noexport:
- [[#description][Description]]
- [[#maintainers][Maintainers]]
- [[#module-flags][Module Flags]]
- [[#plugins][Plugins]]
- [[#prerequisites][Prerequisites]]
- [[#configuration][Configuration]]
- [[#troubleshooting][Troubleshooting]]
* Description
This module configures Emacs for terminal usage.
+ System clipboard integration (through an external clipboard program or OSC-52
escape codes in supported terminals).
+ Fixes cursor-shape changing across evil states in terminal that support it.
+ Mouse support in the terminal.
** Maintainers
This module has no dedicated maintainers.
** Module Flags
+ =+osx= Instead of piping your kill ring through external programs, like xclip
or pbcopy, have Emacs emit OSC-52 escape codes instead, allowing Emacs to
communicate to your clipboard through your terminal. This allows for clipboard
communication over SSH connections or tmux. However, this requires [[https://github.com/spudlyo/clipetty#terminals-that-support-osc-clipboard-operations][a supported
terminal]].
** Plugins
+ clipetty
+ evil-terminal-cursor-changer
+ xclip
* Prerequisites
This module has no hard prerequisites, but in order for its features to work you
need
+ For system clipboard integration:
+ A supported clipboard program, such as:
+ Linux: =xclip=, =xsel=, or =wl-clibpoard= (Wayland)
+ macOS: =pbcopy= and =pbpaste= (included with macOS)
+ Windows: =getclip= and =putclip= (cygwin)
+ A terminal that supports OSC 52 escape codes, such as:
xterm (unix), iTerm2 (macOS), alacritty (cross platform), kitty (macOS, linux), mintty (Windows), hterm (javascript), st (unix), mlterm (cross platform)
+ For cursor shape changing:
+ A terminal that supports VT's DECSCUSR sequence, such as:
Gnome Terminal, xterm, iTerm (macOS), Konsole, or mintty (Windows).
Terminal.app (macOS) is supported to, but requires [[http://www.culater.net/software/SIMBL/SIMBL.php][SIMBL]] and [[https://github.com/saitoha/mouseterm-plus/releases][MouseTerm]] Plus
to work.
* Configuration
# How to configure this module, including common problems and how to address them.
* Troubleshooting
# Common issues and their solution, or places to look for help.

34
modules/os/tty/config.el Normal file
View file

@ -0,0 +1,34 @@
;;; os/tty/config.el -*- lexical-binding: t; -*-
;; Some terminals offer two different cursors: a "visible" static cursor and a
;; "very visible" blinking one. By default, Emacs uses the very visible cursor
;; and will switch back to it when Emacs is started or resumed. A nil
;; `visible-cursor' prevents this.
(setq visible-cursor nil)
;; Enable the mouse in terminal Emacs
(add-hook 'tty-setup-hook #'xterm-mouse-mode)
;; Windows terminals don't support what I'm about to do.
(add-hook! 'tty-setup-hook
(defun doom-init-clipboard-in-tty-emacs-h ()
;; Fix the clipboard in tty Emacs by...
(if (featurep! +osc)
;; ...communicating with the clibpoard through OSC escape codes (must
;; use a terminal that supports it)
(and (require 'clipetty nil t)
(global-clipetty-mode +1))
;; ...OR piping clipboard I/O through xclip, xsel, pb{copy,paste},
;; wl-copy, termux-clipboard-get, or getclip (cygwin); depending on what
;; is available.
(and (require 'xclip nil t)
(xclip-mode +1)))))
(when (featurep! :editor evil)
;; Fix cursor shape-changing in the terminal. Only supported in XTerm, Gnome
;; Terminal, iTerm, Konsole, dumb (etc. mintty), and Apple Terminal.app. If
;; using Apple Terminal.app, install
;; http://www.culater.net/software/SIMBL/SIMBL.php and
;; https://github.com/saitoha/mouseterm-plus/releases. That makes to support
;; VT's DECSCUSR sequence.
(add-hook 'tty-setup-hook #'evil-terminal-cursor-changer-activate))

View file

@ -0,0 +1,12 @@
;; -*- no-byte-compile: t; -*-
;;; os/tty/packages.el
(if (featurep! +osc)
(package! clipetty
:recipe (:host github :repo "spudlyo/clipetty")
:pin "01b39044b9b65fa4ea7d3166f8b1ffab6f740362")
;; Despite its name, this works for macOS as well.
(package! xclip :pin "2951c6b62b29780c7a35c64601a59999b83aa145"))
(when (featurep! :editor evil)
(package! evil-terminal-cursor-changer :pin "b49ca4393d2f3cc6014174950059b36a5cb22949"))