diff options
Diffstat (limited to 'lisp')
-rw-r--r-- | lisp/+crux.el | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/lisp/+crux.el b/lisp/+crux.el new file mode 100644 index 0000000..b87ec7e --- /dev/null +++ b/lisp/+crux.el | |||
@@ -0,0 +1,46 @@ | |||
1 | ;;; +crux.el -*- lexical-binding: t; -*- | ||
2 | |||
3 | ;;; Code: | ||
4 | |||
5 | (require 'crux) | ||
6 | |||
7 | (defgroup +crux nil | ||
8 | "Extra crux customizations." | ||
9 | :group 'crux | ||
10 | :prefix "+crux-") | ||
11 | |||
12 | (defun +crux-kill-ring-save (begin end arg) | ||
13 | "Copy region to the kill-ring, possibly indenting it first. | ||
14 | Copy from BEGIN to END using `kill-ring-save' if no argument was | ||
15 | passed, or with `crux-indent-rigidly-and-copy-to-clipboard' if | ||
16 | one was." | ||
17 | (interactive "r\nP") | ||
18 | (call-interactively (if arg #'kill-ring-save | ||
19 | #'crux-indent-rigidly-and-copy-to-clipboard))) | ||
20 | |||
21 | (defcustom +crux-default-date-format "%c" | ||
22 | "Default date format to use for `+crux-insert-date-or-time'. | ||
23 | Should be a format parsable by `format-time-string'." | ||
24 | :type 'string) | ||
25 | |||
26 | (defcustom +crux-alternate-date-format "%FT%T%z" | ||
27 | "Alternate date format to use for `+crux-insert-date-or-time'. | ||
28 | Should be a format parsable by `format-time-string'." | ||
29 | :type 'string) | ||
30 | |||
31 | (defun +crux-insert-date-or-time (arg) | ||
32 | "Insert current date or time. | ||
33 | Called without a prefix ARG, insert the time formatted by | ||
34 | `+crux-default-date-format'. When called with \\[universal-argument], | ||
35 | format the time with `+crux-alternate-date-format'. Otherwise, | ||
36 | prompt for the time format." | ||
37 | (interactive "*P") | ||
38 | (let ((time (current-time))) | ||
39 | (insert (cond | ||
40 | ((null arg) (format-time-string +crux-default-date-format time)) | ||
41 | ((eq (car-safe arg) 4) | ||
42 | (format-time-string +crux-alternate-date-format time)) | ||
43 | (t (format-time-string (read-string "Time Format: ") time)))))) | ||
44 | |||
45 | (provide '+crux) | ||
46 | ;;; +crux.el ends here | ||