aboutsummaryrefslogtreecommitdiff
path: root/hcel-source.el
diff options
context:
space:
mode:
authorYuchen Pei <hi@ypei.me>2022-09-28 15:27:55 +1000
committerYuchen Pei <hi@ypei.me>2022-09-28 15:27:55 +1000
commit3cd88744e08431268052eeab5f0c8f53439eee17 (patch)
tree7118f59221f5bbfc076f16706fa2a61180c0385b /hcel-source.el
parentabb88a89b50b241a4492114c6fbce364af56f48e (diff)
allow toggle display of exported ids in hcel-outline mode
Diffstat (limited to 'hcel-source.el')
-rw-r--r--hcel-source.el26
1 files changed, 17 insertions, 9 deletions
diff --git a/hcel-source.el b/hcel-source.el
index 4151f63..e2158d1 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