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

Missing harpoon next/previous #7

Open
jakestrahm opened this issue Aug 3, 2022 · 4 comments
Open

Missing harpoon next/previous #7

jakestrahm opened this issue Aug 3, 2022 · 4 comments

Comments

@jakestrahm
Copy link

Is there any plans to add nav_next() like in harpoon? I had bound M to next , to quickly cycle through harpoons and i can't replicate this in this package.

@otavioschwanck
Copy link
Owner

This harpoon doesn't have this feature. Feel free to submit a PR, the logic behind is:

  • see if current file is in harpoon list, if is:

get the line number on harpoon
go to file on next line if exists, if not, go to first harpoon

  • if current file is not on harpoon go to first item in harpoon if exists

@vansoest
Copy link

+1

@MirkoHernandez
Copy link

I've recently been using harpoon, great package, I really like how it integrates with project.el and how it complements activities.el.
Here are some functions that I've been using for moving between harpoon buffers, maybe something similar could be integrated into harpoon. The convention is if not in an harpoon buffer move to the first one on the list.

(defun my/harpoon-next-buffer ()
  (interactive)
  (let* ((harpoon-files-array (cl-map 'vector 'identity  (split-string (harpoon--get-file-text))))
	 (array-length  (length harpoon-files-array))
	 (current-position (cl-position  (harpoon--buffer-file-name)
					 harpoon-files-array :test 'equal))
	 (new-position (and current-position
			    (if (= (1+ current-position) array-length)
				0
			      (1+ current-position)))))
    (when (> array-length 0)
      (if new-position
	  (harpoon-go-to
	   (+ 1 new-position))
	(harpoon-go-to 1)))))

(defun my/harpoon-previous-buffer ()
  (interactive)
  (let* ((harpoon-files-array (cl-map 'vector 'identity  (split-string (harpoon--get-file-text))))
	 (array-length  (length harpoon-files-array))
	 (current-position (cl-position  (harpoon--buffer-file-name)
					 harpoon-files-array :test 'equal))
	 (new-position (and current-position
			    (if (< (1- current-position) 0)
				(- array-length 1)
			      (1- current-position)))))
    (when (> array-length 0)
      (if new-position
	  (harpoon-go-to
	   (+ 1 new-position))
	(harpoon-go-to 1)))))

@malbertzard
Copy link
Contributor

#13 I added a pull request with my implementation. Maybe if the maintainer wants to it will get merged

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

5 participants