From 1f93b69f87e465c02832209e975fd5ace0be63f3 Mon Sep 17 00:00:00 2001 From: Pierre Neidhardt Date: Sun, 21 Feb 2021 18:14:34 +0100 Subject: [PATCH] SLY: Add patch to ignore comments and include input starting with # in history. --- .emacs.d/lisp/init-sly.el | 1 + .emacs.d/lisp/patch-sly-history.el | 58 ++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 .emacs.d/lisp/patch-sly-history.el diff --git a/.emacs.d/lisp/init-sly.el b/.emacs.d/lisp/init-sly.el index 1efa7607..a2813886 100644 --- a/.emacs.d/lisp/init-sly.el +++ b/.emacs.d/lisp/init-sly.el @@ -1,4 +1,5 @@ (require 'patch-sly) +(require 'patch-sly-history) (require 'cl-lib) (defun pure-env (&rest preserve-vars) diff --git a/.emacs.d/lisp/patch-sly-history.el b/.emacs.d/lisp/patch-sly-history.el new file mode 100644 index 00000000..8c087a7e --- /dev/null +++ b/.emacs.d/lisp/patch-sly-history.el @@ -0,0 +1,58 @@ +(define-derived-mode sly-mrepl-mode comint-mode "mrepl" + (sly-mode 1) + (cl-loop for (var value) + in `((comint-use-prompt-regexp nil) + (comint-inhibit-carriage-motion t) + (comint-input-sender sly-mrepl--input-sender) + (comint-output-filter-functions nil) + (comint-input-filter-functions nil) + (comint-history-isearch dwim) + (comint-input-ignoredups t) + (comint-input-history-ignore "^;") ;; XXX: Patched! + (comint-prompt-read-only t) + (comint-process-echoes nil) + (comint-completion-addsuffix "") + (indent-line-function lisp-indent-line) + (sly-mrepl--read-mark nil) + (sly-mrepl--pending-output nil) + (sly-mrepl--output-mark ,(point-marker)) + (sly-mrepl--last-prompt-overlay ,(make-overlay 0 0 nil nil)) + (sly-find-buffer-package-function sly-mrepl-guess-package) + (sly-autodoc-inhibit-autodoc + sly-mrepl-inside-string-or-comment-p) + (mode-line-process nil) + (parse-sexp-ignore-comments t) + (syntax-propertize-function sly-mrepl--syntax-propertize) + (forward-sexp-function sly-mrepl--forward-sexp) + (comint-scroll-show-maximum-output nil) + (comint-scroll-to-bottom-on-input nil) + (comint-scroll-to-bottom-on-output nil) + (inhibit-field-text-motion nil) + (lisp-indent-function sly-common-lisp-indent-function) + (open-paren-in-column-0-is-defun-start nil) + (buffer-file-coding-system utf-8-unix) + ;; Paredit workaround (see + ;; https://github.com/joaotavora/sly/issues/110) + (paredit-override-check-parens-function (lambda (_c) t)) + (comment-start ";")) + do (set (make-local-variable var) value)) + (set-marker-insertion-type sly-mrepl--output-mark nil) + (add-hook 'kill-emacs-hook 'sly-mrepl--save-all-histories) + ;;(set (make-local-variable 'comint-get-old-input) 'ielm-get-old-input) + (set-syntax-table lisp-mode-syntax-table) + (set-keymap-parent sly-mrepl-mode-map nil) + + ;; The REPL buffer has interactive text buttons + (sly-interactive-buttons-mode 1) + + ;; Add hooks to isearch-mode placed strategically after the ones + ;; set by comint.el itself. + ;; + (add-hook 'isearch-mode-hook 'sly-mrepl--setup-comint-isearch t t) + (add-hook 'isearch-mode-end-hook 'sly-mrepl--teardown-comint-isearch t t) + + ;; Add a post-command-handler + ;; + (add-hook 'post-command-hook 'sly-mrepl--highlight-backreferences-maybe t t)) + +(provide 'patch-sly-history)