Wednesday, July 25, 2007

Emacs modes for Flex

  • Emacs modes for Flex:
    • XML: nXML-mode for Emacs from James Clark Using Emacs for XML documents
    • Actionscript: actionscript-mode.el for editing actionscript files in emacs.
    • At least right now it seems you want this xml mode and this actionscript-mode.el.
    • Then, add
      (setq auto-mode-alist (append (list
       '("\\.as\\'"   . actionscript-mode)
       '("\\.\\(xml\\|xsl\\|rng\\|xhtml\\|mxml\\)\\'" . nxml-mode)
       ;; add more modes here
       ) auto-mode-alist))
      
      ;;
      ;; ------------------ Magic for XML Mode ----------------
      ;;
      
      (setq nxml-mode-hook
          '(lambda ()
       (setq tab-width        2
             indent-tabs-mode nil)
             (set-variable 'nxml-child-indent     2)
             (set-variable 'nxml-attribute-indent 2)
             ))
      
    • You can use M-x customize-group RET nxml-highlighting-faces RET to fix your colors the way you like 'em.
  • Setting up asdoc to work within Flex Builder:
    • First, install ant support (Ant is an offshoot of apache and is like Makefile only more betterer.)
    • Then set up a build.xml in your docs/ directory to build the documentation set.
    • I had to modify mine a bit: I added <property name="Templates.dir" location="${FlexSDK.dir}/asdoc/templates/"/> <arg line='-templates-path ${Templates.dir}'/>
    • I also linked the flex home to a no-funny-characters dir:
          ln -s "/Applications/Applications/Adobe Flex Builder 2" /work/ProgramStores/Flex
         cd /work/ProgramStores/Flex
         ln -s "Flex SDK 2" FlexSDK
      Then I exported the location for the asdoc file:
          export FLEX_HOME=/work/ProgramStores/Flex/FlexSDK
      or else I got the error message:
          Exception in thread "main" java.lang.NoClassDefFoundError: Flex

Labels: , , , , , , ,

Tuesday, July 24, 2007

How to use exuberant CTAGS with ActionScript and Flex

How to fix CTAGS to work with ActionScript, from the vim-taglist project:
  • ActionScript Add the following lines to the $HOME/.ctags or $HOME/ctags.conf file:
    --langdef=actionscript
    --langmap=actionscript:.as
    --regex-actionscript=/^[ \t]*[(private| public|static) ( \t)]*function[ \t]+([A-Za-z0-9_]+)[ \t]*\(/\1/f, function, functions/
    --regex-actionscript=/^[ \t]*[(public) ( \t)]*function[ \t]+(set|get) [ \t]+([A-Za-z0-9_]+)[ \t]*\(/\1 \2/p,property, properties/
    --regex-actionscript=/^[ \t]*[(private| public|static) ( \t)]*var[ \t]+([A-Za-z0-9_]+)[ \t]*/\1/v,variable, variables/
    --regex-actionscript=/.*\.prototype \.([A-Za-z0-9 ]+)=([ \t]?)function( [ \t]?)*\(/\1/ f,function, functions/
    --regex-actionscript=/^[ \t]*class[ \t]+([A-Za-z0-9_]+)[ \t]*/\1/c,class, classes/
    
    Add the following lines to the ~/.vimrc or $HOME\_vimrc file:
    " actionscript language
    let tlist_actionscript_settings = 'actionscript;c:class;f:method;p:property;v:variable'
    
I actually just add these lines to my maintenance Makefile:
CTAGLANGS = --langdef=actionscript \
--langmap=actionscript:.as \
--regex-actionscript='/^[ \t]*[(private| public|static) ( \t)]*function[\t]+([A-Za-z0-9_]+)[ \t]*\(/\1/f, function, functions/' \
--regex-actionscript='/^[ \t]*[(public) ( \t)]*function[ \t]+(set|get) [ \t]+([A-Za-z0-9_]+)[ \t]*\(/\1 \2/p,property, properties/' \
--regex-actionscript='/^[ \t]*[(private| public|static) ( \t)]*var[  \t]+([A-Za-z0-9_]+)[\t]*/\1/v,variable, variables/' \
--regex-actionscript='/.*\.prototype \.([A-Za-z0-9 ]+)=([ \t]?)function( [  \t]?)*\(/\1/f,function, functions/' \
--regex-actionscript='/^[ \t]*class[ \t]+([A-Za-z0-9_]+)[ \t]*/\1/c,class, classes/'

.PHONY: ctags
ctags:
-rm -f TAGS
find . -name "*.as" -or -name "*.mxml" | ctags -eL - $(CTAGLANGS)
Take off the -e (ctags -L - $(CTAGLANGS)) if you're one of those vi users (I'm being polite because, after all, it's from them comes this tip)

Labels: , , , , , , , ,