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

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

[nongnu] elpa/sweeprolog 12bddb3f75 117/166: ENHANCED: don't record one-


From: ELPA Syncer
Subject: [nongnu] elpa/sweeprolog 12bddb3f75 117/166: ENHANCED: don't record one-character inputs in the top level history
Date: Fri, 30 Sep 2022 04:59:30 -0400 (EDT)

branch: elpa/sweeprolog
commit 12bddb3f75a21cb4b07b99c30757b51344b8c232
Author: Eshel Yaron <me@eshelyaron.com>
Commit: Eshel Yaron <me@eshelyaron.com>

    ENHANCED: don't record one-character inputs in the top level history
---
 NEWS.org |  8 ++++++++
 sweep.el | 20 ++++++++++++++++----
 2 files changed, 24 insertions(+), 4 deletions(-)

diff --git a/NEWS.org b/NEWS.org
index 0e459a18d2..9ce726fe15 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 8a30ea6831..7d0bfd0a6d 100644
--- a/sweep.el
+++ b/sweep.el
@@ -6,7 +6,7 @@
 ;; Maintainer: Eshel Yaron <me(at)eshelyaron(dot)com>
 ;; 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)



reply via email to

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