From: Eshel Yaron Date: Wed, 14 Sep 2022 13:21:13 +0000 (+0300) Subject: ENHANCED: don't record one-character inputs in the top level history X-Git-Tag: v0.2.1~2 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=12bddb3f75a21cb4b07b99c30757b51344b8c232;p=dict.git ENHANCED: don't record one-character inputs in the top level history --- diff --git a/NEWS.org b/NEWS.org index 0e459a1..9ce726f 100644 --- a/NEWS.org +++ b/NEWS.org @@ -27,6 +27,7 @@ Follows file specifications in =sweep-mode= buffers. ** =C-c C-o= is now bound to =sweep-find-file-at-point=. + * New user options available in =sweep= {{{version({{{input-file}}})}}} ** New user option =sweep-colourise-buffer-on-idle= @@ -45,6 +46,13 @@ buffer. This option determines the maximum size of a =sweep-mode= buffer for which =sweep= will periodically update semantic highlighting on idle. +** New user option =sweep-top-level-min-history-length= + +This option, set by default to 3, determines a minimum length for +inputs inserted into =sweep= top-level history ring. The default value, +3, avoids one character top-level responses from clobbering the +history ring. This kind of inputs includes, for example, the =;= +character typed to invoke backtracking. * New keybindings in =sweep-prefix-map= diff --git a/sweep.el b/sweep.el index 8a30ea6..7d0bfd0 100644 --- a/sweep.el +++ b/sweep.el @@ -6,7 +6,7 @@ ;; Maintainer: Eshel Yaron ;; Keywords: prolog languages extensions ;; URL: https://git.sr.ht/~eshel/sweep -;; Package-Version: 0.2.0 +;; Package-Version: 0.2.1 ;; Package-Requires: ((emacs "28")) ;; This file is NOT part of GNU Emacs. @@ -95,6 +95,15 @@ is used to find a the swipl executable." :type 'function :group 'sweep) +(defcustom sweep-top-level-min-history-length 3 + "Minimum input length to record in the `sweep-top-level' history. + +Inputs shorther than the value of this variable will not be +inserted to the input history in `sweep-top-level-mode' buffers." + :package-version '((sweep . "0.2.1")) + :type 'string + :group 'sweep) + (defvar sweep-install-buffer-name "*Install sweep*" "Name of the buffer used for compiling sweep-module.") @@ -881,9 +890,9 @@ module name, F is a functor name and N is its arity." (defun sweep-colourise-query (buffer) (when (buffer-live-p buffer) (with-current-buffer buffer - (let* ((beg (cdr comint-last-prompt)) - (end (point-max)) - (query (buffer-substring-no-properties beg end))) + (when-let ((beg (cdr comint-last-prompt)) + (end (point-max)) + (query (buffer-substring-no-properties beg end))) (with-silent-modifications (font-lock-unfontify-region beg end)) (sweep-open-query "user" @@ -976,6 +985,9 @@ Interactively, a prefix arg means to prompt for BUFFER." (setq-local comint-prompt-regexp (rx line-start "?- ") comint-input-ignoredups t comint-prompt-read-only t + comint-input-filter (lambda (s) + (< sweep-top-level-min-history-length + (length s))) comint-delimiter-argument-list '(?,) comment-start "%") (add-hook 'post-self-insert-hook #'sweep-top-level--post-self-insert-function nil t)