2022-01-04 06:41:12 +00:00
|
|
|
;;; +crux.el -*- lexical-binding: t; -*-
|
|
|
|
|
|
|
|
;;; Code:
|
|
|
|
|
|
|
|
(require 'crux)
|
|
|
|
|
|
|
|
(defgroup +crux nil
|
|
|
|
"Extra crux customizations."
|
|
|
|
:group 'crux
|
|
|
|
:prefix "+crux-")
|
|
|
|
|
|
|
|
(defun +crux-kill-ring-save (begin end arg)
|
|
|
|
"Copy region to the kill-ring, possibly indenting it first.
|
|
|
|
Copy from BEGIN to END using `kill-ring-save' if no argument was
|
|
|
|
passed, or with `crux-indent-rigidly-and-copy-to-clipboard' if
|
|
|
|
one was."
|
|
|
|
(interactive "r\nP")
|
2022-01-21 22:34:55 +00:00
|
|
|
(call-interactively (if arg
|
|
|
|
#'crux-indent-rigidly-and-copy-to-clipboard
|
|
|
|
#'kill-ring-save))
|
|
|
|
(pulse-momentary-highlight-region begin end))
|
2022-01-04 06:41:12 +00:00
|
|
|
|
|
|
|
(defcustom +crux-default-date-format "%c"
|
|
|
|
"Default date format to use for `+crux-insert-date-or-time'.
|
|
|
|
Should be a format parsable by `format-time-string'."
|
|
|
|
:type 'string)
|
|
|
|
|
|
|
|
(defcustom +crux-alternate-date-format "%FT%T%z"
|
|
|
|
"Alternate date format to use for `+crux-insert-date-or-time'.
|
|
|
|
Should be a format parsable by `format-time-string'."
|
|
|
|
:type 'string)
|
|
|
|
|
|
|
|
(defun +crux-insert-date-or-time (arg)
|
|
|
|
"Insert current date or time.
|
|
|
|
Called without a prefix ARG, insert the time formatted by
|
|
|
|
`+crux-default-date-format'. When called with \\[universal-argument],
|
|
|
|
format the time with `+crux-alternate-date-format'. Otherwise,
|
|
|
|
prompt for the time format."
|
|
|
|
(interactive "*P")
|
|
|
|
(let ((time (current-time)))
|
|
|
|
(insert (cond
|
|
|
|
((null arg) (format-time-string +crux-default-date-format time))
|
|
|
|
((eq (car-safe arg) 4)
|
|
|
|
(format-time-string +crux-alternate-date-format time))
|
|
|
|
(t (format-time-string (read-string "Time Format: ") time))))))
|
|
|
|
|
2022-04-12 18:15:36 +00:00
|
|
|
(defun +crux-kill-and-join-forward (&optional arg)
|
|
|
|
"If at end of line, join with following; else (visual)-kill line.
|
|
|
|
In `visual-line-mode', runs command `kill-visual-line'; in other
|
|
|
|
modes, runs command `kill-line'. Passes ARG to command when
|
|
|
|
provided. Deletes whitespace at join."
|
|
|
|
(interactive "P")
|
|
|
|
(if (and (eolp) (not (bolp)))
|
|
|
|
(delete-indentation 1)
|
|
|
|
(funcall (if visual-line-mode #'kill-visual-line #'kill-line) arg)))
|
|
|
|
|
2022-01-04 06:41:12 +00:00
|
|
|
(provide '+crux)
|
|
|
|
;;; +crux.el ends here
|