jixiuf / vterm-toggle

toggles between the vterm buffer and whatever buffer you are editing.
GNU General Public License v3.0
188 stars 12 forks source link

Allow buffer name customization #34

Closed kautsig closed 2 years ago

kautsig commented 2 years ago

Hi,

first, thanks for this very nice package, I appropriate it a lot. :smiley:

I had the following use case: I want my vterm buffer names to contain a the projectile project name.

This would have following benefits for me:

I extracted the use of vterm-buffer-name into a function call and added an additional configuration parameter vterm-toggle-buffer-name-fn which can be set to a function providing the buffer name.

This allows me to supply my own buffer name function matching the projectile behavior, while keeping backwards compatibility.

    (defun my/vterm-toggle-buffer-name ()
      (if (projectile-project-root)
          (projectile-generate-process-name "vterm" nil (projectile-acquire-root))
        vterm-buffer-name))
    (setq vterm-toggle-buffer-name-fn 'my/vterm-toggle-buffer-name)

I am not super fluent in elisp, so please bear with me.

Please let me know if such a change is fine for you and if I can change anything to make the code more idiomatic or better fitting into the project.

Thanks, Chris

kautsig commented 2 years ago

I noticed that my user supplied function pops up a projectile project selection when used in a non-projectile file.

This is part of the my customization code, I will work on that and provide an update. The PR itself is not affected by that.

kautsig commented 2 years ago

I noticed that my user supplied function pops up a projectile project selection when used in a non-projectile file.

I fixed the customization code in the PR by checking for a non-nil projectile-project-root first.

kautsig commented 2 years ago

I figured out i could achieve the same functionality by re-binding vterm-buffer-name in my custom function, can call vterm-toggle.

So this change is obsolete. Sorry for the noise.