branch: elpa/javelin
commit e6de0c3754e04e04ba43c7ccac7e1e8182e68f8e
Author: Otávio Schwanck dos Santos <[email protected]>
Commit: Otávio Schwanck dos Santos <[email protected]>

    Hydra for delete harpoons
---
 README.org  |   5 ++--
 demo.gif    | Bin 4671101 -> 0 bytes
 harpoon.el  |  90 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++---
 harpoon.gif | Bin 0 -> 2033453 bytes
 hydra.png   | Bin 56712 -> 0 bytes
 5 files changed, 88 insertions(+), 7 deletions(-)

diff --git a/README.org b/README.org
index c6af1ab1d9f..19dda35d55c 100644
--- a/README.org
+++ b/README.org
@@ -3,10 +3,9 @@ Harpoon plugin for emacs, based on the plugin from 
[[https://github.com/ThePrime
 
 This plugin offers quick bookmarks separated by project and branch.  You can 
quick navigate between your working files and forget about that files opened 
that you will not use anymore.
 
-Harpoon persists between emacs sessions.
+Harpoon is more a way to manage and quick navigate between the main files that 
you are working on than a bookmark system.
 
-[[file:demo.gif]]
-[[file:hydra.png]]
+[[file:harpoon.gif]]
 
 * Installation
 ** Manual
diff --git a/demo.gif b/demo.gif
deleted file mode 100644
index 69d0d904108..00000000000
Binary files a/demo.gif and /dev/null differ
diff --git a/harpoon.el b/harpoon.el
index 37659c9c93c..c1b82dd6783 100644
--- a/harpoon.el
+++ b/harpoon.el
@@ -157,6 +157,61 @@
         (find-file full-file-name)
       (message "File not found."))))
 
+(defun harpoon--delete (line-number)
+  "Delete an item on harpoon. LINE-NUMBER: Line of item to delete."
+  (harpoon-toggle-file)
+  (goto-char (point-min)) (forward-line (- line-number 1))
+  (kill-whole-line)
+  (save-buffer)
+  (kill-buffer)
+  (harpoon-delete-item))
+
+
+(defun harpoon-delete-1 ()
+  "Delete item harpoon on position 1."
+  (interactive)
+  (harpoon--delete 1))
+
+(defun harpoon-delete-2 ()
+  "Delete item harpoon on position 1."
+  (interactive)
+  (harpoon--delete 2))
+
+(defun harpoon-delete-3 ()
+  "Delete item harpoon on position 1."
+  (interactive)
+  (harpoon--delete 3))
+
+(defun harpoon-delete-4 ()
+  "Delete item harpoon on position 1."
+  (interactive)
+  (harpoon--delete 4))
+
+(defun harpoon-delete-5 ()
+  "Delete item harpoon on position 1."
+  (interactive)
+  (harpoon--delete 5))
+
+(defun harpoon-delete-6 ()
+  "Delete item harpoon on position 1."
+  (interactive)
+  (harpoon--delete 6))
+
+(defun harpoon-delete-7 ()
+  "Delete item harpoon on position 1."
+  (interactive)
+  (harpoon--delete 7))
+
+(defun harpoon-delete-8 ()
+  "Delete item harpoon on position 1."
+  (interactive)
+  (harpoon--delete 8))
+
+(defun harpoon-delete-9 ()
+  "Delete item harpoon on position 1."
+  (interactive)
+  (harpoon--delete 9))
+
 ;;;###autoload
 (defun harpoon-go-to-1 ()
   "Go to file 1 on harpoon."
@@ -229,7 +284,7 @@
   "Open harpoon quick menu with hydra."
   (interactive)
   (require 'hydra)
-  (let ((candidates (harpoon--hydra-candidates)))
+  (let ((candidates (harpoon--hydra-candidates "harpoon-go-to-")))
     (eval `(defhydra harpoon-hydra (:exit t :column 1)
 "
           ||                          ||
@@ -245,20 +300,22 @@
 "
              ,@candidates
              ("SPC" harpoon-toggle-quick-menu "Open Menu" :column "Other 
Actions")
+             ("d" harpoon-delete-item "Delete some harpoon" :column "Other 
Actions")
              ("f" harpoon-toggle-file "Open Harpoon File" :column "Other 
Actions")
              ("c" harpoon-clear "Clear Harpoon" :column "Other Actions")
              ("s" harpoon-add-file "Save Current File to Harpoon" :column 
"Other Actions"))))
 
   (when (fboundp 'harpoon-hydra/body) (harpoon-hydra/body)))
 
-(defun harpoon--hydra-candidates ()
-  "Candidates for hydra."
+
+(defun harpoon--hydra-candidates (method)
+  "Candidates for hydra. METHOD = Method to execute on harpoon item."
   (let ((line-number 0)
         (full-candidates (seq-take (delete "" (split-string 
(harpoon--get-file-text) "\n")) 9)))
     (mapcar (lambda (item)
               (setq line-number (+ 1 line-number))
               (list (format "%s" line-number)
-                    (intern (concat "harpoon-go-to-" (format "%s" 
line-number)))
+                    (intern (concat method (format "%s" line-number)))
                     (harpoon--format-item-name item)
                     :column (if (< line-number 6) "1-5" "6-9")))
             full-candidates)))
@@ -282,6 +339,31 @@ FULL-CANDIDATES = All candidates to look."
         (concat file-base-name " at " (string-join (butlast splitted-item) 
"/"))
       file-base-name)))
 
+
+;;;###autoload
+(defun harpoon-delete-item ()
+  "Delete items on harpoon."
+  (interactive)
+  (let ((candidates (harpoon--hydra-candidates "harpoon-delete-")))
+    (eval `(defhydra harpoon-delete-hydra (:exit t :column 1 :color red)
+             "
+
+   /0000000\\
+   | 00000 |
+   | | | | |
+   | TRASH |
+   | | | | |
+   \\-------/
+
+Select items to delete:
+"
+             ,@candidates
+             ("SPC" harpoon-quick-menu-hydra "Back to harpoon" :column "Other 
Actions")
+             ("q" hydra-keyboard-quit "Quit" :column "Other Actions"))))
+
+  (when (fboundp 'harpoon-delete-hydra/body) (harpoon-delete-hydra/body)))
+
+
 (defun harpoon--get-file-text ()
   "Get text inside harpoon file."
   (if (file-exists-p (harpoon--file-name))
diff --git a/harpoon.gif b/harpoon.gif
new file mode 100644
index 00000000000..874819eaaab
Binary files /dev/null and b/harpoon.gif differ
diff --git a/hydra.png b/hydra.png
deleted file mode 100644
index a98a244a37d..00000000000
Binary files a/hydra.png and /dev/null differ

Reply via email to