From 566af2b009cab794475f74dda0bb4388300fdc14 Mon Sep 17 00:00:00 2001 From: Benson Chu Date: Fri, 20 Sep 2024 15:15:17 -0500 Subject: [PATCH] Jump to label in asm --- lisp/ti-config/work-asm-config.el | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lisp/ti-config/work-asm-config.el b/lisp/ti-config/work-asm-config.el index 4f57ffd..1e35f7f 100644 --- a/lisp/ti-config/work-asm-config.el +++ b/lisp/ti-config/work-asm-config.el @@ -29,6 +29,7 @@ (modify-syntax-entry ?- "-" asm-mode-syntax-table) (modify-syntax-entry ?+ "-" asm-mode-syntax-table) (modify-syntax-entry ?. "_" asm-mode-syntax-table) +(modify-syntax-entry ?@ "_" asm-mode-syntax-table) (modify-syntax-entry ?< "-" asm-mode-syntax-table) (add-hook 'asm-mode-hook @@ -119,6 +120,19 @@ (setq end (point))) (narrow-to-region start end))) +(defun asm-jump-to-label () + (interactive) + (xref-push-marker-stack) + (let ((addr (symbol-name (symbol-at-point)))) + (goto-char (point-min)) + (cond + ((string-match (rx line-start "@" (group (+ nonl))) addr) + (re-search-forward (format "<%s>:" (match-string 1 addr)))) + (t (re-search-forward + (concat "^" addr ":")))))) + +(define-key asm-mode-map (kbd "M-.") #'asm-jump-to-label) + (add-hook 'asm-mode-hook (lambda () (set (make-local-variable 'font-lock-multiline) t)