J
J Krugman
Let me preface this post by stressing that my intent is NOT to
start a religious vi-vs-emacs flame fest.
I have noticed that vi is *particularly* popular among Perl
programmers, and (as an Emacs enthusiast) I wonder why. I have
edited Perl code with plain ol' vim, and found the experience much
less pleasant than editing Perl with Emacs's cperl mode, but I'm
sure that, in my ignorance, I was not taking advantage of the vi
power tools for Perl coding. So my question really boils down to
what should I do to get a taste of the joys of coding (and debugging?)
Perl with vi?
TIA,
jill
P.S. Yes, I have read perldoc -q editor
P.S.2 What motivated this question was my learning about the handy
little vi sequence
:!perl -cW
for checking the syntax on a buffer of Perl code. The equivalent
in emacs is a bit more long-winded:
C-x h
M-| perl -cW
So I decided to add the following to my .emacs file (probably
re-inventing a thoroughly invented wheel):
(defun check-perl (&optional arg)
"Checks the Perl syntax in current buffer.
If the mark is set and either it is active or transient-mark-mode
is nil, the current region is checked. Otherwise the entire
buffer is checked. With a numeric argument, the check is made under
the strict pragma."
(interactive "P")
(let (start end (strict ""))
(if (and (mark)
(or mark-active
(not transient-mark-mode)))
(progn (setq start (mark ))
(setq end (point)))
(progn (setq start (point-min))
(setq end (point-max)))
)
(if arg (setq strict "-Mstrict "))
(shell-command-on-region
start end (concat "perl " strict "-Mdiagnostics -cW "))))
;; The following binds the F12 key to the check-perl command in
;; the cperl mode
(add-hook 'cperl-mode-hook (lambda ()
(local-set-key [(f12)] 'check-perl)
))
start a religious vi-vs-emacs flame fest.
I have noticed that vi is *particularly* popular among Perl
programmers, and (as an Emacs enthusiast) I wonder why. I have
edited Perl code with plain ol' vim, and found the experience much
less pleasant than editing Perl with Emacs's cperl mode, but I'm
sure that, in my ignorance, I was not taking advantage of the vi
power tools for Perl coding. So my question really boils down to
what should I do to get a taste of the joys of coding (and debugging?)
Perl with vi?
TIA,
jill
P.S. Yes, I have read perldoc -q editor
P.S.2 What motivated this question was my learning about the handy
little vi sequence
:!perl -cW
for checking the syntax on a buffer of Perl code. The equivalent
in emacs is a bit more long-winded:
C-x h
M-| perl -cW
So I decided to add the following to my .emacs file (probably
re-inventing a thoroughly invented wheel):
(defun check-perl (&optional arg)
"Checks the Perl syntax in current buffer.
If the mark is set and either it is active or transient-mark-mode
is nil, the current region is checked. Otherwise the entire
buffer is checked. With a numeric argument, the check is made under
the strict pragma."
(interactive "P")
(let (start end (strict ""))
(if (and (mark)
(or mark-active
(not transient-mark-mode)))
(progn (setq start (mark ))
(setq end (point)))
(progn (setq start (point-min))
(setq end (point-max)))
)
(if arg (setq strict "-Mstrict "))
(shell-command-on-region
start end (concat "perl " strict "-Mdiagnostics -cW "))))
;; The following binds the F12 key to the check-perl command in
;; the cperl mode
(add-hook 'cperl-mode-hook (lambda ()
(local-set-key [(f12)] 'check-perl)
))