[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/consult-hoogle ecee46f2f8 03/21: Use font locking from
From: |
ELPA Syncer |
Subject: |
[elpa] externals/consult-hoogle ecee46f2f8 03/21: Use font locking from haskell-mode. |
Date: |
Sun, 4 Feb 2024 12:57:52 -0500 (EST) |
branch: externals/consult-hoogle
commit ecee46f2f8668483ffc759ac7176dcc8224ff623
Author: Rahguzar <aikrahguzar@gmail.com>
Commit: Rahguzar <aikrahguzar@gmail.com>
Use font locking from haskell-mode.
---
consult-hoogle.el | 32 +++++++++++++++++++++-----------
1 file changed, 21 insertions(+), 11 deletions(-)
diff --git a/consult-hoogle.el b/consult-hoogle.el
index 0509d716e3..86dd6433ec 100644
--- a/consult-hoogle.el
+++ b/consult-hoogle.el
@@ -20,7 +20,7 @@
(require 'consult)
(require 'map)
(require 'subr-x)
-(require 'haskell-font-lock)
+(require 'haskell-mode)
(require 'shr)
;;;; Variables
@@ -54,20 +54,30 @@
("package" (consult-hoogle--format-package parsed)))
'consult--candidate parsed)))
-(defun consult-hoogle--format-value-item (item) "Construct the display string
for ITEM in value."
- (if-let* ((name-and-type (split-string item "::" t " +"))
- (name (or (car name-and-type)))
- (type (or (cadr name-and-type))))
- (concat (propertize name 'face 'haskell-definition-face) " :: "
(propertize type 'face 'haskell-type-face))
- (let ((words (split-string item)))
- (concat (propertize (car words) 'face 'haskell-keyword-face) " "
(propertize (string-join (cdr words) " ") 'face 'haskell-definition-face)))))
+(defun consult-hoogle--fontify (text)
+ "Fontify TEXT, returning the fontified text.
+This is adapted from `haskell-fontify-as-mode' but for better performance
+instead of running `haskell-mode' we just obtain the font-lock parts from
+ it we need."
+ (with-temp-buffer
+ (setq-local font-lock-defaults
+ '((haskell-font-lock-keywords)
+ nil nil nil nil
+ (font-lock-syntactic-face-function
+ . haskell-syntactic-face-function)))
+ (insert text)
+ (if (fboundp 'font-lock-ensure)
+ (font-lock-ensure)
+ (with-no-warnings (font-lock-fontify-buffer)))
+ (buffer-substring (point-min) (point-max))))
(defun consult-hoogle--format-value (alist) "Construct the disaply string from
ALIST for a value."
(let* ((item (map-elt alist 'item))
(module (map-nested-elt alist '(module name) ""))
(package (map-nested-elt alist '(package name) "")))
- (concat (consult-hoogle--format-value-item item)
- " from " (propertize module 'face 'haskell-keyword-face) " in
" (propertize package 'face 'haskell-quasi-quote-face))))
+ (concat (consult-hoogle--fontify item)
+ (propertize " from " 'face 'font-lock-comment-face)
(propertize module 'face 'haskell-keyword-face)
+ (propertize " in " 'face 'font-lock-comment-face) (propertize
package 'face 'haskell-quasi-quote-face))))
(defun consult-hoogle--format-module (alist) "Construct the disaply string
from ALIST for a module."
(let ((name (cadr (split-string (map-elt alist 'item) nil t " +")))
@@ -107,7 +117,7 @@
(let* ((item (map-elt alist 'item))
(module (map-nested-elt alist '(module name) ""))
(package (map-nested-elt alist '(package name) "")))
- (insert (consult-hoogle--format-value-item item) "\n"
+ (insert (consult-hoogle--fontify item) "\n"
(propertize "Module: " 'face 'bold) (propertize module 'face
'haskell-keyword-face) "\n"
(propertize "Package: " 'face 'bold) (propertize package
'face 'haskell-quasi-quote-face) "\n")))
- [elpa] branch externals/consult-hoogle created (now cc4ed71724), ELPA Syncer, 2024/02/04
- [elpa] externals/consult-hoogle 8d6cbeacc2 05/21: Screenshots, ELPA Syncer, 2024/02/04
- [elpa] externals/consult-hoogle ecee46f2f8 03/21: Use font locking from haskell-mode.,
ELPA Syncer <=
- [elpa] externals/consult-hoogle c6063a7244 06/21: Customization option to show less in the candidate line., ELPA Syncer, 2024/02/04
- [elpa] externals/consult-hoogle 9754f8c582 01/21: Beginning, ELPA Syncer, 2024/02/04
- [elpa] externals/consult-hoogle f3ef0d9624 07/21: Fix fontification, ELPA Syncer, 2024/02/04
- [elpa] externals/consult-hoogle 3f6a93a7ab 08/21: squash! Fix fontification, ELPA Syncer, 2024/02/04
- [elpa] externals/consult-hoogle f78db233c0 18/21: New consult builder format, ELPA Syncer, 2024/02/04
- [elpa] externals/consult-hoogle 80a6f2af4d 19/21: Format conventionally, ELPA Syncer, 2024/02/04
- [elpa] externals/consult-hoogle cc4ed71724 21/21: Use list of command name and args, ELPA Syncer, 2024/02/04
- [elpa] externals/consult-hoogle 7e292b8483 04/21: Docs scrolling commands, ELPA Syncer, 2024/02/04
- [elpa] externals/consult-hoogle 04940b0e62 02/21: Quote fix, ELPA Syncer, 2024/02/04
- [elpa] externals/consult-hoogle e1586d0190 09/21: Kill the fontification buffer after exit, ELPA Syncer, 2024/02/04