If you use emacs as your editor while programming in actionscript, then this tweak could be really useful for you.
Emacs has got Imenu facility which allows finding major definitions in a file/buffer. In the context of actionscript this includes class definitions, private/protected/public variables, getters/setters and ofcourse functions. Thus, using Imenu you can bind your keys so that it jump on the definition of a function when those keys are pressed. When you change the contents of the file, you can press
*Rescan*
to make it re-read the buffer and generate a new indexing of the file contents. You can also set
'imenu-auto-rescan'
to a non-nil value so that it automatically scans your file, everytime you make any changes. Here is screenshot of the Imenu:
actionscript-mode is already available for emacs and thus by using the mode you can get all sort of code-coloring. After adding actionscript-mode to your mode-list, you need to add this code to your .emacs to get the desired functionality.
(add-hook 'actionscript-mode-hook 'imenu-add-menubar-index)
(add-hook 'actionscript-mode-hook 'actionscript-init-imenu)
(defun actionscript-init-imenu ()
(interactive)
(setq imenu-generic-expression as-imenu-as-generic-expression)
(global-set-key [mouse-3] 'imenu))(defvar as-imenu-as-generic-expression
` (
("variables"
,(concat
"^"
"[ t]*(public|protected|mx_internal|private)"
"[ t]+var"
"[ t]+([a-zA-Z_][a-zA-Z0-9_]*)" ; match function name
"[ t]*:([a-zA-Z_][a-zA-Z0-9_]*)" ), 2)
;; Getters
("Getters"
,(concat
"^"
"[ t]*(override[ tn]+)?"
"[ t]*(public|protected|mx_internal|private)"
"[ t]+function"
"[ t]+"
"(get[ t]+([a-zA-Z_][a-zA-Z0-9_]*)[ t]*)()"
) 3)
;;setters
("setters"
,(concat
"^"
"[ t]*(override[ tn]+)?"
"[ t]*(public|protected|mx_internal|private)"
"[ t]+function"
"[ t]+"
"(set[ t]+([a-zA-Z_][a-zA-Z0-9_]*)[ t]*)"
"("
"([a-zA-Z_][a-zA-Z0-9_]*):([a-zA-Z_][a-zA-Z0-9_]*)[ tn]*"
")"
) 3)
;; Class definitions
(nil
,(concat
"^"
"((public|protected|mx_internal|private)[ t]+)?"
"(class|interface)[ t]+"
"(" ; the string we want to get
"[a-zA-Z0-9_]+" ; class name
")"
"[ tn]*"
"(extends [ tn]*[a-zA-Z0-9_]+)?"
"[ tn]*";;[:{]"
"(implements [ tn]*([a-zA-Z0-9_]+[,][ tn]*)*[a-zA-Z0-9_])?"
"[ tn]*";;[:{]"
) 4)
;; General function name regexp
(nil
,(concat
"^"
"[ t]*(override[ tn]+)?"
"[ t]*(public|protected|mx_internal|private)"
"([ t]+static)?"
"[ t]+function"
"[ t]+([a-zA-Z_][a-zA-Z0-9_]*)" ; match function name
"[ t]*("
"[^)]*)"
) 4)
)
"Imenu generic expression for C++ mode. See `imenu-generic-expression'.")
Attached is my .emacs file
Filed under: actionscript, emacs
What actionscript-mode do you use ?
the one found on pettomato.com ?
Yes I am using the actionscript-mode found on pettomato.com