From dae8c96bfdcf81ff6e39890de2d3d1be788e552f Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Wed, 21 Sep 2022 15:14:50 +1000 Subject: Fixing some compile warnings --- hcel-client.el | 14 +++++++++++--- hcel-haddorg.el | 1 + hcel-outline.el | 8 ++++---- hcel-results.el | 35 ++++++++++++++++++----------------- hcel-source.el | 26 ++++++++++++++++---------- hcel-utils.el | 7 ++++--- 6 files changed, 54 insertions(+), 37 deletions(-) diff --git a/hcel-client.el b/hcel-client.el index 775d878..eb43dc9 100644 --- a/hcel-client.el +++ b/hcel-client.el @@ -17,12 +17,13 @@ ;; You should have received a copy of the GNU Affero General Public ;; License along with hcel. If not, see . +(require 'hcel-utils) (defcustom hcel-host "localhost:8080" "hcel server host" - :group 'hcel) + :group 'hcel :type '(string)) (defcustom hcel-indexed-dir "/.haskell-code-explorer" "hcel indexed dir" - :group 'hcel) + :group 'hcel :type '(string)) (defvar hcel-client-buffer-name "*hcel-client*") @@ -140,7 +141,8 @@ (insert "[" (current-time-string) "] Request: " url "\n")) (with-current-buffer (url-retrieve-synchronously url t) (let ((header) (status) (fields)) - (delete-http-header) + (hcel-delete-http-header) + (goto-char (point-min)) (setq header (hcel-parse-http-header (car kill-ring)) status (alist-get 'status header) fields (alist-get 'fields header)) @@ -159,4 +161,10 @@ (json-read))) (error "HTTP error: %s" (buffer-substring (point) (point-max))))))) +(defun hcel-delete-http-header () + (save-excursion + (goto-char (point-min)) + (kill-region (point) (progn (re-search-forward "\r?\n\r?\n") + (point))))) + (provide 'hcel-client) diff --git a/hcel-haddorg.el b/hcel-haddorg.el index afb783f..732c6d0 100644 --- a/hcel-haddorg.el +++ b/hcel-haddorg.el @@ -19,6 +19,7 @@ (require 'hcel-source) (require 'hcel-client) (require 'hcel-utils) +(require 'org) (defun hcel-haddorg-to-hcel-definition () (interactive) diff --git a/hcel-outline.el b/hcel-outline.el index c40ccf1..d485844 100644 --- a/hcel-outline.el +++ b/hcel-outline.el @@ -17,7 +17,9 @@ ;; You should have received a copy of the GNU Affero General Public ;; License along with hcel. If not, see . +(require 'hcel-utils) (require 'hcel-source) +(require 'outline) (defvar hcel-outline-buffer-name "*hcel-outline*") (defvar hcel-outline-indentation 2) @@ -37,9 +39,7 @@ kmap)) (define-derived-mode hcel-outline-mode outline-mode "hcel-outline" "Major mode for browsing Haskell codebases." - (setq-local package-filter nil - module-filter nil - outline-regexp "\\( *\\)." + (setq-local outline-regexp "\\( *\\)." outline-level (lambda () (1+ (/ (length (match-string 1)) hcel-outline-indentation))) buffer-read-only t) @@ -116,7 +116,7 @@ update in the outline mode too." 'package-id package-id 'module-path module 'folded t))) - (hcel-list-modules (print package-id))))))) + (hcel-list-modules package-id)))))) (defun hcel-outline-toggle-children () (interactive) diff --git a/hcel-results.el b/hcel-results.el index 8e5091c..39644d0 100644 --- a/hcel-results.el +++ b/hcel-results.el @@ -23,6 +23,7 @@ ;; compilation-mode. ;;; Code: +(require 'hcel-source) (require 'hcel-utils) (eval-when-compile (require 'compile)) @@ -70,6 +71,7 @@ (hcel-load-module-location-info (get-text-property (point) 'location-info))) (defvar-local hcel-results-page-number nil) +(defvar-local hcel-results-max-page-number nil) (defun hcel-results-next-page () (interactive) @@ -100,15 +102,14 @@ ;; hcel-refs-mode (defcustom hcel-refs-per-page 50 "hcel refs number of results per page." - :group 'hcel-refs) + :group 'hcel-refs :type '(natnum)) + +(defvar-local hcel-refs-id nil) +(defvar-local hcel-refs-package-id nil) (define-compilation-mode hcel-refs-mode "hcel-refs" "Major mode for showing references" - (setq-local next-error-function #'hcel-results-next-error - hcel-refs-id nil - hcel-refs-package-id nil - hcel-results-page-number nil - hcel-results-max-page-number nil)) + (setq-local next-error-function #'hcel-results-next-error)) (define-key hcel-refs-mode-map (kbd "M-n") #'hcel-results-next-error-no-open) @@ -247,19 +248,19 @@ Start by choosing a package." ;; hcel-ids-mode (defcustom hcel-ids-per-page 20 "hcel-ids mode number of results per page." - :group 'hcel-ids) + :group 'hcel-ids :type '(natnum)) (defcustom hcel-ids-live-per-page 10 "hcel-ids live search results per page." - :group 'hcel-ids) + :group 'hcel-ids :type '(natnum)) + +(defvar-local hcel-ids-scope nil) +(defvar-local hcel-ids-query nil) +(defvar-local hcel-ids-package-id nil) + (define-compilation-mode hcel-ids-mode "hcel-ids" "Major mode for showing identifiers" - (setq-local next-error-function #'hcel-results-next-error - hcel-ids-scope nil - hcel-ids-query nil - hcel-ids-package-id nil - hcel-results-page-number nil - hcel-results-max-page-number nil)) -(add-hook 'hcel-ids-mode-hook #'hcel-minor-mode) + (setq-local next-error-function #'hcel-results-next-error) + (hcel-minor-mode 1)) (defun hcel-ids-update () (unless (eq major-mode 'hcel-ids-mode) @@ -354,11 +355,11 @@ Start by choosing a package." (number-to-string hcel-ids-live-per-page)))) hcel-ids--minibuffer-saved-results))) -(defun hcel-global-ids-minibuffer-collection (query unused unused) +(defun hcel-global-ids-minibuffer-collection (query &rest _) (hcel-ids-minibuffer-collection 'global query)) (defun hcel-package-ids-minibuffer-collection (package-id) - (lambda (query unused unused) + (lambda (query &rest _) (hcel-ids-minibuffer-collection 'package query package-id))) (defun hcel-ids (scope query &optional package-id) diff --git a/hcel-source.el b/hcel-source.el index 6000d26..dbc2ca2 100644 --- a/hcel-source.el +++ b/hcel-source.el @@ -18,19 +18,21 @@ ;; License along with hcel. If not, see . (require 'hcel-client) + +(setq-local hcel-identifiers nil) +(setq-local hcel-declarations nil) +(setq-local hcel-occurrences nil) +(setq-local hcel-package-id nil) +(setq-local hcel-module-path nil) +(setq-local hcel-highlight-id nil) + (define-derived-mode hcel-mode special-mode "hcel" "Major mode for exploring Haskell codebases" (setq-local eldoc-documentation-strategy #'eldoc-documentation-compose-eagerly eldoc-documentation-functions '(hcel-eldoc-id-type hcel-eldoc-expression-type hcel-eldoc-docs) imenu-create-index-function #'hcel-imenu-create-index - imenu-space-replacement " " - hcel-identifiers nil - hcel-declarations nil - hcel-occurrences nil - hcel-package-id nil - hcel-module-path nil - hcel-highlight-id nil) + imenu-space-replacement " ") (cursor-sensor-mode 1) (add-hook 'xref-backend-functions #'hcel--xref-backend nil t)) @@ -89,7 +91,8 @@ Example of LOCATION-INFO: \"tag\": \"ExactLocation\" }, -If NO-JUMP is non-nil, just open the source and does not jump to the location with pulsing. +If NO-JUMP is non-nil, just open the source and does not jump to +the location with pulsing. " (unless (string= (hcel-location-tag location-info) "ExactLocation") (error "Location tag is not ExactLocation.")) @@ -313,7 +316,8 @@ If NO-JUMP is non-nil, just open the source and does not jump to the location wi ;; highlight (defface hcel-highlight-id '((t (:inherit underline))) - "Face for highlighting hcel identifier at point.") + "Face for highlighting hcel identifier at point." + :group 'hcel-faces) (defun hcel-highlight-update (&rest _) ;; if mark is active, change of face will deactivate the mark in transient @@ -409,7 +413,9 @@ If NO-JUMP is non-nil, just open the source and does not jump to the location wi (alist-get 'components (alist-get 'declType decl)) (alist-get 'name decl)) - (progn (goto-line (alist-get 'lineNumber decl)) (point)))) + (progn (goto-char (point-min)) + (forward-line (1- (alist-get 'lineNumber decl))) + (point)))) hcel-declarations)) (define-key hcel-mode-map "j" #'imenu) diff --git a/hcel-utils.el b/hcel-utils.el index b44f885..08ff105 100644 --- a/hcel-utils.el +++ b/hcel-utils.el @@ -75,11 +75,12 @@ Example of an idSrcSpan: (col-beg (alist-get 'column (alist-get 'start span))) (line-end (alist-get 'line (alist-get 'end span))) (col-end (alist-get 'column (alist-get 'end span)))) - (hcel- buffer-substring-line-column line-beg (1- col-beg) line-end (1- col-end)))) + (hcel-buffer-substring-line-column line-beg (1- col-beg) line-end (1- col-end)))) ;; buffers and strings manipulation (defun hcel-goto-line-column (line column) - (goto-line line) + (goto-char (point-min)) + (forward-line (1- line)) (move-to-column column)) (defun hcel-unquote-html (html) @@ -169,7 +170,7 @@ Example of an idSrcSpan: (defun hcel-text-property-near-point (prop) "Find property prop at point, or just before point." (or (get-text-property (point) prop) - (get-text-property (max 0 (1- (point))) prop))) + (get-text-property (max 1 (1- (point))) prop))) (provide 'hcel-utils) ;;; hcel-utils.el ends here. -- cgit v1.2.3