aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitry Gutov2015-06-01 22:45:15 +0300
committerDmitry Gutov2015-06-02 18:47:42 +0300
commit64f2d346b762a6e3180eba92b5cc96f82f370687 (patch)
treef6c34314d431dec65c408b48f7e896ea8c96e578
parent98cb43fb0d6b29260c96662ee18f3cfbc4878c97 (diff)
downloademacs-64f2d346b762a6e3180eba92b5cc96f82f370687.tar.gz
emacs-64f2d346b762a6e3180eba92b5cc96f82f370687.zip
Move xref-elisp-location to elisp-mode.el
* lisp/progmodes/xref.el (xref-elisp-location) (xref-make-elisp-location, xref-location-marker): Remove here. (xref--xref): Don't limit the type of the location slot. * lisp/progmodes/elisp-mode.el (xref-elisp-location): Define as a cl-struct here. (xref-location-marker): Move here.
-rw-r--r--lisp/progmodes/elisp-mode.el19
-rw-r--r--lisp/progmodes/xref.el27
2 files changed, 19 insertions, 27 deletions
diff --git a/lisp/progmodes/elisp-mode.el b/lisp/progmodes/elisp-mode.el
index bcbf1d57edc..968bb21f08a 100644
--- a/lisp/progmodes/elisp-mode.el
+++ b/lisp/progmodes/elisp-mode.el
@@ -579,7 +579,6 @@ It can be quoted, or be inside a quoted form."
579 579
580;;; Xref backend 580;;; Xref backend
581 581
582(declare-function xref-make-elisp-location "xref" (symbol type file))
583(declare-function xref-make-bogus-location "xref" (message)) 582(declare-function xref-make-bogus-location "xref" (message))
584(declare-function xref-make "xref" (description location)) 583(declare-function xref-make "xref" (description location))
585(declare-function xref-collect-matches "xref" (input dir &optional kind)) 584(declare-function xref-collect-matches "xref" (input dir &optional kind))
@@ -697,6 +696,24 @@ It can be quoted, or be inside a quoted form."
697(defun elisp--xref-identifier-completion-table () 696(defun elisp--xref-identifier-completion-table ()
698 elisp--xref-identifier-completion-table) 697 elisp--xref-identifier-completion-table)
699 698
699(cl-defstruct (xref-elisp-location
700 (:constructor xref-make-elisp-location (symbol type file)))
701 "Location of an Emacs Lisp symbol definition."
702 symbol type file)
703
704(cl-defmethod xref-location-marker ((l xref-elisp-location))
705 (pcase-let (((cl-struct xref-elisp-location symbol type file) l))
706 (let ((buffer-point
707 (pcase type
708 (`defun (find-function-search-for-symbol symbol nil file))
709 ((or `defvar `defface)
710 (find-function-search-for-symbol symbol type file))
711 (`feature
712 (cons (find-file-noselect file) 1)))))
713 (with-current-buffer (car buffer-point)
714 (goto-char (or (cdr buffer-point) (point-min)))
715 (point-marker)))))
716
700;;; Elisp Interaction mode 717;;; Elisp Interaction mode
701 718
702(defvar lisp-interaction-mode-map 719(defvar lisp-interaction-mode-map
diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el
index c9bffc6fc6f..3bc66f884eb 100644
--- a/lisp/progmodes/xref.el
+++ b/lisp/progmodes/xref.el
@@ -143,38 +143,13 @@ actual location is not known.")
143 143
144(cl-defmethod xref-location-group ((_ xref-bogus-location)) "(No location)") 144(cl-defmethod xref-location-group ((_ xref-bogus-location)) "(No location)")
145 145
146;; This should be in elisp-mode.el, but it's preloaded, and we can't
147;; preload defclass and defmethod (at least, not yet).
148(defclass xref-elisp-location (xref-location)
149 ((symbol :type symbol :initarg :symbol)
150 (type :type symbol :initarg :type)
151 (file :type string :initarg :file
152 :reader xref-location-group))
153 :documentation "Location of an Emacs Lisp symbol definition.")
154
155(defun xref-make-elisp-location (symbol type file)
156 (make-instance 'xref-elisp-location :symbol symbol :type type :file file))
157
158(cl-defmethod xref-location-marker ((l xref-elisp-location))
159 (with-slots (symbol type file) l
160 (let ((buffer-point
161 (pcase type
162 (`defun (find-function-search-for-symbol symbol nil file))
163 ((or `defvar `defface)
164 (find-function-search-for-symbol symbol type file))
165 (`feature
166 (cons (find-file-noselect file) 1)))))
167 (with-current-buffer (car buffer-point)
168 (goto-char (or (cdr buffer-point) (point-min)))
169 (point-marker)))))
170
171 146
172;;; Cross-reference 147;;; Cross-reference
173 148
174(defclass xref--xref () 149(defclass xref--xref ()
175 ((description :type string :initarg :description 150 ((description :type string :initarg :description
176 :reader xref--xref-description) 151 :reader xref--xref-description)
177 (location :type xref-location :initarg :location 152 (location :initarg :location
178 :reader xref--xref-location)) 153 :reader xref--xref-location))
179 :comment "An xref is used to display and locate constructs like 154 :comment "An xref is used to display and locate constructs like
180variables or functions.") 155variables or functions.")