Remote Emacs article: Allow spaces in filenames and realpath -m.

This commit is contained in:
tastytea 2019-10-06 21:23:11 +02:00
parent 0693d3a51d
commit 3d33203774
Signed by: tastytea
GPG Key ID: CFC39497F1B26E07
1 changed files with 14 additions and 4 deletions

View File

@ -141,17 +141,25 @@ for p in "${@}"; do
# Use local server, for use with --sudo.
local=1
else
# Setting field separator to newline so that filenames with spaces will
# not be split up into 2 array elements.
OLDIFS=${IFS}
IFS=$'\n'
if [[ $(id -u) -eq 0 || ${sudo} -eq 1 ]]; then
if [[ ${local} -eq 0 ]]; then
params+=( "/ssh:$(hostname -f)|sudo:$(hostname -f):"$(readlink -f ${p}) )
params+=( "/ssh:$(hostname -f)|sudo:$(hostname -f):"$(realpath -m "${p}") )
else
params+=( "/sudo:localhost:"$(readlink -f ${p}) )
params+=( "/sudo:localhost:"$(realpath -m "${p}") )
fi
else
params+=( "/ssh:$(hostname -f):"$(readlink -f ${p}) )
params+=( "/ssh:$(hostname -f):"$(realpath "${p}") )
fi
IFS=${OLDIFS}
fi
done
emacsclient -f ~/.emacs.d/server/server "${params[@]}"
{{< / highlight >}}
----
@ -219,4 +227,6 @@ echo 'Defaults env_keep += "SSH_CONNECTION"' >> /etc/sudoers.d/ssh_vars
== Updates
* Updated on 2019-05-12 to include the `-f` argument for emacsclient.
* Updated 2019-05-12: Add `-f` argument to emacsclient.
* Updated 2019-10-06: Support files with spaces in emacsremote and allow to
open files the user can't read (for use with emacsremote --sudo).