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

Suggestion: bring ability to use harpoon.el without a project function #11

Open
Qkessler opened this issue Jun 2, 2023 · 2 comments
Open

Comments

@Qkessler
Copy link

Qkessler commented Jun 2, 2023

Hi there!

Just adding an issue to give feedback on the current state of the customizability of the package. In my opinion, we are opinionated in the way that package users should use it, and we should have as a tenet to bring the most amount of customizability as possible, so the user base grows along with the different workflows supported.

In my case, I use harpoon to move between the files in a single tab from tab-bar.el and that allows me to have the notes on the first file change, and code on the second, to jump back and forth between them. With the current changes (say, fixing the project.el function), I'm not able to do that, and basically it means that I end up using harpoon less, or close to nothing.

As a way to implement it, we could have a defvar or defcustom to actually apply the project finding logic, or instead of enforcing the project functionality, we could just add a variable to be the function that we use for harpoon (similar to the harpoon-without-project-function, but as the default).

We could assign a default value to that function to the project one for now, to avoid any breaking changes, but give the possiblity to override the function used for all the harpooning.

What do you think? Thanks for the package, avid user (until very recently for the reasons I state above).

Best,
Quique.

@betaprior
Copy link

I second this. I often need to bring up org buffers that are not part of a project, and right now I'm not able to do that.

@Qkessler
Copy link
Author

@betaprior As a workaround, I have overwritten the functions that harpoon uses for defining the project root, so it fallbacks to the harpoon-without-project-function that we define. I use use-package but you should be able to pick anything you need from this snippet:

(use-package harpoon
  :elpaca (harpoon :host github :repo "otavioschwanck/harpoon.el")
  :hook (harpoon-mode . auto-revert-mode)
  :init
  (defun qk-tab-bar-get-current-tab-name ())
  (setq
   harpoon-cache-file (concat no-littering-var-directory "harpoon/")
   harpoon-without-project-function 'qk-tab-bar-get-current-tab-name)
  :general
  (+general-global-help
    "c" 'harpoon-clear
    "t" 'harpoon-toggle-file
    "a" 'harpoon-add-file)
  (global-definer
    "'" 'harpoon-go-to-1
    "," 'harpoon-go-to-2
    "." 'harpoon-go-to-3)
  :config
  (defun qk-tab-bar-get-current-tab-name ()
    (alist-get 'name (tab-bar--current-tab)))
  (defun harpoon-project-root-function () nil)
  (defun harpoon--has-project () nil))

If we place the functions we need on the :config property, we override the functions after initializing them, and it works.

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