bmag / emacs-purpose

Manage Windows and Buffers According to Purposes
GNU General Public License v3.0
496 stars 23 forks source link

feat: add compatibility with counsel #147

Closed codesuki closed 5 years ago

codesuki commented 5 years ago

This small change lets me use counsel together with purpose. Would be helpful if that could be incorporated into upstream so I don't have to use my own fork.

coveralls commented 5 years ago

Coverage Status

Coverage increased (+0.07%) to 70.057% when pulling 5e0fb506915f884d35fed6e41785385ec440b17a on codesuki:counsel into fb649bb07de63a70ecdace464eadcaafe01e1995 on bmag:master.

bmag commented 5 years ago

I don't really like this PR, because it changes what purpose-ido-caller without changing its name and documentation accordingly.

Besides, you should already be able to use Purpose and Counsel together. Use the ivy-purpose package and/or change the keybindings in purpose-mode-map, e.g. (define-key purpose-mode-map (kbd "C-x b") nil).

codesuki commented 5 years ago

Agree about the docs. Thought I send a draft version and fix it up in case you accept it. I think the ivy-purpose-package is doing something slightly different, will try the keybindings approach. Thanks.

bmag commented 5 years ago

Thought I send a draft version and fix it up in case you accept it.

That's fair, but would be better to state this when opening the PR so I know when I review it.

codesuki commented 5 years ago

So after thinking more about the above and looking at the ivy-purpose package, I think what I want to accomplish is different. I use counsel instead of ido so I want the same behavior (open file with counsel and purpose or with counsel but without purpose on C-u) If I fix the docs and function name would you reconsider the PR given the functionality?

bmag commented 5 years ago

There's a better option than changing ido-caller. Here is how to define a command with similar behavior: (ivy-switch-buffer-without-purpose is from ivy-purpose)

(define-purpose-prefix-overload switch-buffer-overload
  '(ivy-switch-buffer ivy-switch-buffer-without-purpose ivy-purpose-switch-buffer-with-purpose))

This won't replace the keybinding of purpose-switch-buffer-overload in purpose-mode-map (C-x b). If you want that:

(define-key purpose-mode-map [remap purpose-switch-buffer-overload] 'switch-buffer-overload)

I'd accept a PR to ivy-purpose that adds something like this. Maybe with better names or other functions. Using counsel is also ok but requires a bit more work, and I'm not sure it has advantages over plain ivy in our case.