diff --git a/content/posts/Editing-remote-files-with-emacs-comfortably.adoc b/content/posts/Editing-remote-files-with-emacs-comfortably.adoc index f53a493..9793661 100644 --- a/content/posts/Editing-remote-files-with-emacs-comfortably.adoc +++ b/content/posts/Editing-remote-files-with-emacs-comfortably.adoc @@ -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).