diff --git a/core/core-editor.el b/core/core-editor.el index a98428e08..195a1d3fe 100644 --- a/core/core-editor.el +++ b/core/core-editor.el @@ -161,15 +161,6 @@ possible." ;; non-X systems (like Windows or macOS), where only `STRING' is used. (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 diff --git a/core/packages.el b/core/packages.el index e54c5b490..f646c17b4 100644 --- a/core/packages.el +++ b/core/packages.el @@ -48,10 +48,6 @@ ;; optimizations (the original has been abandoned). :recipe (:host github :repo "hlissner/ws-butler") :pin "2bb49d3ee7d2cba133bc7e9cdac416cd1c5e4fe0") -(unless IS-WINDOWS - (package! clipetty - :recipe (:host github :repo "spudlyo/clipetty") - :pin "01b39044b9b65fa4ea7d3166f8b1ffab6f740362")) ;; core-projects.el (package! projectile :pin "bbcf781d3fddb8e00d0dc10eb68bc2528fb409b3") diff --git a/docs/modules.org b/docs/modules.org index 95626ae8a..25c1ac8af 100644 --- a/docs/modules.org +++ b/docs/modules.org @@ -16,6 +16,7 @@ removing them from your ~doom!~ block in =$DOOMDIR/init.el=. - [[#email][:email]] - [[#input][:input]] - [[#lang][:lang]] +- [[#os][:os]] - [[#term][:term]] - [[#tools][:tools]] - [[#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. + [[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 Modules that offer terminal emulation. diff --git a/init.example.el b/init.example.el index f8bc1d176..0b8f82495 100644 --- a/init.example.el +++ b/init.example.el @@ -104,6 +104,9 @@ ;;tmux ; an API for interacting with tmux ;;upload ; map local to remote projects via ssh/ftp + :os + ;;tty ; improve the terminal Emacs experience + :lang ;;agda ; types of types of types of types... ;;cc ; C/C++/Obj-C madness diff --git a/modules/os/tty/README.org b/modules/os/tty/README.org new file mode 100644 index 000000000..9112a22e5 --- /dev/null +++ b/modules/os/tty/README.org @@ -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. diff --git a/modules/os/tty/config.el b/modules/os/tty/config.el new file mode 100644 index 000000000..b9b86c3db --- /dev/null +++ b/modules/os/tty/config.el @@ -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)) diff --git a/modules/os/tty/packages.el b/modules/os/tty/packages.el new file mode 100644 index 000000000..5f1cef5b4 --- /dev/null +++ b/modules/os/tty/packages.el @@ -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"))