summary refs log tree commit diff stats
path: root/lisp
diff options
context:
space:
mode:
authorCase Duckworth2022-01-04 00:41:12 -0600
committerCase Duckworth2022-01-04 00:41:12 -0600
commit817c0ae001a1ea6cc2775e1e2898931b3ff12d8a (patch)
tree20b25747bd274ff2c4658389bc493ec7264b86df /lisp
parentAdd +remember-prefix-arg function (diff)
downloademacs-817c0ae001a1ea6cc2775e1e2898931b3ff12d8a.tar.gz
emacs-817c0ae001a1ea6cc2775e1e2898931b3ff12d8a.zip
Add +crux.el
Oops, missed this with a previous commit
Diffstat (limited to 'lisp')
-rw-r--r--lisp/+crux.el46
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.
14Copy from BEGIN to END using `kill-ring-save' if no argument was
15passed, or with `crux-indent-rigidly-and-copy-to-clipboard' if
16one 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'.
23Should 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'.
28Should 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.
33Called without a prefix ARG, insert the time formatted by
34`+crux-default-date-format'. When called with \\[universal-argument],
35format the time with `+crux-alternate-date-format'. Otherwise,
36prompt 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