From 0a0db21234cf5884b893f5c0e19c10c7ba8c3092 Mon Sep 17 00:00:00 2001 From: ivan Date: Sat, 15 Aug 2026 23:06:21 -0600 Subject: [PATCH] stuff --- init.el | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/init.el b/init.el index 300fdd6..f3c940f 100644 --- a/init.el +++ b/init.el @@ -248,32 +248,40 @@ ;;;; BEGIN: cperl-mode (require 'perl-mode) (require 'cperl-mode) -(require 'projectile) (setq cperl-set-style "linux") (setq cperl-highlight-variables-indiscriminately t) (defalias 'perl-mode 'cperl-mode) (setq cperl-indent-parens-as-block t) -(add-to-list 'auto-mode-alist '("\\.\\(p\\([lm]\\)\\)\\'" . cperl-mode)) -(setq cperl-basic-offset 2) +(add-to-list 'auto-mode-alist '("\\.pm$" . cperl-mode)) +(add-to-list 'auto-mode-alist '("\\.pl$" . cperl-mode)) +(add-to-list 'auto-mode-alist '("\\.psgi$" . cperl-mode)) +(setq cperl-basic-offset 4) (add-hook 'cperl-mode-hook (lambda () (add-hook 'before-save-hook #'perltidy-buffer nil t))) -;;; Set Perl include path (setq flycheck-perl-include-path '()) - -;;; This is kinda ugly, assuming you use perlbrew its fine :) (when (file-directory-p "~/perl5/perlbrew") (let ((rf-perl-version (shell-command-to-string "source ~/.bashrc && perl -e 'print($^V =~ s/v//r)' 2> /dev/null"))) - (add-to-list 'flycheck-perl-include-path - (concat "~/perl5/perlbrew/perls/perl-" rf-perl-version "/lib/" rf-perl-version)))) + ;; Strip any trailing newlines from shell command output + (setq rf-perl-version (string-trim rf-perl-version)) + (when (not (string-empty-p rf-perl-version)) + (add-to-list 'flycheck-perl-include-path + (expand-file-name (format "~/perl5/perlbrew/perls/perl-%s/lib/%s" rf-perl-version rf-perl-version)))))) -(when-let ((pr (projectile-project-root))) - (add-to-list 'flycheck-perl-include-path (concat pr "/lib"))) +(require 'projectile) -(add-hook 'cperl-mode-hook - (lambda () - (add-to-list 'flycheck-perl-include-path (concat (projectile-project-root) "lib")))) +(defun flycheck-perllib-init () + "Dynamically add local project lib path to Flycheck without overwriting global paths." + (let ((root (or (and (fboundp 'projectile-project-root) (projectile-project-root)) + (and (fboundp 'project-current) (project-current) (project-root (project-current)))))) + (when root + (let ((local-lib (expand-file-name "lib" root))) + (when (file-directory-p local-lib) + (make-local-variable 'flycheck-perl-include-path) + (add-to-list 'flycheck-perl-include-path local-lib)))))) + +(add-hook 'cperl-mode-hook #'flycheck-perllib-init) ;;; cperl-mode does some ugly stuff (eval-after-load 'cperl-mode