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

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

[nongnu] elpa/cider 5920aa7d95 2/2: Make logview optional


From: ELPA Syncer
Subject: [nongnu] elpa/cider 5920aa7d95 2/2: Make logview optional
Date: Thu, 6 Jul 2023 06:59:17 -0400 (EDT)

branch: elpa/cider
commit 5920aa7d95f5ee478cbb0590f693af173c1b3209
Author: Roman Scherer <roman@burningswell.com>
Commit: Bozhidar Batsov <bozhidar@batsov.dev>

    Make logview optional
---
 Eldev                                         |  1 +
 cider-log.el                                  | 48 +++++++++++++++++++--------
 cider.el                                      |  2 +-
 doc/modules/ROOT/pages/debugging/logging.adoc |  9 +++++
 4 files changed, 46 insertions(+), 14 deletions(-)

diff --git a/Eldev b/Eldev
index a4cbaf2615..5dc49631ff 100644
--- a/Eldev
+++ b/Eldev
@@ -9,6 +9,7 @@
 (eldev-use-plugin 'autoloads)
 
 (eldev-add-loading-roots 'test "test/utils")
+(eldev-add-extra-dependencies 'runtime '(:package logview :optional t))
 
 (defvar cider-test-type 'main)
 (setf eldev-standard-excludes `(:or ,eldev-standard-excludes
diff --git a/cider-log.el b/cider-log.el
index efdb7ffaa0..1f039e1660 100644
--- a/cider-log.el
+++ b/cider-log.el
@@ -28,7 +28,7 @@
 (require 'cider-inspector)
 (require 'cider-stacktrace)
 (require 'cl-lib)
-(require 'logview)
+(require 'logview nil t)
 (require 'org)
 (require 'seq)
 (require 'transient)
@@ -82,6 +82,18 @@
   :safe #'integerp
   :type 'integer)
 
+(defcustom cider-log-use-logview (fboundp 'logview-mode)
+  "Whether to use `logview-mode' or not."
+  :group 'cider
+  :package-version '(cider . "1.8.0")
+  :safe #'booleanp
+  :type 'boolean)
+
+(defvar logview-mode-map)
+(declare-function logview--guess-submode "logview" () t)
+(declare-function logview-initialized-p "logview" () t)
+(declare-function logview-mode "logview" () t)
+
 (defvar cider-log--initialized-once-p nil
   "Set to t if log framework and appender have been initialized once.")
 
@@ -565,7 +577,7 @@ The KEYS are used to lookup the values and are joined by 
SEPARATOR."
                 (seq-doseq (buffer buffers)
                   (with-current-buffer buffer
                     (cider-log--insert-events buffer (list cider/log-event))
-                    (when (not (logview-initialized-p))
+                    (when (and cider-log-use-logview (not 
(logview-initialized-p)))
                       (let ((framework cider-log-framework)
                             (appender cider-log-appender)
                             (consumer cider-log-consumer))
@@ -795,8 +807,9 @@ The KEYS are used to lookup the values and are joined by 
SEPARATOR."
 ;; Major mode
 
 (defvar cider-log-mode-map
-  (let ((map (make-sparse-keymap)))
-    (set-keymap-parent map logview-mode-map)
+  (let ((map (make-sparse-keymap))
+        (parent (if cider-log-use-logview logview-mode-map special-mode-map)))
+    (set-keymap-parent map parent)
     (define-key map (kbd "C-c M-l a") #'cider-log-appender)
     (define-key map (kbd "C-c M-l c") #'cider-log-consumer)
     (define-key map (kbd "C-c M-l e") #'cider-log-event)
@@ -812,15 +825,8 @@ The KEYS are used to lookup the values and are joined by 
SEPARATOR."
     map)
   "The Cider log stream mode key map.")
 
-(define-derived-mode cider-log-mode logview-mode "Cider Log"
-  "Major mode for inspecting Clojure log events.
-
-CIDER Log Mode allows you to capture, debug, inspect and view log events
-emitted by Java logging frameworks.  The captured log events can be
-searched, streamed to the client, pretty printed and are integrated with
-the CIDER Inspector and the CIDER stacktrace mode.
-
-\\{cider-log-mode-map}"
+(defun cider-log--setup-mode ()
+  "Setup CIDER log mode."
   (use-local-map cider-log-mode-map)
   (setq-local electric-indent-chars nil)
   (setq-local logview-show-ellipses nil)
@@ -829,6 +835,22 @@ the CIDER Inspector and the CIDER stacktrace mode.
   (when (fboundp 'evil-set-initial-state)
     (evil-set-initial-state 'cider-log-mode 'emacs)))
 
+(defvar cider-log--mode-doc
+  "Major mode for inspecting Clojure log events.
+
+CIDER Log Mode allows you to capture, debug, inspect and view log events
+emitted by Java logging frameworks.  The captured log events can be
+searched, streamed to the client, pretty printed and are integrated with
+the CIDER Inspector and the CIDER stacktrace mode.
+
+\\{cider-log-mode-map}")
+
+(if cider-log-use-logview
+    (define-derived-mode cider-log-mode logview-mode "Cider Log" 
cider-log--mode-doc
+      (cider-log--setup-mode))
+  (define-derived-mode cider-log-mode special-mode "Cider Log" 
cider-log--mode-doc
+      (cider-log--setup-mode)))
+
 ;; Transient Lisp Variable
 
 (defclass cider-log--lisp-variable (transient-lisp-variable) ())
diff --git a/cider.el b/cider.el
index 423709b8c6..12d0bdbaa7 100644
--- a/cider.el
+++ b/cider.el
@@ -12,7 +12,7 @@
 ;; Maintainer: Bozhidar Batsov <bozhidar@batsov.dev>
 ;; URL: http://www.github.com/clojure-emacs/cider
 ;; Version: 1.8.0-snapshot
-;; Package-Requires: ((emacs "26") (clojure-mode "5.16.0") (parseedn "1.0.6") 
(queue "0.2") (spinner "1.7") (seq "2.22") (sesman "0.3.2") (logview "0.16.1") 
(transient "0.4.1"))
+;; Package-Requires: ((emacs "26") (clojure-mode "5.16.0") (parseedn "1.0.6") 
(queue "0.2") (spinner "1.7") (seq "2.22") (sesman "0.3.2") (transient "0.4.1"))
 ;; Keywords: languages, clojure, cider
 
 ;; This program is free software: you can redistribute it and/or modify
diff --git a/doc/modules/ROOT/pages/debugging/logging.adoc 
b/doc/modules/ROOT/pages/debugging/logging.adoc
index 423dbd8cbd..ccb198f11a 100644
--- a/doc/modules/ROOT/pages/debugging/logging.adoc
+++ b/doc/modules/ROOT/pages/debugging/logging.adoc
@@ -25,6 +25,15 @@ logging related actions.
 - link:../usage/pretty_printing.html[Pretty Print] log events.
 - Show log events in the CIDER link:inspector.html[Inspector]
 - Show log event exceptions in the CIDER 
link:../usage/dealing_with_errors.html[Stacktrace Mode]
+- Integration with https://github.com/doublep/logview[logview]
+
+== Dependencies
+
+https://github.com/doublep/logview[Logview] is an optional dependency
+of CIDER Log Mode. We recommend using it, since it is responsible for
+coloring the log events and it provides other useful features, such as
+syntax highlighting, filtering and more. It is used automatically when
+available and its use can be customized via `+cider-log-use-logview+`.
 
 == Usage
 



reply via email to

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