in reply to CPerl-Mode Indentation

Did you try with perltidy? I've it integrated to emacs with the following code in the .emacs
(global-set-key "\C-xt" 'perltidy-region) (defun perltidy-region () "Run perltidy on the current region or the whole buffer." (interactive) (save-excursion (let ((beg (if mark-active (point) (point-min))) (end (if mark-active (mark) (point-max)))) (shell-command-on-region beg end "perltidy -q" nil t))))
Originally from Specific Indentation request for perl in Emacs and then I modified it a little bit, so before checking in my code I run it thru perl tidy by pressing Ctrl+xt

Replies are listed 'Best First'.
Re^2: CPerl-Mode Indentation
by LanX (Saint) on Jun 15, 2010 at 10:39 UTC
    I know this approach but unfortunately this is not very compatible to the emacs way...

    Indentation is an integral part and main advantage of emacs editing, where ever you are in the code, just hitting TAB is enough to perfectly interactively indent the whole line ... I even bound it to RET to get it automatically when ending lines.

    It's not only cosmetics, you immediately get a feedback for multiline syntax errors (eg forgotten ";") when the indentation is wrong! So each time you insert an new line in a hash the perltity indentation will be broken again by emacs! That means you will have to mark the whole structure again and pipe it through perltidy.

    To make this more comfortable you will have to write a elisp-key-macro bound to TAB which automatically detects to be within a structure, to ignore normal emacs indentation, select the structure and to pipe it through perltidy...

    While this is perfectly possible, it's easier now to extend cperl-mode, it has a more natural UI and has a much better return of investment.

    I have it on my TODO list, but regarding the number of open projects it has only low priority. :)

    Cheers Rolf

      Absolutely I'm not taking away cperl-mode responsibilities, I'm just giving you a workaround

      BTW the small change that I made to that function was that if you have nothing selected it'll send perltidy the whole buffer, so that might help in your case

        Various responses:

        I haven't tried with perl tidy, I need to check into that, thanks. I agree with the indentation being part of core emacs and finding syntax errors through odd indentation is helpful! I'd rather have the feature in cperl vs using the perl tidy piping approach too.

        I'm much more familiar with perl vs python, but that's interesting there's also the lisp for python programmers document.

        In the past I've actually learned some LISP and also Emacs LISP but have forgotten it. Trying to figure out how to add in the additional bit of indentation features would be an interesting side project and make me pretty happy as the end result hehe