abo-abo / lispy

Short and sweet LISP editing
http://oremacs.com/lispy/
1.2k stars 132 forks source link

[QUESTION] making le-clojure.clj optional #552

Open bennyandresen opened 3 years ago

bennyandresen commented 3 years ago

I'm generally a fan of the way lispy + lispyville works, but the automatic loading of le-clojure.clj is being a pain in several of my usecases. (I'm using unorthodox platforms and clj/cljs systems, rather than the default clj repl.)

Is there a way to completely opt out of this functionality? I'm fine with not getting the benefits (which I assume to be C-1 and C-2).

Andre0991 commented 3 years ago

EDIT: I just extracted the diff bellow to this package: https://github.com/Andre0991/vilpy (early days, I do not recommend using it!).

I'm looking for the same thing.

I just hacked this quick solution.

You can load put it in some local dir and use this use-package (replace load-path).

(use-package lispy
  :hook ((lisp-mode . lispy-mode)
         (emacs-lisp-mode . lispy-mode)
         (clojure-mode . lispy-mode))
  :load-path "~/dev/peric/lispy-lite"
)

Diff:

diff --git a/lispy.el b/lispy.el
index 70134b7..65fddfd 100644
--- a/lispy.el
+++ b/lispy.el
@@ -141,26 +141,32 @@
   (require 'semantic)
   (require 'semantic/db))
 (require 'mode-local)
-(require 'lispy-tags)
 (require 'help-fns)
 (require 'edebug)
 (require 'etags)
 (require 'outline)
 (require 'avy)
 (require 'newcomment)
-(require 'lispy-inline)
 (setq iedit-toggle-key-default nil)
 (require 'delsel)
 (require 'swiper)
 (require 'pcase)
 (require 'hydra)
-(eval-after-load 'cider '(require 'le-clojure))

 (defsubst lispy-looking-back (regexp)
   "Forward to (`looking-back' REGEXP)."
   (looking-back regexp (line-beginning-position)))

 ;;* Locals: extract block
+(defvar lispy-elisp-modes
+  '(emacs-lisp-mode lisp-interaction-mode eltex-mode minibuffer-inactive-mode
+                    suggest-mode)
+  "Modes for which `lispy--eval-elisp' and related functions are appropriate.")
+
+(defvar lispy-clojure-modes
+  '(clojure-mode clojurescript-mode clojurex-mode clojurec-mode)
+  "Modes for which clojure related functions are appropriate.")
+
 (defvar lispy-map-input-overlay nil
   "The input overlay for mapping transformations.")

@@ -489,12 +495,6 @@ backward through lists, which is useful to move into special.
                (setq-local lispy-outline "^\\(?:%\\*+\\|\\\\\\(?:sub\\)?section{\\)")
                (setq lispy-outline-header "%")
                (setq-local outline-regexp "\\(?:%\\*+\\|\\\\\\(?:sub\\)?section{\\)"))
-              ((eq major-mode 'clojure-mode)
-               (eval-after-load 'le-clojure
-                 '(setq completion-at-point-functions
-                   '(lispy-clojure-complete-at-point
-                     cider-complete-at-point)))
-               (setq-local outline-regexp (substring lispy-outline 1)))
               ((eq major-mode 'python-mode)
                (setq-local lispy-outline "^#\\*+")
                (setq lispy-outline-header "#")
@@ -581,10 +581,6 @@ Otherwise return the amount of times executed."
         (nthcdr (1- ,n) (prog1 ,lst (setq ,lst (nthcdr ,n ,lst))))
         nil))))

-(defvar lispy-site-directory (file-name-directory
-                              load-file-name)
-  "The directory where all of the lispy files are located.")
-
 ;;* Verb related
 (defun lispy-disable-verbs-except (verb)
   "Disable all verbs except VERB."
@@ -4377,33 +4373,41 @@ SYMBOL is a string."
 When ARG is 2, insert the result as a comment.
 When at an outline, eval the outline."
   (interactive "p")
+  (cond
+   ((bound-and-true-p inf-clojure-minor-mode)
+    (inf-clojure-eval-last-sexp))
+   ((derived-mode-p 'emacs-lisp-mode)
+    (call-interactively #'eval-last-sexp))
+   ((bound-and-true-p cider-mode)
+    (cider-eval-last-sexp)))
   (setq lispy-eval-output nil)
-  (condition-case e
-      (cond ((eq arg 2)
-             (lispy-eval-and-comment))
-            ((and (looking-at lispy-outline)
-                  (looking-at lispy-outline-header))
-             (lispy-eval-outline))
-            (t
-             (let ((res (lispy--eval nil)))
-               (when (memq major-mode lispy-clojure-modes)
-                 (setq res (lispy--clojure-pretty-string res)))
-               (when lispy-eval-output
-                 (setq res (concat lispy-eval-output res)))
-               (cond ((eq lispy-eval-display-style 'message)
-                      (lispy-message res))
-                     ((or (fboundp 'cider--display-interactive-eval-result)
-                          (require 'cider nil t))
-                      (cider--display-interactive-eval-result
-                       res (cdr (lispy--bounds-dwim))))
-                     ((or (fboundp 'eros--eval-overlay)
-                          (require 'eros nil t))
-                      (eros--eval-overlay
-                       res (cdr (lispy--bounds-dwim))))
-                     (t
-                      (error "Please install CIDER >= 0.10 or eros to display overlay"))))))
-    (eval-error
-     (lispy-message (cdr e)))))
+  ;; (condition-case e
+  ;;     (cond ((eq arg 2)
+  ;;            (lispy-eval-and-comment))
+  ;;           ((and (looking-at lispy-outline)
+  ;;                 (looking-at lispy-outline-header))
+  ;;            (lispy-eval-outline))
+  ;;           (t
+  ;;            (let ((res (lispy--eval nil)))
+  ;;              (when (memq major-mode lispy-clojure-modes)
+  ;;                (setq res (lispy--clojure-pretty-string res)))
+  ;;              (when lispy-eval-output
+  ;;                (setq res (concat lispy-eval-output res)))
+  ;;              (cond ((eq lispy-eval-display-style 'message)
+  ;;                     (lispy-message res))
+  ;;                    ((or (fboundp 'cider--display-interactive-eval-result)
+  ;;                         (require 'cider nil t))
+  ;;                     (cider--dislay-interactive-eval-result
+  ;;                      res (cdr (lispy--bounds-dwim))))
+  ;;                    ((or (fboundp 'eros--eval-overlay)
+  ;;                         (require 'eros nil t))
+  ;;                     (eros--eval-overlay
+  ;;                      res (cdr (lispy--bounds-dwim))))
+  ;;                    (t
+  ;;                     (error "Please install CIDER >= 0.10 or eros to display overlay"))))))
+  ;;   (eval-error
+  ;;    (lispy-message (cdr e))))
+  )

 (defun lispy-forward-outline ()
   (let ((pt (point)))
-- 
Andre0991 commented 3 years ago

I'm thinking of evolving this code and removing more stuff from lispy.el: all functions that are related to org or semantic, hydra, outline, anything that deals with debugging... I'm sure all this stuff is useful for some people, but I really just want the core editing features.