aboutsummaryrefslogtreecommitdiff
path: root/hcel-results.el
diff options
context:
space:
mode:
authorYuchen Pei <hi@ypei.me>2022-09-23 14:18:11 +1000
committerYuchen Pei <hi@ypei.me>2022-09-23 14:18:11 +1000
commitf73cbee6f83f948202d0ea3fb8775b49562295be (patch)
treea8f4aeda7fdb80e89d4da2e2b8e167873f8ccc6f /hcel-results.el
parent138869fcbec02630b4311b88118bc8d48584ea2d (diff)
fixing compiler warnings and removing major-mode
Diffstat (limited to 'hcel-results.el')
-rw-r--r--hcel-results.el27
1 files changed, 13 insertions, 14 deletions
diff --git a/hcel-results.el b/hcel-results.el
index 465df14..6d6c2c9 100644
--- a/hcel-results.el
+++ b/hcel-results.el
@@ -75,26 +75,25 @@
(defun hcel-results-next-page ()
(interactive)
- ;; FIXME: Using `major-mode' is a code smell.
- (unless (memq major-mode '(hcel-refs-mode hcel-ids-mode))
+ (unless (derived-mode-p 'hcel-refs-mode 'hcel-ids-mode)
(error "Not in hcel-refs or hcel-ids mode: %S" major-mode))
(when (= hcel-results-page-number hcel-results-max-page-number)
(error "Already on the last page"))
(setq hcel-results-page-number (1+ hcel-results-page-number))
- (cond ((eq major-mode 'hcel-refs-mode) (hcel-refs-update-references))
- ((eq major-mode 'hcel-ids-mode) (hcel-ids-update))
+ (cond ((derived-mode-p 'hcel-refs-mode) (hcel-refs-update-references))
+ ((derived-mode-p 'hcel-ids-mode) (hcel-ids-update))
(t (error "wrong major mode: %S" major-mode)))
(hcel-results-next-error-internal 1))
(defun hcel-results-previous-page ()
(interactive)
- (unless (memq major-mode '(hcel-refs-mode hcel-ids-mode))
+ (unless (derived-mode-p 'hcel-refs-mode 'hcel-ids-mode)
(error "Not in hcel-refs or hcel-ids mode: %S" major-mode))
(when (= hcel-results-page-number 1)
(error "Already on the first page."))
(setq hcel-results-page-number (1- hcel-results-page-number))
- (cond ((eq major-mode 'hcel-refs-mode) (hcel-refs-update-references))
- ((eq major-mode 'hcel-ids-mode) (hcel-ids-update))
+ (cond ((derived-mode-p 'hcel-refs-mode) (hcel-refs-update-references))
+ ((derived-mode-p 'hcel-ids-mode) (hcel-ids-update))
(t (error "wrong major mode: %S" major-mode)))
(goto-char (point-max))
(hcel-results-next-error-internal -1))
@@ -119,7 +118,7 @@
(defun hcel-refs-update-references ()
"Find references and update the current hcel-refs-mode buffer."
- (unless (eq major-mode 'hcel-refs-mode)
+ (unless (derived-mode-p 'hcel-refs-mode)
(error "Not in hcel-refs mode!"))
(let ((inhibit-read-only t)
(modules-refs
@@ -183,7 +182,7 @@
Start by choosing a package."
(interactive)
- (unless (eq major-mode 'hcel-refs-mode)
+ (unless (derived-mode-p 'hcel-refs-mode)
(error "Not in hcel-refs mode!"))
(let* ((global-refs (hcel-api-global-references hcel-refs-id))
(name (cadddr (split-string hcel-refs-id "|")))
@@ -215,13 +214,13 @@ Start by choosing a package."
(defun hcel-minor-find-references-at-point ()
(interactive)
- (cond ((or (eq major-mode 'hcel-outline-mode)
+ (cond ((or (derived-mode-p 'hcel-outline-mode)
(eq (current-buffer) eldoc--doc-buffer))
(hcel-find-references-internal
(hcel-text-property-near-point 'package-id)
(hcel-text-property-near-point 'module-path)
(hcel-text-property-near-point 'internal-id)))
- ((eq major-mode 'hcel-ids-mode)
+ ((derived-mode-p 'hcel-ids-mode)
(hcel-find-references-internal
(alist-get 'packageId (hcel-text-property-near-point 'location-info))
(alist-get 'modulePath (hcel-text-property-near-point 'location-info))
@@ -263,7 +262,7 @@ Start by choosing a package."
(hcel-minor-mode 1))
(defun hcel-ids-update ()
- (unless (eq major-mode 'hcel-ids-mode)
+ (unless (derived-mode-p 'hcel-ids-mode)
(error "Not in hcel-ids mode!"))
(when (and (eq hcel-ids-scope 'package) (not hcel-ids-package-id))
(error "No package-id supplied for identifiers call!"))
@@ -322,7 +321,7 @@ Start by choosing a package."
(defun hcel-ids-update-query (query)
"Search for identities matching query."
(interactive (list (progn
- (unless (eq major-mode 'hcel-ids-mode)
+ (unless (derived-mode-p 'hcel-ids-mode)
(error "Not in hcel-ids mode!"))
(read-string "Query: " hcel-ids-query))))
(setq hcel-ids-query query
@@ -388,7 +387,7 @@ Start by choosing a package."
(interactive (list
(let ((minibuffer-allow-text-properties t)
(package-id hcel-package-id))
- (unless (eq major-mode 'hcel-mode)
+ (unless (derived-mode-p 'hcel-mode)
(error "Not in hcel-mode!"))
(completing-read
(format "Search for identifier in %s: "