about summary refs log tree commit diff
path: root/modules/workstation/emacs
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2020-10-29 08:28:23 +0000
committerAlyssa Ross <hi@alyssa.is>2020-12-04 16:59:18 +0000
commit6e5117584cfde97f94896b1e8e7e85530020925d (patch)
tree92fa6cdd4f376070801a1dda252d4cc7e7855e94 /modules/workstation/emacs
parent72aa9b7a75d7286762831d64bd3fbc029e64b554 (diff)
downloadnixlib-6e5117584cfde97f94896b1e8e7e85530020925d.tar
nixlib-6e5117584cfde97f94896b1e8e7e85530020925d.tar.gz
nixlib-6e5117584cfde97f94896b1e8e7e85530020925d.tar.bz2
nixlib-6e5117584cfde97f94896b1e8e7e85530020925d.tar.lz
nixlib-6e5117584cfde97f94896b1e8e7e85530020925d.tar.xz
nixlib-6e5117584cfde97f94896b1e8e7e85530020925d.tar.zst
nixlib-6e5117584cfde97f94896b1e8e7e85530020925d.zip
modules/emacs: disable pager (except in term)
This will make git log and journalctl work properly in eshell or
async-shell-command.

Lexical binding is needed for enable-pager to capture the original
PAGER value.
Diffstat (limited to 'modules/workstation/emacs')
-rw-r--r--modules/workstation/emacs/init.el16
1 files changed, 16 insertions, 0 deletions
diff --git a/modules/workstation/emacs/init.el b/modules/workstation/emacs/init.el
index e0c0a79a6242..b3f5861c4be0 100644
--- a/modules/workstation/emacs/init.el
+++ b/modules/workstation/emacs/init.el
@@ -1,3 +1,5 @@
+;; -*- lexical-binding: t -*-
+
 ;;; UI customization ;;;
 (column-number-mode)
 (electric-pair-mode)
@@ -40,6 +42,17 @@
 (direnv-mode)
 (global-set-key (kbd "C-c d") 'direnv-update-environment)
 
+;;; Environment ;;;
+
+;; Provide a way to turn paging back on for modes like terminal emulators.
+(let ((pager (getenv "PAGER")))
+  (defun enable-pager ()
+    (setenv-local "PAGER" pager)))
+
+;; Set PAGER to the empty string, which Git and journalctl will
+;; interpret as an explicit opt-out of paging.
+(setenv "PAGER" "")
+
 ;;; Eshell ;;;
 ;; Tell programs we support ANSI color.
 (add-hook 'eshell-mode-hook
@@ -94,6 +107,9 @@
 ;; Use the system "sendmail" program to send mail.
 (setq send-mail-function 'sendmail-send-it)
 
+;;; Term ;;;
+(add-hook 'term-mode-hook #'enable-pager)
+
 ;;; Transient ;;;
 ;; Make all Magit options available, even those that are disabled by
 ;; default because they're too obscure.