akhayyat/dotfiles

Conditional emacs support

Commit 23497347cda0 · Ahmad Khayyat · 2026-06-21 07:44 +0300

Changeset
23497347cda0c6e62103c75028e9b7817c3d9500

View source at this commit

Comments

No comments yet.

Log in to comment

Diff

diff --git a/zsh/programs.zsh b/zsh/programs.zsh
--- a/zsh/programs.zsh
+++ b/zsh/programs.zsh
@@ -9,20 +9,21 @@
 fi
 
 # Emacs
-alias e="emacsclient -a '' -t"
-alias ew="emacsclient -a '' -c --no-wait"
-
-ediff() {
-    if (($+2)); then
-        emacs --eval "(ediff-files \"$1\" \"$2\")"
-    else
-        echo "Usage: ediff <file-1> <file-2>"
-    fi
-}
-
-# EDITOR
-export EDITOR="emacsclient -a '' -t"
-export VISUAL="emacsclient -a '' -t"
+if [ -x "$(which emacsclient)" ]; then
+    alias e="emacsclient -a '' -t"
+    alias ew="emacsclient -a '' -c --no-wait"
+    export EDITOR="emacsclient -a '' -t"
+    export VISUAL="emacsclient -a '' -t"
+fi
+if [ -x "$(which emacs)" ]; then
+    ediff() {
+        if (($+2)); then
+            emacs --eval "(ediff-files \"$1\" \"$2\")"
+        else
+            echo "Usage: ediff <file-1> <file-2>"
+        fi
+    }
+fi
 
 # Apt
 upd() {