Skip to content
Browse files

Enhance smali-mode some more.

  • Loading branch information...
1 parent 6516b3b commit fe4053f575169bf2c886bbca1b2b78d005b1ad14 @nelhage committed Jan 1, 2011
Showing with 28 additions and 4 deletions.
  1. +28 −4 ddx.el
View
32 ddx.el
@@ -84,20 +84,40 @@
map)
"Keymap for DDX major mode")
+(defvar smali-mode-map
+ (let ((map (make-sparse-keymap)))
+ (set-keymap-parent map ddx-mode-map)
+ (define-key map (kbd "M-.") 'ddx-smali-goto-label)
+ map)
+ "Keymap for smali major mode")
+
(defvar ddx-mode-syntax-table
(let ((tbl (make-syntax-table)))
(modify-syntax-entry ?_ "w" tbl)
(modify-syntax-entry ?\# "<" tbl)
(modify-syntax-entry ?\n ">" tbl)
tbl))
+(defun ddx-indent-line ()
+ "Indent the current line as DDX code"
+ (interactive)
+
+ )
+
(defun ddx-goto-label (&optional label)
(interactive)
(if (not label)
(setq label (thing-at-point 'word)))
(beginning-of-buffer)
(re-search-forward (concat "^" label ":")))
+(defun ddx-smali-goto-label (&optional label)
+ (interactive)
+ (if (not label)
+ (setq label (thing-at-point 'word)))
+ (beginning-of-buffer)
+ (re-search-forward (concat "^\\s +:" label "\\>")))
+
(defface ddx-label-highlight
'((t :background "#003"))
"Face to highlabel selected label in ddx-mode")
@@ -172,12 +192,16 @@
(ddx-reset-timer)
(require 'javadoc))
-(defun smali-mode ()
- (interactive)
- (let ((ddx-label-re "\\s :\\([a-zA-Z0-9_]+\\)"))
- (ddx-mode)))
+(define-derived-mode smali-mode ddx-mode "smali"
+ "Major mode to edit .smali assembly files"
+ (set (make-local-variable 'ddx-label-re)
+ "\\s :\\([a-zA-Z0-9_]+\\)")
+ (ddx-collect-labels)
+ (font-lock-add-keywords nil (list (cons ddx-label-re font-lock-constant-face)))
+ (use-local-map smali-mode-map))
(add-to-list 'auto-mode-alist (cons "\\.ddx$" 'ddx-mode))
+(add-to-list 'auto-mode-alist (cons "\\.smali$" 'smali-mode))
(defmacro save-match-data (&rest body)
"Execute BODY, preserving any pre-existing match data"

0 comments on commit fe4053f

Please sign in to comment.
Something went wrong with that request. Please try again.