dotfiles/.emacs.d/lisp/init-kill.el

47 lines
2.0 KiB
EmacsLisp
Raw Normal View History

2021-08-17 11:49:19 +00:00
;;; init-kill.el --- Kill Ring Configuration File -*- lexical-binding: t -*-
;;; Commentary:
;; Contains code copied from prelude-editor.el
;;; Code:
(use-package browse-kill-ring
2022-08-30 11:53:46 +00:00
:defer 5
2021-08-17 11:49:19 +00:00
:config
2021-09-01 13:57:19 +00:00
(browse-kill-ring-default-keybindings))
2021-08-17 11:49:19 +00:00
2022-08-10 14:59:35 +00:00
(use-package easy-kill
:bind
([remap kill-ring-save] . easy-kill)
;; emulate expand-region
("C-=" . easy-mark)
(:map easy-kill-base-map ("C-=" . easy-kill-expand)))
2022-08-10 14:59:35 +00:00
2023-05-19 11:09:57 +00:00
(use-feature emacs
2022-10-14 12:46:02 +00:00
:hook
2023-05-19 11:09:57 +00:00
(elpaca-after-init . (lambda ()
;; Based on code in prelude-editor.el
(defun yank-advised-indent-function (beg end)
"Do indentation, as long as the region isn't too large."
(if (<= (- end beg) 10000)
(indent-region beg end nil)))
2021-08-17 11:49:19 +00:00
2023-05-19 11:09:57 +00:00
(defmacro advise-commands (advice-name commands class &rest body)
"Apply advice named ADVICE-NAME to multiple COMMANDS.
2021-08-17 11:49:19 +00:00
The body of the advice is in BODY."
2023-05-19 11:09:57 +00:00
`(progn
,@(mapcar (lambda (command)
`(defadvice ,command (,class ,(intern (concat (symbol-name command) "-" advice-name)) activate)
,@body))
commands)))
2022-10-14 12:46:02 +00:00
2023-05-19 11:09:57 +00:00
(advise-commands "indent" (yank yank-pop) after
(if (and (not (ad-get-arg 0))
(not (member major-mode '(conf-mode coffee-mode haml-mode python-mode slim-mode yaml-mode)))
(or (derived-mode-p 'prog-mode)
(member major-mode '(LaTeX-mode TeX-mode))))
(let ((transient-mark-mode nil))
(yank-advised-indent-function (region-beginning) (region-end))))))))
2021-08-17 11:49:19 +00:00
(provide 'init-kill)
;;; init-kill.el ends here