-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpbui-standard-commands.el
101 lines (80 loc) · 3.62 KB
/
pbui-standard-commands.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
;;; pbui-standard-commands.el --- Standard commands for PBUI -*- lexical-binding: t -*-
;; Copyright (C) 2021 Mariano Montone
;; Author: Mariano Montone <marianomontone@gmail.com>
;; URL: https://github.com/mmontone/pbui
;; Keywords: user-interface
;; Version: 0.1
;; Package-Requires: ((emacs "25") (dash "2.19.1"))
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;; A set of standard commands for PBUI.
;;; Code:
(require 'pbui)
(def-presentation-command (standard-commands:open-files
:title "Open file(s)"
:description "Open file(s) in a new buffer")
((files file))
(dolist (file files)
(find-file file)))
(def-presentation-command (standard-commands:delete-files
:title "Delete file(s)"
:description "Delete file(s)")
((files file))
(when (yes-or-no-p (format "Delete the %d selected files?" (length files)))
(dolist (file files)
(delete-file file))
(message (format "%d files deleted" (length files)))))
(def-presentation-command (standard-commands:copy-files-to-directory
:title "Copy file(s) to directory"
:description "Copy file(s) to directory")
((files file) (dir directory))
(dolist (file files)
(copy-file file
(file-name-concat dir (file-name-nondirectory file))))
(message (format "%d files copied to %s" (length files) dir)))
(def-presentation-command (standard-commands:move-files-to-directory
:title "Move file(s) to directory"
:description "Move file(s) to directory")
((files file) (dir directory))
(dolist (file files)
(rename-file file
(file-name-concat dir (file-name-nondirectory file))))
(message (format "%d files moved to %s" (length files) dir)))
(def-presentation-command (standard-commands:move-files-to-trash
:title "Move file(s) to trash"
:description "Move file(s) to trash")
((files file))
(dolist (file files)
(move-file-to-trash file))
(message (format "%d files moved to trash" (length files))))
(def-presentation-command (standard-commands:rename-files
:title "Rename file(s)"
:description "Rename files(s)")
((files file))
(dolist (file files)
(let ((newname (read-from-minibuffer "New file name: ")))
(rename-file file newname)
(message "File renamed"))))
(def-presentation-command (send-email
:title "Send email"
:description "Send email")
((emails email))
(call-process "/usr/bin/xdg-open" nil nil nil
(format "mailto:%s" (s-join "," emails))))
(when (featurep 'inspector)
(defun inspect-presentation-at-point ()
(interactive)
(let ((presentation (presentation-at-point)))
(when presentation
(inspector-inspect presentation)))))
(provide 'pbui-standard-commands)
;;; pbui-standard-commands ends here