From c501d0f2c6be6f3cdf89d39c8aa6fbdd8ce58c56 Mon Sep 17 00:00:00 2001
From: Kelvin Smith <oneKelvinSmith@gmail.com>
Date: Tue, 31 Mar 2015 21:57:26 +0530
Subject: [PATCH] Add emacs plugin (even more updated)

Incorporate changes after code review of #408
---
 plugins/emacs/emacs.load                    | 12 +++++++++---
 plugins/emacs/functions/__launch_emacs.fish |  4 ++--
 plugins/emacs/functions/ecd.fish            |  1 -
 3 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/plugins/emacs/emacs.load b/plugins/emacs/emacs.load
index bdfc300..41417ff 100644
--- a/plugins/emacs/emacs.load
+++ b/plugins/emacs/emacs.load
@@ -9,7 +9,9 @@ function __major_version
 end
 
 function __set_editor
-  set -q EDITOR; or set -gx EDITOR emacs
+  if not set -q EDITOR
+    set -gx EDITOR emacs
+  end
 end
 
 function __add_functions_to_path
@@ -17,8 +19,12 @@ function __add_functions_to_path
   set fish_function_path $emacs_functions $fish_function_path
 end
 
-set -q __emacs; or set __emacs (which emacs)
-set -q __emacs_version; or set __emacs_version (__major_version $__emacs)
+if not set -q __emacs
+  set __emacs (which emacs)
+end
+if not set -q __emacs_version
+  set __emacs_version (__major_version $__emacs)
+end
 
 if test "$__emacs_version" -gt 23
   __set_editor
diff --git a/plugins/emacs/functions/__launch_emacs.fish b/plugins/emacs/functions/__launch_emacs.fish
index 52e839e..1f23753 100644
--- a/plugins/emacs/functions/__launch_emacs.fish
+++ b/plugins/emacs/functions/__launch_emacs.fish
@@ -1,9 +1,9 @@
 function __launch_emacs
   set -l x (emacsclient --alternate-editor '' --eval '(x-display-list)' 2>/dev/null)
 
-  if begin; test -z "$x"; or test $x = nil; end
+  if test -z "$x" -o "$x" = nil
     emacsclient $argv --alternate-editor '' --create-frame
   else
-    or emacsclient $argv --alternate-editor ''
+    emacsclient $argv --alternate-editor ''
   end
 end
diff --git a/plugins/emacs/functions/ecd.fish b/plugins/emacs/functions/ecd.fish
index 4fcde6a..b0b8978 100644
--- a/plugins/emacs/functions/ecd.fish
+++ b/plugins/emacs/functions/ecd.fish
@@ -7,6 +7,5 @@ function ecd
     echo $dir
   else
     echo 'cannot deduce current buffer filename.' >/dev/stderr
-    return 1
   end
 end
-- 
GitLab