-
Notifications
You must be signed in to change notification settings - Fork 11
/
hsys-xref.el
76 lines (59 loc) · 2.48 KB
/
hsys-xref.el
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
;;; hsys-xref.el --- GNU Hyperbole support functions for "xref.el" -*- lexical-binding: t; -*-
;;
;; Author: Bob Weiner
;;
;; Orig-Date: 24-Aug-91
;; Last-Mod: 14-Apr-24 at 19:03:32 by Bob Weiner
;;
;; SPDX-License-Identifier: GPL-3.0-or-later
;;
;; Copyright (C) 1991-2024 Free Software Foundation, Inc.
;; See the "HY-COPY" file for license information.
;;
;; This file is part of GNU Hyperbole.
;;; Commentary:
;;; Code:
;;; ************************************************************************
;;; Requirements
;;; ************************************************************************
(require 'xref)
;;; ************************************************************************
;;; Public declarations
;;; ************************************************************************
(declare-function smart-emacs-lisp-mode-p "hmouse-tag")
;;; ************************************************************************
;;; Public functions
;;; ************************************************************************
(defun hsys-xref-definitions (identifier)
"Return a list of all definitions of string IDENTIFIER."
(let* ((elisp-flag (smart-emacs-lisp-mode-p t))
(xref-backend (or (and elisp-flag
(fboundp 'ert-test-boundp)
(ert-test-boundp (intern-soft identifier))
(boundp 'xref-etags-mode)
'etags)
(xref-find-backend)))
(xref-items (xref-backend-definitions xref-backend identifier)))
xref-items))
(defun hsys-xref-definition (identifier)
"Return the first definition of string IDENTIFIER."
(car (hsys-xref-definitions identifier)))
(defun hsys-xref-identifier-at-point ()
(xref-backend-identifier-at-point (xref-find-backend)))
(defun hsys-xref-item-buffer (item)
"Return the buffer in which xref ITEM is defined."
(marker-buffer (save-excursion (xref-location-marker (xref-item-location item)))))
(defun hsys-xref-item-position (item)
"Return the buffer position where xref ITEM is defined."
(marker-position (save-excursion (xref-location-marker (xref-item-location item)))))
;;; ************************************************************************
;;; Private functions
;;; ************************************************************************
(defun xref--item-at-point ()
"Fix next xref function to handle when called at beginning of buffer."
(get-text-property
(max (point-min) (if (eolp) (1- (point)) (point)))
'xref-item))
(defalias 'hsys-xref-item-at-point #'xref--item-at-point)
(provide 'hsys-xref)
;;; hsys-xref.el ends here