Archive for February, 2009

Updating to intrepid broke my left arrow key!

Seems that the keycodes on my keyboard (thinkpad T43p) changed after installing the new version of intrepid. I note that the kernel version changed. This meant that my xmodmap was mapping this key to alt…

Add comment February 24, 2009

Flash broken by upgrade to ubuntu intrepid

Upgrading to ubuntu intrepid broke the sound in flash. Videos would play but there was no sound.

Attempting to install the apt non-free flash player failed complaining about the md5 checksum not matching (presumably becase the md5 sum is hard-code and the flash player that was being downloaded had changed). [aside: running apt-get clean and repeating made this work. ]

However downloading and installing the latest version of flash worked.

Add comment February 24, 2009

Using flymake in emacs to validate html as you type

Flymake is a general emacs plugin which allows you to run an external validator against a buffers content and visually report errors. The effects are quite similar to the red underlining you will see in some IDEs (e.g visual studio) – but can be used for any file format with a validator with some work. The following settings let flymake validate html in emacs.

Motivation

  • Seeing mistakes earlier can make them easier to correct
  • Many programs will simply die with little logging if given broken xml files
  • Remembering to run a validator takes effort
  • t

Setup

  • Install html tidy (this is available under cygwin on windows, and using apt under most linuxes)
  • Create this perl scripts, make it executable and place it on your path [1] call it flymakehtml
    #!/usr/bin/perl
    open(INPUT, "rxp $ARGV[0] 2>&1|");
    while (<INPUT>){
        /^Error/ && chomp;
        print;
    }
  • Add the following code to your .emacs file:
  • (defun flymake-html-init ()
      (let* ((temp-file (flymake-init-create-temp-buffer-copy
    		     'flymake-create-temp-inplace))
    	 (local-file (file-relative-name
    		      temp-file
    		      (file-name-directory buffer-file-name))))
        (list "tidy" (list local-file))))
    
    (add-to-list 'flymake-allowed-file-name-masks
    	     '("\\.html\\'" flymake-html-init)) 
    
    (add-to-list 'flymake-err-line-patterns
    	     '("line \\([0-9]+\\) column \\([0-9]+\\) - \\(Warning\\|Error\\): \\(.*\\)"
    	      nil 1 2 4))
    
  • Also, ensure that you have the following command somewhere in your .emacs file
     (add-hook 'find-file-hook 'flymake-find-file-hook)

This should then work. You might like to change the face used to show errors with M-x customize-face flymake-errline. Hovering over an error will show you a description of the error

[1] This is to trim the tidied document from the output and only leave error messages.

Caveats
Sometimes error messages will use slightly strange tenses – since html tidy is a tool to tidy html rather than validate it – but the meaning is usually clear enough.

You might be interested in the nxhtml plugin as an alternative to this – but with more features such as context dependent autocompletion – though this looks like it could take a little setting up, and also seems a little overpowering

2 comments February 23, 2009

Using flymake in emacs to validate xml as you type

Motivation

  • Seeing mistakes earlier can make them easier to correct
  • Many programs will simply die with little logging if given broken xml files
  • Remembering to run a validator takes effort

Setup

  • Install rxp (this is available under cygwin on windows, and using apt under most linuxes)
  • Create this perl scripts, make it executable and place it on your path [1] call it xmlparse
    #!/usr/bin/perl
    open(HA, "rxp $ARGV[0] 2>&1|");
    while (){
        /^Error/ && chomp;
        print;
    }
  • Add the following code to your .emacs file
  • (defun flymake-xml-init ()
      (let* ((temp-file (flymake-init-create-temp-buffer-copy
    		     'flymake-create-temp-inplace))
    	 (local-file (file-relative-name
    		      temp-file
    		      (file-name-directory buffer-file-name))))
        (list "xmlparse" (list local-file))))
    
    (add-to-list 'flymake-allowed-file-name-masks
    	     '("\\.xml\\'" flymake-xml-init)) 
    
    (add-to-list 'flymake-err-line-patterns
    	     '("\\(.*\\) at line \\([0-9]+\\) char \\([0-9]+\\) of file://\\(.*\\)"
    	      4 2 3 1))
  • Also, ensure that you have the following command somewhere in your .emacs file
     (add-hook 'find-file-hook 'flymake-find-file-hook)

This should then work. You might like to change the face used to show errors with M-x customize-face flymake-errline. Hovering over an error will show you a description of the error

Caveats

The behavior for unclosed tags is not what I want. The error is reported where the parent tag closes – which can be quite some distance from the opening tag. However at least the message is informative.

There is an existing emacs host, nxhtml, which has some of these things built in together with other editing tools – but it looks a little monolithic.

[1] This ensures that each error is written on only one line. Flymake appears to only be able deal with output in this form.

Add comment February 23, 2009


Meta

Facets

abstruse Add new tag AOP apt aspect oriented programming assumes knowledge autiobiographical bash scripts bell books clarity code samples configuration console emacs for the benefit of google functional programming graphical design hacks higher-order functions howtos intention revealing programming keyboard links linux note to self opinions parsing patterns philosophising philosophizing programming python random ideas refactoring removing packages short stories succinct svn systems stuff theoretical philosophizing typing work ethic you probably don't want to read this

Archives

Pages

 

February 2009
M T W T F S S
« Sep   Mar »
 1
2345678
9101112131415
16171819202122
232425262728