-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathxref-asm.el
More file actions
52 lines (38 loc) · 1.29 KB
/
Copy pathxref-asm.el
File metadata and controls
52 lines (38 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
;;; xref-asm.el --- Xref for asm-mode -*- lexical-binding: t; -*-
;; Copyright 2019 fmdkdd
;; This file is not part of GNU Emacs.
;;; Commentary:
;; (add-hook 'asm-mode-hook #'xref-asm-activate)
;;; Code:
(require 'xref)
(defun xref-asm-xref-backend ()
"ASM backend for xref."
'xref-asm)
(cl-defmethod xref-backend-identifier-at-point ((_backend (eql xref-asm)))
(symbol-name (symbol-at-point)))
(cl-defmethod xref-backend-definitions ((_backend (eql xref-asm)) symbol)
(mapcar
(lambda (candidate)
(xref-make (car candidate)
(xref-make-buffer-location (current-buffer)
(cdr candidate))))
(xref-asm-candidates symbol)))
(defun xref-asm-candidates (symbol)
"Return list of labels matching SYMBOL."
(save-excursion
(goto-char (point-min))
(let ((labels))
;; Match labels and constants
(while (re-search-forward (format "^\\s *@?%s\\s *[:=]" symbol) nil t)
(push (cons (match-string-no-properties 0) (point))
labels))
labels)))
;;;###autoload
(defun xref-asm-activate ()
"Register the xref asm backend."
(add-to-list 'xref-backend-functions #'xref-asm-xref-backend))
(provide 'xref-asm)
;;; xref-asm.el ends here
;; Local Variables:
;; eval: (fmdkdd/byte-compile-on-save)
;; End: