branch: elpa/javelin
commit 631354f24c0bd56daaf8ab613d695c4f1d57949a
Merge: 2c384accad8 89c10401ae6
Author: Otávio Schwanck dos Santos <[email protected]>
Commit: GitHub <[email protected]>
Merge pull request #13 from malbertzard/master
Adding go to next and go to prev Command
---
README.org | 1 +
harpoon.el | 20 ++++++++++++++++++++
2 files changed, 21 insertions(+)
diff --git a/README.org b/README.org
index 22f9e4a90cb..cc9c950387c 100644
--- a/README.org
+++ b/README.org
@@ -25,6 +25,7 @@ Add to package.el:
- Add, order and delete harpoons in your code.
- Harpoon is separated by project and branch
- Quick switch between harpoons
+- Jump between last and previous entries
* Configuring
Example of how to set the shortcuts:
diff --git a/harpoon.el b/harpoon.el
index 5acb46dd352..1fa67af1885 100644
--- a/harpoon.el
+++ b/harpoon.el
@@ -281,6 +281,26 @@
(interactive)
(harpoon-go-to 9))
+;;;###autoload
+(defun harpoon-go-to-next ()
+ "Go to the next file in harpoon."
+ (interactive)
+ (let* ((files (delete "" (split-string (harpoon--get-file-text) "\n")))
+ (current-file (harpoon--buffer-file-name))
+ (current-index (or (cl-position current-file files :test 'string=)
-1))
+ (next-index (mod (+ current-index 1) (length files))))
+ (harpoon-go-to (1+ next-index))))
+
+;;;###autoload
+(defun harpoon-go-to-prev ()
+ "Go to the previous file in harpoon."
+ (interactive)
+ (let* ((files (delete "" (split-string (harpoon--get-file-text) "\n")))
+ (current-file (harpoon--buffer-file-name))
+ (current-index (or (cl-position current-file files :test 'string=)
-1))
+ (prev-index (mod (+ current-index (length files) -1) (length files))))
+ (harpoon-go-to (1+ prev-index))))
+
;;;###autoload
(defun harpoon-add-file ()
"Add current file to harpoon."