keepass.el - quickly copy KeePass passwords to the kill ring reddit / emacs ---------------------------------------------------------------------- taygrinn · 2022-11-03 01:49 ​ https://i.redd.it/rqc61oyr2nx91.gif [keepass.el](https://gitlab.com/tay-dev/keepass.el) provides a quick method of retrieving KeePass passwords within Emacs. ---------------------------------------------------------------------- FrozenOnPluto · 2022-11-03 02:18 Slick, I was looking for something like this a few months back. Thanks! ---------------------------------------------------------------------- KirmTwinty · 2022-11-03 05:21 I did something similar a while ago. However I couldn't manage to have a secure way to handle passwords safely within Emacs (like removing them from the kill-ring after a while). Did you or do the passwords stay in the history ? Nice job anyway! ---------------------------------------------------------------------- deaddyfreddy · 2022-11-03 10:29 Cool stuff! Some thoughts: - I think it's possible to generate password getter functions in runtime, bind them to keys and optionally use `which-key` to show bindings/names. - `hydra` could be another alternative solution P.S. Using `when` instead of `if` when there's only one branch is more idiomatic. ---------------------------------------------------------------------- taygrinn · 2022-11-03 12:54 Yes indeed! It also disables the clipboard temporarily so the password is only available within Emacs. ---------------------------------------------------------------------- taygrinn · 2022-11-03 13:07 Thanks! I considered hydra but in the end read-char-choice does everything I need. 'when' just calls 'if' under the hood, and I don't think one is more idiomatic than the other. ---------------------------------------------------------------------- deaddyfreddy · 2022-11-03 13:31 > read-char-choice does everything I need The problem is `read-char-choice` is a bit low-level, comparing to `define-key`, so when you implement your own wraparound, there can be possible pitfalls. I maintain a package, which worked great for keymaps, but for `read-char`-based "bindings" I had to implement advice workarounds. I'm not talking "it's not good to use it", just warning that in theory there can be issues (or they can't). > 'when' just calls 'if' under the hood, and I don't think one is more idiomatic than the other. https://www.gnu.org/software/emacs/manual/html_node/elisp/Conditionals .html#index-when it doesn't bar `if`, for sure, but `when` explicitly signals "here's side-effects happening!", so semantically it's different from `if`. After all, you're using `when` in other places already :) ---------------------------------------------------------------------- KirmTwinty · 2022-11-03 14:02 Nice! I Will give it a try 😀 ---------------------------------------------------------------------- taygrinn · 2022-11-03 20:00 I'm sorry Freddy I have to disagree on both counts. read-char-choice isn't exactly low-level, it's written in elisp and relies on read-key, which in turn relies on define-key. I'm curious to know what problems you've experienced with it though. Neither 'if' nor 'when' declare themselves side-effect free, and I don't believe they are semantically different in any way. ---------------------------------------------------------------------- faldborg · 2022-11-03 20:34 I made something similar last year because I wanted to use keepass as an auth source: https://github.com/fishbacon/keepass-auth-source It is only barely usable but it works for what I need. ---------------------------------------------------------------------- deaddyfreddy · 2022-11-03 22:59 > read-char-choice isn't exactly low-level, it's written in elisp and relies on read-key, which in turn relies on define-key. I checked the code, you are absolutely right here! > I'm curious to know what problems you've experienced with it though not with `read-char-choice`, but with `read-char` > Neither 'if' nor 'when' declare themselves side-effect free I was talking that `when` is traditionally used specifically for side- effects (so the else branch doesn't matter). > I don't believe they are semantically different in any way. what's the reason to have both in this case? ---------------------------------------------------------------------- taygrinn · 2022-11-04 00:03 That's really cool! However, I see that the master password is being passed in as a command line argument, which is visible by other processes. [I used process-send-string](https://gitlab.com/tay-dev/kee pass.el/- /blob/5a8ab5eb9676e97ab4a7d97a1efa0d69b67c562c/keepass.el#L351) in order to get around this, but I'm not sure it'll work with KPScript (I'm using keepassxc-cli). ---------------------------------------------------------------------- taygrinn · 2022-11-04 00:09 It's just a convenience function, like unless. I don't think it has anything to do with side effects. ---------------------------------------------------------------------- deaddyfreddy · 2022-11-04 00:18 some links https://www.emacswiki.org/emacs/WhenToUseIf https://google.github.io/styleguide/lispguide.xml?showone=Conditional_ Expressions#Conditional_Expressions https://emacs.stackexchange.com/questions/14195/and-vs-when-for- conditionals/14204#14204 ---------------------------------------------------------------------- taygrinn · 2022-11-04 01:41 At best, it's a convention. In my opinion it's meaningless. `(progn (expression))` is semantically equivalent to `(expression)`. The last expression in a 'when' is not a side effect (only), just like the first expression in an 'if'. With only one expression, they are equivalent. The discussion of 'when' and 'and' is a slightly different matter. ---------------------------------------------------------------------- faldborg · 2022-11-04 15:49 Dunno how `process-send-string` works I just stuck with what I know :) Back when I made it I was planning on also doing a keepassxc version using their extension protocol, but I got side-tracked by rewriting my non-public sharepoint project management package.