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

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

[elpa] externals/hcel 3cd88744e0 4/4: allow toggle display of exported i


From: ELPA Syncer
Subject: [elpa] externals/hcel 3cd88744e0 4/4: allow toggle display of exported ids in hcel-outline mode
Date: Wed, 28 Sep 2022 01:57:38 -0400 (EDT)

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

    allow toggle display of exported ids in hcel-outline mode
---
 hcel-outline.el | 19 +++++++++++++++----
 hcel-source.el  | 26 +++++++++++++++++---------
 2 files changed, 32 insertions(+), 13 deletions(-)

diff --git a/hcel-outline.el b/hcel-outline.el
index a192e07285..ea8f9199cc 100644
--- a/hcel-outline.el
+++ b/hcel-outline.el
@@ -27,8 +27,8 @@
 
 (defvar hcel-outline-mode-map
   (let ((kmap (make-sparse-keymap)))
-    (define-key kmap "n"  #'outline-next-visible-heading)
-    (define-key kmap "p"  #'outline-previous-visible-heading)
+    (define-key kmap "n"  #'next-logical-line)
+    (define-key kmap "p"  #'previous-logical-line)
     (define-key kmap "f"  #'outline-forward-same-level)
     (define-key kmap "F"  #'hcel-outline-follow-mode)
     (define-key kmap "b"  #'outline-backward-same-level)
@@ -140,6 +140,12 @@ update in the outline mode too."
           ((eq thing 'module) (hcel-outline-load-identifiers-at-point))
           (t nil))))
 
+(defun hcel-outline-toggle-exported ()
+  (interactive)
+  (if (memq 'hcel-unexported buffer-invisibility-spec)
+      (remove-from-invisibility-spec 'hcel-unexported)
+    (add-to-invisibility-spec 'hcel-unexported)))
+
 (defun hcel-outline-load-identifiers-at-point ()
   (interactive)
   (unless (eq (get-text-property (point) 'thing) 'module)
@@ -158,7 +164,9 @@ update in the outline mode too."
                   (y-or-n-p "Open module source?"))
           (with-current-buffer
               (hcel-load-module-source package-id module-path)
-            (setq imenu-index (save-excursion (hcel-imenu-create-index))))
+            (setq imenu-index
+                  (save-excursion
+                    (hcel-imenu-create-index))))
           (beginning-of-line 2)
           (mapc
            (lambda (pair)
@@ -170,7 +178,10 @@ update in the outline mode too."
                'thing 'identifier
                'package-id package-id
                'module-path module-path
-               'position (cdr pair))))
+               'position (cdr pair)
+               'invisible (unless
+                              (get-text-property 1 'exported (car pair))
+                            'hcel-unexported))))
            imenu-index))))))
 
 (defun hcel-outline-open-module-source-at-point (&optional other-window)
diff --git a/hcel-source.el b/hcel-source.el
index 4151f631d7..e2158d16cc 100644
--- a/hcel-source.el
+++ b/hcel-source.el
@@ -21,6 +21,7 @@
 (require 'dom)
 (require 'hcel-client)
 (require 'text-property-search)
+(require 'json)
 (require 'xref)
 
 (defvar-local hcel-identifiers nil)
@@ -373,19 +374,26 @@ the location with pulsing.
 
 ;; imenu
 (defun hcel-imenu-create-index ()
+  (hcel-imenu-create-index-internal))
+
+(defun hcel-imenu-create-index-internal (&optional exported-only)
   (unless (derived-mode-p 'hcel-mode)
     (error "Not in hcel-mode!"))
   (goto-char (point-min))
-  (let ((index) (match))
+  (let ((index) (match) (exported))
     (while (setq match (text-property-search-forward 'declaration))
-      (push (cons
-             (hcel-render-components
-              (alist-get 'components
-                         (alist-get 'declType (prop-match-value match)))
-              (alist-get 'name (prop-match-value match)))
-             (1- (point)))
-            index))
-    index))
+      (setq exported (eq (alist-get 'isExported (prop-match-value match)) t))
+      (unless (and exported-only (not exported))
+        (push (cons
+               (propertize
+                (hcel-render-components
+                 (alist-get 'components
+                            (alist-get 'declType (prop-match-value match)))
+                 (alist-get 'name (prop-match-value match)))
+                'exported exported)
+               (1- (point)))
+              index)))
+    (reverse index)))
 (define-key hcel-mode-map "j" #'imenu)
 
 ;; xref



reply via email to

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