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

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

[elpa] externals/consult-hoogle b7b363827d 1/2: Remove dependency on has


From: ELPA Syncer
Subject: [elpa] externals/consult-hoogle b7b363827d 1/2: Remove dependency on haskell-mode
Date: Sun, 10 Nov 2024 07:02:42 -0500 (EST)

branch: externals/consult-hoogle
commit b7b363827dc505e09ec01b9d102112dda5aa359b
Author: Rahguzar <rahguzar@zohomail.eu>
Commit: Rahguzar <rahguzar@zohomail.eu>

    Remove dependency on haskell-mode
    
    Now we use auto-mode-alist to find an appropriate mode.
---
 consult-hoogle.el | 12 +++++++-----
 hoogle-base.el    | 11 ++++++++++-
 hoogle-buffer.el  |  2 +-
 3 files changed, 18 insertions(+), 7 deletions(-)

diff --git a/consult-hoogle.el b/consult-hoogle.el
index 5c15dc7657..a70deaed64 100644
--- a/consult-hoogle.el
+++ b/consult-hoogle.el
@@ -9,7 +9,7 @@
 ;; Version: 0.2.2
 ;; Keywords: docs languages
 ;; Homepage: https://codeberg.org/rahguzar/consult-hoogle
-;; Package-Requires: ((emacs "27.1") (consult "0.18") (haskell-mode "16.1"))
+;; Package-Requires: ((emacs "28.1") (consult "0.18"))
 
 ;; This file is part of GNU Emacs.
 
@@ -23,9 +23,9 @@
 ;;;; Packages
 (require 'consult)
 (require 'hoogle-base)
-(require 'haskell-mode)
 
 (declare-function hoogle-buffer "hoogle-buffer")
+(declare-function project-root "project")
 
 ;;;; Variables
 (defgroup consult-hoogle nil
@@ -158,7 +158,7 @@ STATE is the optional state function passed to the 
`consult--read'."
         (fun (or action (lambda (alist) (hoogle-base--browse-url 'item 
alist)))))
     (with-current-buffer (get-buffer-create " *Hoogle Fontification*" t)
       (setq-local delay-mode-hooks t)
-      (haskell-mode))
+      (hoogle-base--haskell-mode))
     (unwind-protect
         (funcall fun (consult--read
                       (consult--async-command #'consult-hoogle--builder
@@ -171,7 +171,7 @@ STATE is the optional state function passed to the 
`consult--read'."
                       :state state
                       :sort nil
                       :keymap consult-hoogle-map
-                      :add-history (or (and (fboundp #'haskell-ident-at-point)
+                      :add-history (or (and (fboundp 'haskell-ident-at-point)
                                             (consult--async-split-initial
                                              (haskell-ident-at-point)))
                                      (consult--async-split-thingatpt 'symbol))
@@ -200,7 +200,9 @@ By default this shows the documentation for the current 
candidate in a side
 window.  This can be disabled by a prefix ARG."
   (interactive (list current-prefix-arg))
   (let ((hoogle-base-args hoogle-base-project-args)
-        (default-directory (haskell-cabal-find-dir)))
+        (default-directory (if-let ((proj (project-current)))
+                               (project-root proj)
+                             default-directory)))
     (consult-hoogle arg)))
 
 (defun consult-hoogle-scroll-docs-down (&optional arg)
diff --git a/hoogle-base.el b/hoogle-base.el
index 86234ab7a7..699fc07c54 100644
--- a/hoogle-base.el
+++ b/hoogle-base.el
@@ -9,7 +9,7 @@
 ;; Version: 0.2.1
 ;; Keywords: docs languages
 ;; Homepage: https://codeberg.org/rahguzar/consult-hoogle
-;; Package-Requires: ((emacs "27.1") (haskell-mode "16.1"))
+;; Package-Requires: ((emacs "28.1"))
 
 ;; This file is part of GNU Emacs.
 
@@ -66,6 +66,15 @@ It should run the search with the new query.")
     map))
 
 ;;;; Utility Functions
+(defun hoogle-base--haskell-mode ()
+  "Run the major-mode suitable for haskell."
+  (if-let ((mode (assoc-default ".hs" auto-mode-alist #'string-match-p)))
+      (funcall mode)
+    (display-warning
+     'hoogle-base
+     "No major-mode for haskell is configured. There will be no syntax 
hightlighting."
+     :warning)))
+
 (defun hoogle-base--candidate ()
   "Get the current candidate."
   (if (functionp hoogle-base-find-candidate)
diff --git a/hoogle-buffer.el b/hoogle-buffer.el
index f944429897..7b014050ed 100644
--- a/hoogle-buffer.el
+++ b/hoogle-buffer.el
@@ -94,7 +94,7 @@
   (when (buffer-live-p hoogle-buffer--fontification-buffer)
     (with-current-buffer hoogle-buffer--fontification-buffer
       (setq-local delay-mode-hooks t)
-      (haskell-mode)
+      (hoogle-base--haskell-mode)
       (setq-local font-lock-dont-widen t
                   font-lock-support-mode nil
                   font-lock-global-modes nil)



reply via email to

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