Loading ...
Sorry, an error occurred while loading the content.

Perl -cw and error hilighting macro

Expand Messages
  • Dr. Detlef Groth
    Hello, I recently played a little bit with eclipse and it s Perl-EPIC plugin. After each file save, the errors on the perl-file are underlined using perl -cw
    Message 1 of 1 , Jun 28, 2007
    • 0 Attachment
      Hello,

      I recently played a little bit with eclipse and it's Perl-EPIC plugin.
      After each file save, the errors on the perl-file are underlined using
      "perl -cw <filename>" command -cw checks file and warns without
      executing it. I tried to implement this feature for MicroEmacs as well
      and came up with the following solution:


      define-macro perl-check
      set-alpha-mark "\x81"
      set-variable #l0 $buffer-bname
      pipe-shell-command &cat &cat "perl -cw \"" $buffer-fname "\""
      find-buffer "*command*"
      beginning-of-buffer
      set-variable #l1 "|"
      ; search all errors with the line string
      !force search-forward " line "
      !while $status
      forward-char
      backward-char
      set-mark
      forward-word
      exchange-point-and-mark
      copy-region
      ; TODO need to use restore the kill buffer
      !if &xse @y "\\d+"
      set-variable #l1 &cat &cat #l1 @y "|"

      !endif
      -1 yank
      !force search-forward " line "
      !done
      set-variable #l1 &cat #l1 "-1|"
      ; TODO need to avoid to open an other buffer-window
      find-buffer #l0
      set-variable #l2 1
      set-variable #l3 &lget #l1 #l2
      beginning-of-buffer
      ; remove all line hilighting
      !repeat
      ; Protect folded lines.
      !if ¬ &or &equ $line-scheme .scheme.fold-close &equ \
      $line-scheme .scheme.fold-open
      set-variable $line-scheme -1
      !endif
      !force forward-line
      !until ¬ $status
      !if &great &len #l1 4
      ; set-variable $debug 2
      !repeat
      beginning-of-buffer
      set-variable #l3 &sub #l3 1
      #l3 forward-line
      set-variable $line-scheme 9
      set-variable #l2 &add #l2 1
      set-variable #l3 &lget #l1 #l2
      !until &equal #l3 "-1"
      ml-write &cat "Errors on line(s):" &rep #l1 "-1|" ""
      !else
      ; TODO need to grab the status message currently in the
      ; message line and to combine it with our message
      ml-write "Syntax Ok"
      !endif
      screen-update
      goto-alpha-mark "\x81"
      !emacro
      define-macro perl-save
      save-buffer
      -2000 command-wait
      perl-check
      !emacro

      buffer-bind-key perl-check "C-x C-k"

      buffer-bind-key perl-save "C-x C-s"

      There are only two problems currently with this approach. Each time a
      new window is opened for the current perl-buffer. And it would be nice
      to implement a mouseover or similar on a colored line which should
      give the the error-message on with ml-write. Is such a mouseover
      possible for colored lines ?

      regards,
      Detlef
    Your message has been successfully submitted and would be delivered to recipients shortly.