diff --git a/src/main.cc b/src/main.cc index ddefdcd6..a77eda66 100644 --- a/src/main.cc +++ b/src/main.cc @@ -90,9 +90,9 @@ void register_env_vars() shell_manager.register_env_var("reg_.+", [](const String& name, const Context& context) { return RegisterManager::instance()[name[4]].values(context)[0]; }); - shell_manager.register_env_var("socket", + shell_manager.register_env_var("session", [](const String& name, const Context& context) - { return Server::instance().filename(); }); + { return Server::instance().session(); }); shell_manager.register_env_var("client", [](const String& name, const Context& context) { return context.client().name(); }); diff --git a/src/rc/clang.kak b/src/rc/clang.kak index 70e8b6dc..5cb4647a 100644 --- a/src/rc/clang.kak +++ b/src/rc/clang.kak @@ -23,7 +23,7 @@ def clang-complete %{ for cmp in ${output}; do completions="${completions}:${cmp}" done - echo "eval -client $kak_client %[ echo completed; setb completions '${completions}' ]" | socat -u stdin UNIX-CONNECT:${kak_socket} + echo "eval -client $kak_client %[ echo completed; setb completions '${completions}' ]" | socat -u stdin UNIX-CONNECT:/tmp/kak-${kak_session} ) >& /dev/null < /dev/null & } } diff --git a/src/rc/client.kak b/src/rc/client.kak index 234c8353..067ccb3c 100644 --- a/src/rc/client.kak +++ b/src/rc/client.kak @@ -8,6 +8,6 @@ decl str termcmd %sh{ def new -shell-params %{ nop %sh{ if (( $# != 0 )); then kakoune_params="-e '$@'"; fi - ${kak_opt_termcmd} "kak -c ${kak_socket#/tmp/kak-} ${kakoune_params}" < /dev/null >& /dev/null & + ${kak_opt_termcmd} "kak -c ${kak_session} ${kakoune_params}" < /dev/null >& /dev/null & disown }} diff --git a/src/rc/git-tools.kak b/src/rc/git-tools.kak index 57c0dc4f..c28c1070 100644 --- a/src/rc/git-tools.kak +++ b/src/rc/git-tools.kak @@ -41,7 +41,7 @@ def -shell-params git %{ %sh{ echo "eval -client '$kak_client' %{ try %{ addhl flag_lines magenta git_blame_flags } catch %{} setb -buffer '$kak_bufname' git_blame_flags '' - }" | socat -u stdin UNIX-CONNECT:${kak_socket} + }" | socat -u stdin UNIX-CONNECT:/tmp/kak-${kak_session} declare -A authors declare -A dates send_flags() { @@ -51,7 +51,7 @@ def -shell-params git %{ %sh{ for (( i=1; $i < $count; i++ )); do flag="$flag:$(($line+$i))|black|$text" done - echo "setb -add -buffer '$kak_bufname' git_blame_flags %{${flag}}" | socat -u stdin UNIX-CONNECT:${kak_socket} + echo "setb -add -buffer '$kak_bufname' git_blame_flags %{${flag}}" | socat -u stdin UNIX-CONNECT:/tmp/kak-${kak_session} } git blame --incremental $kak_bufname | ( while read blame_line; do if [[ $blame_line =~ ([0-9a-f]{40}).([0-9]+).([0-9]+).([0-9]+) ]]; then diff --git a/src/remote.cc b/src/remote.cc index 586b18bb..38ed1b05 100644 --- a/src/remote.cc +++ b/src/remote.cc @@ -508,20 +508,21 @@ private: FDWatcher m_socket_watcher; }; -Server::Server(const String& session_name) - : m_filename{"/tmp/kak-" + session_name} +Server::Server(String session_name) + : m_session{std::move(session_name)} { + String filename = "/tmp/kak-" + m_session; int listen_sock = socket(AF_UNIX, SOCK_STREAM, 0); fcntl(listen_sock, F_SETFD, FD_CLOEXEC); sockaddr_un addr; addr.sun_family = AF_UNIX; - strncpy(addr.sun_path, m_filename.c_str(), sizeof(addr.sun_path) - 1); + strncpy(addr.sun_path, filename.c_str(), sizeof(addr.sun_path) - 1); if (bind(listen_sock, (sockaddr*) &addr, sizeof(sockaddr_un)) == -1) - throw runtime_error("unable to bind listen socket " + m_filename); + throw runtime_error("unable to bind listen socket " + filename); if (listen(listen_sock, 4) == -1) - throw runtime_error("unable to listen on socket " + m_filename); + throw runtime_error("unable to listen on socket " + filename); auto accepter = [](FDWatcher& watcher) { sockaddr_un client_addr; @@ -538,7 +539,7 @@ Server::Server(const String& session_name) Server::~Server() { - unlink(m_filename.c_str()); + unlink(("/tmp/kak-" + m_session).c_str()); close(m_listener->fd()); } diff --git a/src/remote.hh b/src/remote.hh index 189eb0c1..309770da 100644 --- a/src/remote.hh +++ b/src/remote.hh @@ -32,12 +32,12 @@ std::unique_ptr connect_to(const String& pid, struct Server : public Singleton { - Server(const String& session_name); + Server(String session_name); ~Server(); - const String& filename() const { return m_filename; } + const String& session() const { return m_session; } private: - String m_filename; + String m_session; std::unique_ptr m_listener; };