From 0f77cab1b303bd23e84a48952834d7d607c089bd Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Tue, 6 Sep 2022 11:21:51 +1000 Subject: Adding hcel minor mode and find references in outline mode --- lisp/hcel-results.el | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) (limited to 'lisp/hcel-results.el') diff --git a/lisp/hcel-results.el b/lisp/hcel-results.el index 63f3c91..2636b41 100644 --- a/lisp/hcel-results.el +++ b/lisp/hcel-results.el @@ -179,15 +179,32 @@ Start by choosing a package." (defun hcel-find-references-at-point () "Find references of the identifier at point." (interactive) - (when-let ((id (alist-get 'externalId (hcel-lookup-identifier-at-point))) - (buffer-name (hcel-refs-format-id id))) - (with-current-buffer (get-buffer-create buffer-name) - (hcel-refs-mode) - (setq hcel-refs-id id) - (hcel-refs-update-references-package) - (switch-to-buffer-other-window buffer-name)))) + (hcel-find-references-internal hcel-package-id hcel-module-path + (get-text-property (point) 'identifier))) (define-key hcel-mode-map (kbd "M-?") 'hcel-find-references-at-point) +(defun hcel-minor-find-references-at-point () + (interactive) + (let ((props (text-properties-at (point)))) + (cond ((eq major-mode 'hcel-outline-mode) + (hcel-find-references-internal + (plist-get props 'package-id) + (plist-get props 'module-path) + (plist-get props 'internal-id))) + (t (error "%S not supported!" major-mode))))) + +(defun hcel-find-references-internal (package-id module-path identifier) + (when (and package-id module-path identifier) + (with-current-buffer (hcel-buffer-name package-id module-path) + (when-let* ((id (alist-get + 'externalId + (alist-get (intern identifier) hcel-identifiers))) + (buffer-name (hcel-refs-format-id id))) + (with-current-buffer (get-buffer-create buffer-name) + (hcel-refs-mode) + (setq hcel-refs-id id) + (hcel-refs-update-references-package)) + (switch-to-buffer-other-window buffer-name))))) ;; hcel-ids-mode (defcustom hcel-ids-per-page 20 "hcel-ids mode number of results per page." -- cgit v1.2.3