changeset 578:7948fb9d0ced

If first file isn't owned by user - open it in TRAMP sudo.
author Oleksandr Gavenko <gavenkoa@gmail.com>
date Wed, 07 Jan 2015 23:33:54 +0200
parents c903e43d0e1a
children be9c2fb5dbde
files emacs/e emacs/e.1
diffstat 2 files changed, 9 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/emacs/e	Mon Sep 29 10:19:58 2014 +0300
+++ b/emacs/e	Wed Jan 07 23:33:54 2015 +0200
@@ -22,6 +22,11 @@
 if [ -n "$COMSPEC" ]; then
   # We probably under Windows like OS. I like native Emacs over Cygwin.
   exec emacsclientw -a emacs -n -- "$@"
-else
-  exec emacsclient -a emacs -n -- "$@"
 fi
+
+f=`readlink -f "$1"`
+if [ -e "$f" -a `stat -c %U "$f"` != $USER ] || [ -e "${f%/*}" -a `stat -c %U "${f%/*}"` != $USER ]; then
+    shift
+    exec emacsclient -a emacs -n -- "/sudo::$f" "$@"
+fi
+exec emacsclient -a emacs -n -- "$@"
--- a/emacs/e.1	Mon Sep 29 10:19:58 2014 +0300
+++ b/emacs/e.1	Wed Jan 07 23:33:54 2015 +0200
@@ -33,6 +33,8 @@
 
 Both start Emacs if it is not already running through "-a emacs" option.
 
+If first file isn't owned by user - open it in TRAMP sudo.
+
 Under Cygwin native Emacs being used.
 .SH OPTIONS
 .IP --help