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

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

[elpa] externals/hcel f73cbee6f8 3/3: fixing compiler warnings and remov


From: ELPA Syncer
Subject: [elpa] externals/hcel f73cbee6f8 3/3: fixing compiler warnings and removing major-mode
Date: Fri, 23 Sep 2022 00:57:45 -0400 (EDT)

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

    fixing compiler warnings and removing major-mode
---
 hcel-client.el  |  1 +
 hcel-outline.el |  2 +-
 hcel-results.el | 27 +++++++++++++--------------
 hcel-source.el  | 30 ++++++++++++++++--------------
 4 files changed, 31 insertions(+), 29 deletions(-)

diff --git a/hcel-client.el b/hcel-client.el
index 5bd9946f13..3af6882129 100644
--- a/hcel-client.el
+++ b/hcel-client.el
@@ -18,6 +18,7 @@
 ;; License along with hcel.  If not, see <https://www.gnu.org/licenses/>.
 
 (require 'hcel-utils)
+(require 'json)
 (defcustom hcel-host "localhost:8080"
   "hcel server host"
   :group 'hcel :type '(string))
diff --git a/hcel-outline.el b/hcel-outline.el
index 2c7913cb35..962e5aa786 100644
--- a/hcel-outline.el
+++ b/hcel-outline.el
@@ -207,7 +207,7 @@ update in the outline mode too."
   :lighter " hcel-outline-follow"
   :after-hook
   (if hcel-outline-follow-mode
-      (if (not (eq major-mode 'hcel-outline-mode))
+      (if (not (derived-mode-p 'hcel-outline-mode))
           (error "Not in hcel-outline mode!")
         (add-hook 'post-command-hook
                   #'hcel-outline-open-thing-at-point-other-window nil t))
diff --git a/hcel-results.el b/hcel-results.el
index 465df1485f..6d6c2c93f0 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: "
diff --git a/hcel-source.el b/hcel-source.el
index 0d451b58e5..f6e5d55060 100644
--- a/hcel-source.el
+++ b/hcel-source.el
@@ -17,7 +17,12 @@
 ;; You should have received a copy of the GNU Affero General Public
 ;; License along with hcel.  If not, see <https://www.gnu.org/licenses/>.
 
+(require 'array)
+(require 'dom)
 (require 'hcel-client)
+(require 'hcel-outline)
+(require 'hcel-results)
+(require 'xref)
 
 (defvar-local hcel-identifiers nil)
 (defvar-local hcel-declarations nil)
@@ -66,7 +71,7 @@ When FORCE is non-nil, kill existing source buffer if any."
 (defun hcel-reload-module-source ()
   "Reloads current module source."
   (interactive)
-  (if (equal major-mode 'hcel-mode)
+  (if (derived-mode-p 'hcel-mode)
       (switch-to-buffer
        (hcel-load-module-source hcel-package-id hcel-module-path t))
     (error "Not in hcel-mode!")))
@@ -119,11 +124,8 @@ the location with pulsing.
    (read-buffer
     "Switch to buffer: " nil t
                (lambda (buffer)
-                 (equal 
-                  (buffer-local-value
-        'major-mode
-        (get-buffer (if (stringp buffer) buffer (car buffer))))
-                  'hcel-mode)))))
+                 (with-current-buffer (if (stringp buffer) buffer (car buffer))
+                   (derived-mode-p 'hcel-mode))))))
 (define-key hcel-mode-map "b" #'hcel-switch-buffer)
 
 (defun hcel-lookup-occurrence-at-point ()
@@ -260,12 +262,12 @@ the location with pulsing.
                             'internal-id identifier 'string=)
                            (point)))))
               (docstring
-               (cond ((eq major-mode 'hcel-outline-mode)
+               (cond ((derived-mode-p 'hcel-outline-mode)
                       (hcel-render-type-internal
                        (hcel-text-property-near-point 'package-id)
                        (hcel-text-property-near-point 'module-path)
                        identifier))
-                     ((eq major-mode 'hcel-ids-mode)
+                     ((derived-mode-p 'hcel-ids-mode)
                       (hcel-render-type-internal
                        (alist-get 'packageId (hcel-text-property-near-point 
'location-info))
                        (alist-get 'modulePath (hcel-text-property-near-point 
'location-info))
@@ -286,12 +288,12 @@ the location with pulsing.
 
 (defun hcel-minor-eldoc-docs (cb)
   (when-let* ((docstring
-               (cond ((eq major-mode 'hcel-outline-mode)
+               (cond ((derived-mode-p 'hcel-outline-mode)
                       (hcel-id-docs-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-id-docs-internal
                        (alist-get 'packageId (hcel-text-property-near-point 
'location-info))
                        (alist-get 'modulePath (hcel-text-property-near-point 
'location-info))
@@ -404,7 +406,7 @@ the location with pulsing.
 
 ;; imenu
 (defun hcel-imenu-create-index ()
-  (unless (eq major-mode 'hcel-mode)
+  (unless (derived-mode-p 'hcel-mode)
     (error "Not in hcel-mode!"))
   (mapcar
    (lambda (decl)
@@ -435,13 +437,13 @@ the location with pulsing.
   (hcel-minor-find-definition-at-point))
 (defun hcel-minor-find-definition-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-definition-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-definition-internal
           (alist-get 'packageId (hcel-text-property-near-point 'location-info))
           (alist-get 'modulePath (hcel-text-property-near-point 
'location-info))
@@ -504,7 +506,7 @@ the location with pulsing.
    ((null hcel-minor-mode)
     (remove-hook 'eldoc-documentation-functions #'hcel-minor-eldoc-id-type t)
     (remove-hook 'eldoc-documentation-functions #'hcel-minor-eldoc-docs t))
-   ((not (or (memq major-mode hcel-minor-major-modes)
+   ((not (or (apply 'derived-mode-p hcel-minor-major-modes)
              (eq (current-buffer) eldoc--doc-buffer)))
     (setq hcel-minor-mode nil)
     (error "Not in one of the supported modes (%s) or the eldoc buffer."



reply via email to

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