summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGianni Ceccarelli <gianni.ceccarelli@broadbean.com>2019-06-26 16:48:25 +0100
committerdakkar <dakkar@thenautilus.net>2021-06-12 19:01:51 +0100
commitd7cc388e15647f87b0e5c02301e6a9b20cddea16 (patch)
tree07c92a7bc4f6fe68e860661fddc96cc6717642ed
parentauto-update the keyring (diff)
downloademacs-master.tar.gz
emacs-master.tar.bz2
emacs-master.zip
smarter perl indent in POD sectionsHEADmaster
-rwxr-xr-xinit.el24
1 files changed, 24 insertions, 0 deletions
diff --git a/init.el b/init.el
index 3426903..13842eb 100755
--- a/init.el
+++ b/init.el
@@ -389,3 +389,27 @@
; https://www.emacswiki.org/emacs/ELPA
(add-hook 'after-init-hook 'unicode-fonts-setup)
(add-hook 'after-init-hook 'gnu-elpa-keyring-update)
+
+(defun dakkar/perl-indent (beg end)
+ (interactive "r")
+ (if (use-region-p)
+ (cond ((get-text-property beg 'in-pod)
+ (let* (
+ (text (buffer-substring beg end))
+ (indented-text (with-temp-buffer
+ (insert text)
+ (cperl-mode)
+ (cperl-indent-region 0 (buffer-size))
+ (indent-rigidly 0 (buffer-size) cperl-indent-level)
+ (buffer-string))))
+ (delete-region beg end)
+ (insert indented-text)))
+ (t (cperl-indent-region beg end)))))
+
+(defun dakkar/setup-cperl-mode ()
+ (setq indent-region-function 'dakkar/perl-indent)
+ (substitute-key-definition
+ 'indent-region 'dakkar/perl-indent
+ cperl-mode-map global-map))
+
+(add-hook 'cperl-mode-hook 'dakkar/setup-cperl-mode)