| Category: | Miscellaneous |
| Author/Contact Info | |
| Description: | If you use emacs, this function will check the syntax of your perl code and also run podchecker against it and display the result in a new buffer. You can call this function via the after-save-hook, and have the syntax checker run automatically. The function checks for CPerl mode. Updated the code and the 'perlsyn' folder is shown only when there is a syntax error.(thanks to water) Updated code to do a perl -wc (thanks to htoug) |
;;my after-save-hook to cperl
(defun myperl-check-syntax ()
(interactive)
(if (not (equal mode-name "CPerl"))
;;ignore
()
;;get the full path of this file
(setq source-full-path (buffer-file-name))
;;clear the buffer of earlier error
(set-buffer (get-buffer-create "perlsyn"))
(erase-buffer)
;;set the perl5lib
(setenv "PERL5LIB" "/usr/lib/perl5")
;;execute perl -wc
(call-process "perl" nil "perlsyn" nil "-wc" source-full-path)
;;execute podchecker
;; (call-process "podchecker" nil "perlsyn" nil
;; source-full-path)
;; checks if perl returned a syntax OK string
(if (not (equal (substring (buffer-string) -3 -1) "OK"))
(switch-to-buffer "perlsyn")))
)
(add-hook 'after-save-hook 'myperl-check-syntax)
|
|
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: check syntax of perl code and pod in emacs
by water (Deacon) on Oct 12, 2004 at 00:39 UTC | |
|
Re: check syntax of perl code and pod in emacs
by stefan k (Curate) on Oct 12, 2004 at 09:48 UTC | |
by water (Deacon) on Oct 17, 2004 at 19:44 UTC | |
by stefan k (Curate) on Nov 01, 2004 at 08:19 UTC | |
|
Re: check syntax of perl code and pod in emacs (warnings)
by htoug (Deacon) on Oct 12, 2004 at 07:32 UTC | |
|
Re: check syntax of perl code and pod in emacs
by vjo (Novice) on Oct 20, 2004 at 21:23 UTC |