purcell / whole-line-or-region

In Emacs, operate on current line if no region is active
114 stars 12 forks source link

Issue in emms mode #7

Open Ergus opened 5 years ago

Ergus commented 5 years ago

Hi: I am using the package since some months ago and it works pretty well. But I have tried some modes where the default bindings are associated to different functions (like emms-playlist for example) and there are issues because those buffers are read-only for the default copy/yank functions because they have other functions to do so.

I think that somehow this could be fixed changing the current approach to instead of making function-wrappers for those functions, use elisp-functions advices instead and get the functions to call from the keybinds with Key Lookup.

https://www.gnu.org/software/emacs/manual/html_node/elisp/Functions-for-Key-Lookup.html https://www.gnu.org/software/emacs/manual/html_node/elisp/Advising-Functions.html

This could be useful to simplify all the package indeed.

purcell commented 5 years ago

You haven't really clearly explained what's not working for you, so I'm not sure how to help with this yet, sorry.

Ergus commented 5 years ago

In some modes like emms the C-y C-w (and others) bindings are associated to different commands (emms-playlist-mode-kill and emms-playlist-mode-yank in this specific case). Using those bindings with the WLOR global mode gives errors because those buffers are readonly and can be modified only throw its special functions. The workaround I have now is to add a hook to disable WLOR in the problematic modes, but this is in fact a dirty solution, and it is not scalable at all, specially for newer users. Looking to what the WLOR functions do it could be interesting to consider add an advice for the default functions so the alternative modes will not have issues, but also people using godmode, ergoemacs and related modes will not have issues and will be allowed to use the package out of the box.

purcell commented 5 years ago

Thanks for the explanation! I agree this case isn't handled well currently, and I'll think about options for fixing it. advice isn't a viable option, since advising key built-in functions like kill-region can break all sorts of code. But certainly the keymaps could be created and installed in a better way.