Remove $kak_socket replaced with $kak_session
use /tmp/kak-$kak_session to get the socket path
This commit is contained in:
parent
b080f456a7
commit
3021c7f60a
|
@ -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(); });
|
||||
|
|
|
@ -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 &
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
||||
|
|
|
@ -32,12 +32,12 @@ std::unique_ptr<RemoteClient> connect_to(const String& pid,
|
|||
|
||||
struct Server : public Singleton<Server>
|
||||
{
|
||||
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<FDWatcher> m_listener;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user