aboutsummaryrefslogtreecommitdiff
path: root/sh/profile.d
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2019-01-02 23:29:09 +1300
committerTom Ryder <tom@sanctum.geek.nz>2019-01-02 23:29:09 +1300
commit1c96eaf0b739228c3a2353f3f015d0258e052d03 (patch)
treeb9d64393e8de6ba0d611737cfa283d90f0714e70 /sh/profile.d
parentMerge branch 'release/v4.4.0' (diff)
parentBump VERSION (diff)
downloaddotfiles-1c96eaf0b739228c3a2353f3f015d0258e052d03.tar.gz
dotfiles-1c96eaf0b739228c3a2353f3f015d0258e052d03.zip
Merge branch 'release/v4.5.0'v4.5.0
* release/v4.5.0: Bump VERSION Add some more elementary Emacs configuration Add Emacs settings for message-mode Tidy packages list in .emacs a bit Add emacsclient logic to $VISUAL set Don't edit message headers using Emacs Add new filetype pattern for muttrc
Diffstat (limited to 'sh/profile.d')
-rw-r--r--sh/profile.d/visual.sh24
1 files changed, 20 insertions, 4 deletions
diff --git a/sh/profile.d/visual.sh b/sh/profile.d/visual.sh
index 94aee963..359bf13a 100644
--- a/sh/profile.d/visual.sh
+++ b/sh/profile.d/visual.sh
@@ -1,9 +1,25 @@
-# If emacs is installed, and ~/.emacs exists, use emacs as the visual editor;
-# otherwise, use the system's vi
+# 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
- VISUAL=emacs
+ [ -f "$HOME"/.emacs ] ; then
+
+ # Use or start a GNU Emacs client, if possible
+ if command -v pgrep >/dev/null 2>&1 &&
+ pgrep --exact --full --euid="$USER" \
+ 'emacs --daemon' >/dev/null ||
+ emacs --daemon >/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
else
VISUAL=vi
fi
+
+# Export final editor decision
export VISUAL