Skip to content

Commit

Permalink
Add eaf-file-manager-run-command-for-mark-files, eaf-file-manager-com…
Browse files Browse the repository at this point in the history
…press-file and eaf-file-manager-uncompress-file
  • Loading branch information
manateelazycat committed Feb 26, 2022
1 parent 40efa08 commit a792582
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 0 deletions.
10 changes: 10 additions & 0 deletions README.md
Expand Up @@ -29,6 +29,8 @@ File manager application for the [Emacs Application Framework](https://github.co

### The keybinding of EAF File Manager.

### The keybinding of EAF File Manager.

| Key | Event |
| :---- | :------ |
| `<f12>` | open_devtools |
Expand Down Expand Up @@ -81,5 +83,13 @@ File manager application for the [Emacs Application Framework](https://github.co
| `.` | js_preview_scroll_down_line |
| `<` | js_preview_scroll_up |
| `>` | js_preview_scroll_down |
| `1` | sort_by_name |
| `2` | sort_by_size |
| `3` | sort_by_modified_time |
| `4` | sort_by_created_time |
| `5` | sort_by_access_time |
| `!` | eaf-file-manager-run-command-for-mark-files |
| `z` | eaf-file-manager-compress-file |
| `Z` | eaf-file-manager-uncompress-file |
| `C-s` | search_file |

10 changes: 10 additions & 0 deletions buffer.py
Expand Up @@ -687,6 +687,16 @@ def delete_file(self, file_info):

def vue_get_mark_files(self):
return list(filter(lambda file: file["mark"] == "mark", self.vue_files)).copy()

def get_mark_file_names(self):
return list(map(lambda file: file["path"], self.vue_get_mark_files()))

def get_select_file_name(self):
current_file = self.vue_get_select_file()
if current_file != None:
return current_file["path"]
else:
return ""

def vue_get_file_next_to_last_mark(self):
mark_indexes = []
Expand Down
34 changes: 34 additions & 0 deletions eaf-file-manager.el
Expand Up @@ -113,6 +113,9 @@
("3" . "sort_by_modified_time")
("4" . "sort_by_created_time")
("5" . "sort_by_access_time")
("!" . "eaf-file-manager-run-command-for-mark-files")
("z" . "eaf-file-manager-compress-file")
("Z" . "eaf-file-manager-uncompress-file")
("C-s" . "search_file")
)
"The keybinding of EAF File Manager."
Expand Down Expand Up @@ -298,6 +301,37 @@
(t
(eaf-open (file-truename default-directory) "file-manager")))))

(defun eaf-file-manager-run-command-for-mark-files ()
(interactive)
(let ((mark-files (eaf-call-sync "execute_function" eaf--buffer-id "get_mark_file_names")))
(cond ((<= (length mark-files) 0)
(message "No file selected"))
(t
(let ((command (read-string "Run command: ")))
(when command
(shell-command (format "%s %s" command (string-join mark-files " ")))))))))

(defun eaf-file-manager-compress-file ()
(interactive)
(let* ((mark-files (eaf-call-sync "execute_function" eaf--buffer-id "get_mark_file_names"))
(file-string (if (> (length mark-files) 0)
(string-join mark-files " ")
(eaf-call-sync "execute_function" eaf--buffer-id "get_select_file_name")
)))

(if (string-equal file-string "")
(message "No file need to compress.")
(let ((file-name (read-string "Compress file name: ")))
(when file-name
(shell-command (format "tar -zcvf %s.tar.gz %s" file-name file-string)))))))

(defun eaf-file-manager-uncompress-file ()
(interactive)
(let* ((current-file (eaf-call-sync "execute_function" eaf--buffer-id "get_select_file_name")))
(if (string-equal current-file "")
(message "No file in current directory.")
(shell-command (format "tar -xvf %s" current-file)))))

(provide 'eaf-file-manager)

;;; eaf-file-manager.el ends here

0 comments on commit a792582

Please sign in to comment.