From 09a18bb012d61cd0dbef7eabe996d896c83a8bf6 Mon Sep 17 00:00:00 2001 From: Pierre Neidhardt Date: Sun, 29 Nov 2020 10:39:03 +0100 Subject: [PATCH] SLY: Replace patches with helm-switch-to-repl, use lisp-repl-core-dumper. --- .emacs.d/lisp/init-lisp.el | 123 ++----------------------------------- 1 file changed, 5 insertions(+), 118 deletions(-) diff --git a/.emacs.d/lisp/init-lisp.el b/.emacs.d/lisp/init-lisp.el index f346737b..46142325 100644 --- a/.emacs.d/lisp/init-lisp.el +++ b/.emacs.d/lisp/init-lisp.el @@ -68,118 +68,6 @@ changed, of when called interactively." (insert current-sbcl-version)) sbcl-core)))) -(defun ambrevar/helm-ff--shell-interactive-buffer-p (buffer &optional mode) - (with-current-buffer buffer - (when (derived-mode-p (or mode 'eshell-mode)) - (let ((next-prompt-fn (cl-case major-mode - (sly-mrepl-mode #'comint-next-prompt) - (shell-mode #'comint-next-prompt) - (eshell-mode #'eshell-next-prompt) - (term-mode #'term-next-prompt)))) - (save-excursion - (goto-char (point-min)) - (funcall next-prompt-fn 1) - (null (eql (point) (point-min)))))))) - -(defun ambrevar/helm-ff-shell-alive-p (mode) - "Returns non nil when a process is running inside `shell-mode' buffer." - (cl-ecase mode - (sly-mrepl-mode - (save-excursion - (comint-goto-process-mark) - (or (null comint-last-prompt) - (not (eql (point) - (marker-position (cdr comint-last-prompt))))))) - (shell-mode - (save-excursion - (comint-goto-process-mark) - (or (null comint-last-prompt) - (not (eql (point) - (marker-position (cdr comint-last-prompt))))))) - (eshell-mode - (get-buffer-process (current-buffer))) - (term-mode - (save-excursion - (goto-char (term-process-mark)) - (not (looking-back "\\$ " (- (point) 2))))))) - -(with-eval-after-load 'helm-files - (defun ambrevar/helm-ff-switch-to-shell (_candidate) - "Like `helm-ff-switch-to-shell' but supports more modes." - ;; Reproduce the Emacs-25 behavior to be able to edit and send - ;; command in term buffer. - (let (term-char-mode-buffer-read-only ; Emacs-25 behavior. - term-char-mode-point-at-process-mark ; Emacs-25 behavior. - (cd-eshell (lambda () - (eshell/cd helm-ff-default-directory) - (eshell-reset))) - (cd-sly (lambda () ; XXX: New! - (let ((directory helm-ff-default-directory)) - (sly-change-directory directory) - ;; REVIEW: `sly-change-directory' does not change the - ;; REPL's dir, do it here. - (cd-absolute directory)))) - (cd-shell - (lambda () - (cl-case helm-ff-default-directory) - (goto-char (point-max)) - (when (eq helm-ff-preferred-shell-mode 'shell-mode) - (comint-delete-input)) - (insert (format "cd %s" - (shell-quote-argument - (or (file-remote-p - helm-ff-default-directory 'localname) - helm-ff-default-directory)))) - (cl-case helm-ff-preferred-shell-mode - (shell-mode (comint-send-input)) - (term-mode (progn (term-char-mode) (term-send-input)))))) - (bufs (cl-loop for b in (mapcar 'buffer-name (buffer-list)) - when (or - (ambrevar/helm-ff--shell-interactive-buffer-p - b 'sly-mrepl-mode) ; XXX: New! - (helm-ff--shell-interactive-buffer-p - b helm-ff-preferred-shell-mode)) - collect b))) - ;; Jump to a shell buffer or open a new session. - (helm-aif (and (not helm-current-prefix-arg) - (if (cdr bufs) - (helm-comp-read "Switch to shell buffer: " bufs - :must-match t) - (car bufs))) - ;; Display in same window by default to preserve the - ;; historical behaviour - (pop-to-buffer it '(display-buffer-same-window)) - (cl-case helm-ff-preferred-shell-mode - (eshell-mode - (eshell helm-current-prefix-arg)) - (shell-mode - (shell (helm-aif (and helm-current-prefix-arg - (prefix-numeric-value - helm-current-prefix-arg)) - (format "*shell<%s>*" it)))) - (term-mode - (progn - (ansi-term (getenv "SHELL") - (helm-aif (and helm-current-prefix-arg - (prefix-numeric-value - helm-current-prefix-arg)) - (format "*ansi-term<%s>*" it))) - (term-line-mode))))) - ;; Now cd into directory. - (helm-aif (and (memq major-mode '(sly-mrepl-mode shell-mode term-mode)) ; XXX: New! - (get-buffer-process (current-buffer))) - (accept-process-output it 0.1)) - (unless (ambrevar/helm-ff-shell-alive-p major-mode) ; XXX: New! - (funcall - (cond ; XXX: New! - ((eq major-mode 'eshell-mode) - cd-eshell) - ((eq major-mode 'sly-mrepl-mode) - cd-sly) - (t - cd-shell)))))) - (advice-add 'helm-ff-switch-to-shell :override #'ambrevar/helm-ff-switch-to-shell)) - (defvar ambrevar/sly-status--last-command-time nil) (make-variable-buffer-local 'ambrevar/sly-status--last-command-time) (defun ambrevar/sly-status--record () @@ -263,12 +151,11 @@ returns a string." (advice-add 'sly-mrepl-next-prompt :override #'ambrevar/sly-mrepl-next-prompt) (advice-add 'sly-mrepl-previous-prompt :override #'ambrevar/sly-mrepl-previous-prompt) - (setq sly-lisp-implementations - '((sbcl (lambda () - (let ((core (ambrevar/sly-dump-sbcl-core :ambrevar))) - `(("sbcl" ,@(when core `("--core" ,core))))))) - (ccl ("ccl")) - (ecl ("ecl")))) + (let ((dumper (expand-file-name "~/projects/lisp-repl-core-dumper/lisp-repl-core-dumper"))) + (setq sly-lisp-implementations + `((sbcl (,dumper "sbcl")) + (ccl (,dumper "ccl")) + (ecl ("ecl"))))) (with-eval-after-load 'sly-mrepl (set-face-attribute 'sly-mrepl-output-face nil :inherit 'default :foreground)