From 97a0d713317036d773df6476f8ae47a1e423276f Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 4 Jan 2019 10:18:06 +1300 Subject: Further attempts at sane Emacs VISUAL setting --- .gitignore | 1 + Makefile | 5 ++++- emacs/bin/emacsm.sh | 3 +++ emacs/profile.d/emacs.sh | 2 ++ sh/profile.d/visual.sh | 26 +++++--------------------- 5 files changed, 15 insertions(+), 22 deletions(-) create mode 100644 emacs/bin/emacsm.sh create mode 100644 emacs/profile.d/emacs.sh diff --git a/.gitignore b/.gitignore index 8b407166..309644a0 100644 --- a/.gitignore +++ b/.gitignore @@ -152,6 +152,7 @@ /bin/xrq /dillo/dillorc /dillo/dillorc.m4 +/emacs/bin/emacsm /games/aaf /games/acq /games/aesth diff --git a/Makefile b/Makefile index 31018936..6c7b9ee0 100644 --- a/Makefile +++ b/Makefile @@ -393,8 +393,11 @@ install-dunst: install-x mkdir -p -- $(HOME)/.config/dunst cp -p -- dunst/dunstrc $(HOME)/.config/dunst -install-emacs: +install-emacs: emacs/bin/emacsm install-sh + mkdir -p -- $(HOME)/.local/bin cp -p -- emacs/emacs $(HOME)/.emacs + cp -p -- emacs/bin/emacsm $(HOME)/.local/bin + cp -p -- emacs/profile.d/emacs.sh $(HOME)/.profile.d install-ex: cp -p -- ex/exrc $(HOME)/.exrc diff --git a/emacs/bin/emacsm.sh b/emacs/bin/emacsm.sh new file mode 100644 index 00000000..58571c5c --- /dev/null +++ b/emacs/bin/emacsm.sh @@ -0,0 +1,3 @@ +# Try to manage GNU emacs daemons on the terminal +# Emphasis on "try". Man, I have no idea what I'm doing. +emacsclient --create-frame --alternate-editor='' diff --git a/emacs/profile.d/emacs.sh b/emacs/profile.d/emacs.sh new file mode 100644 index 00000000..34f6d476 --- /dev/null +++ b/emacs/profile.d/emacs.sh @@ -0,0 +1,2 @@ +# Start an Emacs server if we can't detect one already running +pgrep -fx -u "$USER" 'emacs --daemon' >/dev/null || emacs --daemon diff --git a/sh/profile.d/visual.sh b/sh/profile.d/visual.sh index f79158b8..d5280abd 100644 --- a/sh/profile.d/visual.sh +++ b/sh/profile.d/visual.sh @@ -1,24 +1,8 @@ -# If an Emacs is installed, and ~/.emacs exists, use emacs as the visual -# editor; otherwise, use the system's vi -if command -v emacs >/dev/null 2>&1 && - [ -f "$HOME"/.emacs ] ; then - - # Use or start a GNU Emacs client, if possible - if command -v pgrep >/dev/null 2>&1 && - pgrep -fxu "$USER" 'emacs --daemon' >/dev/null || - emacs --daemon 2>/dev/null ; then - VISUAL=emacsclient - - # If no GNU Emacs daemon is available, just create a new instance every - # time - else - VISUAL=emacs - fi - -# If an Emacs isn't installed, just use good old vi +# If my Emacs wrapper is installed, use emacs as the visual editor; otherwise, +# use the system's vi +if command -v emacsm >/dev/null 2>&1 ; then + VISUAL='emacsm' else - VISUAL=vi + VISUAL='vi' fi - -# Export final editor decision export VISUAL -- cgit v1.2.3