emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/hcel abb88a89b5 3/4: do not try to go to haddorg if the


From: ELPA Syncer
Subject: [elpa] externals/hcel abb88a89b5 3/4: do not try to go to haddorg if the identifier is not exported
Date: Wed, 28 Sep 2022 01:57:38 -0400 (EDT)

branch: externals/hcel
commit abb88a89b50b241a4492114c6fbce364af56f48e
Author: Yuchen Pei <hi@ypei.me>
Commit: Yuchen Pei <hi@ypei.me>

    do not try to go to haddorg if the identifier is not exported
---
 hcel-haddorg.el | 38 ++++++++++++++++++++++----------------
 1 file changed, 22 insertions(+), 16 deletions(-)

diff --git a/hcel-haddorg.el b/hcel-haddorg.el
index f757e24388..90b0ce6fc4 100644
--- a/hcel-haddorg.el
+++ b/hcel-haddorg.el
@@ -19,6 +19,7 @@
 (require 'hcel-source)
 (require 'hcel-client)
 (require 'hcel-utils)
+(require 'json)
 (require 'org)
 
 (defcustom hcel-haddorg-dir "~/Projects/sedoc/haddock/org-output"
@@ -56,22 +57,27 @@ is in ghc-8.10.1, hcel will attempt to look up in 
ghc-9.2.2.org.")
 (defun hcel-identifier-at-point-to-haddorg ()
   (interactive)
   (when-let* ((identifier (hcel-text-property-near-point 'identifier))
-              (external-id (alist-get 'externalId
-                                      (alist-get (intern identifier)
-                                                 hcel-identifiers))))
-    (let* ((splitted (split-string external-id "|"))
-           (package-id (car splitted))
-           (module-name (cadr splitted))
-           (entity (cond ((equal (caddr splitted) "Typ") "t")
-                         ((equal (caddr splitted) "Val") "v")
-                         (t nil)))
-           (name (cadddr splitted))
-           (file-name (hcel-haddorg-fuzzy-version-match package-id))
-           (custom-id (concat module-name "/" entity "/" name)))
-      (unless file-name
-        (error "Cannot find org file for %s" package-id))
-      (org-link-open-from-string
-       (format "[[file:%s::#%s]]" file-name custom-id)))))
+              (id (alist-get (intern identifier) hcel-identifiers))
+              (exported (alist-get 'isExported id))
+              (external-id (alist-get 'externalId id)))
+    (if (and (eq exported json-false)
+             ;; FIXME: Hacky.  ExactLocation implies identifier is declared in
+             ;; the current module.
+             (equal (alist-get 'tag (alist-get 'locationInfo id)) 
"ExactLocation"))
+        (message "%s is not exported." (hcel-occ-symbol-at-point))
+      (let* ((splitted (split-string external-id "|"))
+             (package-id (car splitted))
+             (module-name (cadr splitted))
+             (entity (cond ((equal (caddr splitted) "Typ") "t")
+                           ((equal (caddr splitted) "Val") "v")
+                           (t nil)))
+             (name (cadddr splitted))
+             (file-name (hcel-haddorg-fuzzy-version-match package-id))
+             (custom-id (concat module-name "/" entity "/" name)))
+        (if file-name
+            (org-link-open-from-string
+             (format "[[file:%s::#%s]]" file-name custom-id))
+          (message "Cannot find org file for %s" package-id))))))
 
 (defun hcel-haddorg-fuzzy-version-match (package-id)
   (let ((exact-match



reply via email to

[Prev in Thread] Current Thread [Next in Thread]