diff options
author | David Morgan <djm_uk@protonmail.com> | 2022-10-14 13:46:02 +0100 |
---|---|---|
committer | David Morgan <djm_uk@protonmail.com> | 2022-10-14 13:46:02 +0100 |
commit | 5edc8a842fd3c0ab6a654aea33a9875820b65660 (patch) | |
tree | ad65f9dbb8535b8abd17b6525d31a56895f2833f /.emacs.d/lisp | |
parent | fc3ad645792acc8077f4190331725c28f63b9b6b (diff) | |
download | dotfiles-5edc8a842fd3c0ab6a654aea33a9875820b65660.tar.gz |
Tweak auto-indent on yank advice
Diffstat (limited to '.emacs.d/lisp')
-rw-r--r-- | .emacs.d/lisp/init-kill.el | 47 |
1 files changed, 22 insertions, 25 deletions
diff --git a/.emacs.d/lisp/init-kill.el b/.emacs.d/lisp/init-kill.el index 324f5f8..c750956 100644 --- a/.emacs.d/lisp/init-kill.el +++ b/.emacs.d/lisp/init-kill.el @@ -14,34 +14,31 @@ ([remap mark-sexp] . easy-mark)) (use-package emacs - :config - (defadvice exchange-point-and-mark (before deactivate-mark activate compile) - "When called with no active region, do not activate mark." - (interactive - (list (not (region-active-p))))) - - (defun yank-advised-indent-function (beg end) - "Do indentation, as long as the region isn't too large." - (if (<= (- end beg) 1000) - (indent-region beg end nil))) + :hook + (emacs-startup . (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))) - (defmacro advise-commands (advice-name commands class &rest body) - "Apply advice named ADVICE-NAME to multiple COMMANDS. + (defmacro advise-commands (advice-name commands class &rest body) + "Apply advice named ADVICE-NAME to multiple COMMANDS. The body of the advice is in BODY." - `(progn - ,@(mapcar (lambda (command) - `(defadvice ,command (,class ,(intern (concat (symbol-name command) "-" advice-name)) activate) - ,@body)) - commands))) - - (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)))))) + `(progn + ,@(mapcar (lambda (command) + `(defadvice ,command (,class ,(intern (concat (symbol-name command) "-" advice-name)) activate) + ,@body)) + commands))) + + (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)))))))) (provide 'init-kill) ;;; init-kill.el ends here |