Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make BufCreate/BufOpen run in the parent context #915

Open
kurkale6ka opened this issue Nov 4, 2016 · 3 comments
Open

Make BufCreate/BufOpen run in the parent context #915

kurkale6ka opened this issue Nov 4, 2016 · 3 comments

Comments

@kurkale6ka
Copy link
Contributor

kurkale6ka commented Nov 4, 2016

This would allow the following to work (open a file where I left):

Initial setup:

mkdir -p $XDG_DATA_HOME/kakoune

sqlite3 $XDG_DATA_HOME/kakoune/info.db << 'INIT'
CREATE TABLE recent (
  file VARCHAR(200) UNIQUE,
  pos VARCHAR(20),
  stamp INTEGER
);

CREATE INDEX _file ON recent (file);
INIT

In kakrc:

hook global BufWritePre .* %{

    %sh{ sqlite3 $XDG_DATA_HOME/kakoune/info.db "INSERT or REPLACE into recent (file, pos, stamp) values ('$kak_buffile', '$kak_selections_desc', strftime('%s', 'now'));" }
}

hook global BufOpen .* %{

    %sh{
    if [ -f "$kak_buffile" ]
    then
        selections=$(sqlite3 "$XDG_DATA_HOME"/kakoune/info.db "SELECT pos from recent where file = '$kak_buffile';")
        [ -n "$selections" ] && printf '%s\n' "select $selections"
    fi
    }
}
@lenormf
Copy link
Contributor

lenormf commented Nov 4, 2016

What's "not working" in the code you gave?

@kurkale6ka
Copy link
Contributor Author

Quote from @mawww:

and if you were using WinCreate, that does not run in
the client context (unfortunately), so you wont be
modifying the actual user selections

@lenormf
Copy link
Contributor

lenormf commented Nov 4, 2016

Ok the issue is with selections, can't you use kak -p or the eval -client ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants