note
stefan k
Hi,<br>
first, as I posted before, although I really appreciate when someone writes code in elisp (even if it were just for the fun in it ;-) I suggest using the function <code>cperl-check-syntax</code> which invokes <code>mode-compile</code> which is quite clever. One gain would be that you can jump to errors found my that process directly. Another gain would be the customizability of <code>mode-compile</code>. There is one variable called <code>mode-compile-other-frame-p</code> which could be used to achieve your first goal in a way: simply let it use a different frame (known as "window" to all other users ;-) and hide that frame somewhere on your desktop where it won't get in your way.
<p>
Another possibility might be to use one of the hooks run before and after running <code>mode-compile</code> but after looking at the code I can't find an obvious way.
<p>
As to your second question you're probably interested in using the emacs-feature where you can pass a region or a buffer to a shell command and replace the region/buffer with the result of that command. This can also be used for sorting lines for example.
<p>
This call would look like this:
<code>
C-x h C-u M-| perltidy
</code>
Here <code>C-x h</code> should mark the whole buffer, the prefix argument <code>C-u</code> enables the replacement of the region and finally <code>M-|</code> calls the function <code>shell-command-on-region</code> which asks for the command to use. Unfortunately I don't have perltidy at hand to test it.
<p>
Putting all this into a single function which can be bound to a key would be like:
<code>
(defun my-perltidy ()
"Call perltidy on the current buffer.
This replaces the current content of the buffer with the output of the
perltidy programm. You must have perltidy installed.
See http://perlmonks.org/?node_id=399154 for the start of this."
(interactive)
(when (yes-or-no-p "Really run perltidy? ")
(goto-char (point-min))
(shell-command-on-region (point-min)
(point-max)
"perltidy"
nil
t)))
</code>
And then:
<code>
(add-hook 'cperl-mode-hook
'(lambda ()
(local-set-key '[(control c) (control t)] 'my-perltidy)))
</code>
or something like that.
<p>
Please note, that I use XEmacs, but this code should be usable on both emacsen, I guess
<p>
<b>Update Thu Oct 14 14:15:41 CEST 2004:</b> Added note on emacs-version
<!-- Node text goes above. Div tags should contain sig only -->
<div class="pmsig"><div class="pmsig-5094">
<p>
<table width="80%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><small>Regards...</small></td>
<td align="right"><small>
<a href="http://www.skamphausen.de">Stefan</a>
</small></td>
</tr>
<tr>
<td colspan="2" align="center">
<small>you begin bashing the string with a +42 regexp of confusion</small>
</td>
</tr>
</table>
</div></div>
399154
399154