branch: elpa/javelin
commit a2e3bf2f4e4df7d6490f0d8b08357e2526c90477
Author: Damian Barabonkov <[email protected]>
Commit: Damian Barabonkov <[email protected]>
feat: Add go-or-assign-to functionality
---
harpoon.el | 101 +++++++++++++++++++++++++++++++++++++++++++++++++------------
1 file changed, 81 insertions(+), 20 deletions(-)
diff --git a/harpoon.el b/harpoon.el
index 847a1affc7d..868d72552b4 100644
--- a/harpoon.el
+++ b/harpoon.el
@@ -208,7 +208,7 @@ Returns the relative path if in a project, otherwise the
absolute path."
(file-relative-name (buffer-file-name) project-root)
(buffer-file-name))))
-;;; --- Generic harpoon functions ---
+;;; --- Go-to functions ---
;;;###autoload
(defun harpoon-go-to (harpoon-number)
@@ -227,25 +227,6 @@ Returns the relative path if in a project, otherwise the
absolute path."
(t
(message "%s not found." full-file-name)))))
-;;;###autoload
-(defun harpoon-delete (harpoon-number)
- "Delete an item on harpoon. HARPOON-NUMBER: Position to delete."
- (harpoon--remove-filepath-by-position harpoon-number)
- (message "Deleted harpoon position %d" harpoon-number))
-
-
-;;;###autoload
-(defun harpoon-assign-to (harpoon-number)
- "Assign the current buffer to a specific position in harpoon.
-HARPOON-NUMBER: The position (1-9) to assign the current file to."
- (let ((file-to-add (harpoon--buffer-filepath-relative-to-root)))
- (harpoon--set-filepath-by-position harpoon-number file-to-add)
- (message "Assigned %s to harpoon position %d" file-to-add harpoon-number)))
-
-;;; --- Generic harpoon functions ---
-
-;;; --- Go-to functions ---
-
;;;###autoload
(defun harpoon-go-to-1 ()
"Go to file 1 on harpoon."
@@ -304,6 +285,12 @@ HARPOON-NUMBER: The position (1-9) to assign the current
file to."
;;; --- Delete functions ---
+;;;###autoload
+(defun harpoon-delete (harpoon-number)
+ "Delete an item on harpoon. HARPOON-NUMBER: Position to delete."
+ (harpoon--remove-filepath-by-position harpoon-number)
+ (message "Deleted harpoon position %d" harpoon-number))
+
;;;###autoload
(defun harpoon-delete-1 ()
"Delete item harpoon on position 1."
@@ -362,6 +349,14 @@ HARPOON-NUMBER: The position (1-9) to assign the current
file to."
;;; --- Assign to functions ---
+;;;###autoload
+(defun harpoon-assign-to (harpoon-number)
+ "Assign the current buffer to a specific position in harpoon.
+HARPOON-NUMBER: The position (1-9) to assign the current file to."
+ (let ((file-to-add (harpoon--buffer-filepath-relative-to-root)))
+ (harpoon--set-filepath-by-position harpoon-number file-to-add)
+ (message "Assigned %s to harpoon position %d" file-to-add harpoon-number)))
+
;;;###autoload
(defun harpoon-assign-to-1 ()
"Assign current buffer to position 1 on harpoon."
@@ -418,6 +413,72 @@ HARPOON-NUMBER: The position (1-9) to assign the current
file to."
;;; --- Assign to functions ---
+;;;###autoload
+(defun harpoon-go-or-assign-to (harpoon-number)
+ "Go to harpoon position if occupied, otherwise assign current buffer to it.
+HARPOON-NUMBER: The position (1-9) to go to or assign."
+ (if (harpoon--get-filepath-by-position harpoon-number)
+ (harpoon-go-to harpoon-number)
+ (harpoon-assign-to harpoon-number)))
+
+;;; --- Go or assign to functions ---
+
+;;;###autoload
+(defun harpoon-go-or-assign-to-1 ()
+ "Go to position 1 if occupied, otherwise assign current buffer to it."
+ (interactive)
+ (harpoon-go-or-assign-to 1))
+
+;;;###autoload
+(defun harpoon-go-or-assign-to-2 ()
+ "Go to position 2 if occupied, otherwise assign current buffer to it."
+ (interactive)
+ (harpoon-go-or-assign-to 2))
+
+;;;###autoload
+(defun harpoon-go-or-assign-to-3 ()
+ "Go to position 3 if occupied, otherwise assign current buffer to it."
+ (interactive)
+ (harpoon-go-or-assign-to 3))
+
+;;;###autoload
+(defun harpoon-go-or-assign-to-4 ()
+ "Go to position 4 if occupied, otherwise assign current buffer to it."
+ (interactive)
+ (harpoon-go-or-assign-to 4))
+
+;;;###autoload
+(defun harpoon-go-or-assign-to-5 ()
+ "Go to position 5 if occupied, otherwise assign current buffer to it."
+ (interactive)
+ (harpoon-go-or-assign-to 5))
+
+;;;###autoload
+(defun harpoon-go-or-assign-to-6 ()
+ "Go to position 6 if occupied, otherwise assign current buffer to it."
+ (interactive)
+ (harpoon-go-or-assign-to 6))
+
+;;;###autoload
+(defun harpoon-go-or-assign-to-7 ()
+ "Go to position 7 if occupied, otherwise assign current buffer to it."
+ (interactive)
+ (harpoon-go-or-assign-to 7))
+
+;;;###autoload
+(defun harpoon-go-or-assign-to-8 ()
+ "Go to position 8 if occupied, otherwise assign current buffer to it."
+ (interactive)
+ (harpoon-go-or-assign-to 8))
+
+;;;###autoload
+(defun harpoon-go-or-assign-to-9 ()
+ "Go to position 9 if occupied, otherwise assign current buffer to it."
+ (interactive)
+ (harpoon-go-or-assign-to 9))
+
+;;; --- Go or assign to functions ---
+
;;;###autoload
(defun harpoon-go-to-next ()
"Go to the next file in harpoon."