emacs-devel
[Top][All Lists]
Advanced

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

comint input history


From: Eric M. Ludlam
Subject: comint input history
Date: Mon, 30 Oct 2000 08:31:47 -0500

Hi,

  In `comint-send-input', new strings are added to the ring
`comint-input-ring' in a fancy way.  I started receiving patches for a
mode I maintain where someone is trying to replicate this
functionality.

  It would make sense to move this into a call shell modes can use
if they want to add things to the history in a nice way.

  Does this sound reasonable?

  The below patch does this.

Eric

----------
*** comint.el.~1.210~   Wed Oct 11 09:03:41 2000
--- comint.el   Mon Oct 30 08:30:18 2000
***************
*** 1311,1316 ****
--- 1311,1326 ----
  ;;
  ;; Input processing stuff
  ;;
+ (defun comint-add-to-input-history (cmd)
+   "Add CMD to the input history.
+ Ignore duplicates if `comint-input-ignoredups' is non-nil."
+   (if (and (funcall comint-input-filter cmd)
+          (or (null comint-input-ignoredups)
+              (not (ring-p comint-input-ring))
+              (ring-empty-p comint-input-ring)
+              (not (string-equal (ring-ref comint-input-ring 0)
+                                 cmd))))
+       (ring-insert comint-input-ring cmd)))
  
  (defun comint-send-input ()
    "Send input to process.
***************
*** 1386,1398 ****
              (delete-region pmark (point))
            (insert ?\n))
  
!         (if (and (funcall comint-input-filter history)
!                  (or (null comint-input-ignoredups)
!                      (not (ring-p comint-input-ring))
!                      (ring-empty-p comint-input-ring)
!                      (not (string-equal (ring-ref comint-input-ring 0)
!                                         history))))
!             (ring-insert comint-input-ring history))
  
          (run-hook-with-args 'comint-input-filter-functions
                              (concat input "\n"))
--- 1396,1402 ----
              (delete-region pmark (point))
            (insert ?\n))
  
!         (comint-add-to-input-history history)
  
          (run-hook-with-args 'comint-input-filter-functions
                              (concat input "\n"))
***************
*** 1420,1425 ****
--- 1424,1430 ----
                (overlay-put over 'field 'boundary)
                (overlay-put over 'rear-nonsticky t)
                (overlay-put over 'evaporate t))))
+ 
  
          (comint-snapshot-last-prompt)

-- 
|\/\/\___/\/\/|  Eric Ludlam                 address@hidden; address@hidden
\____ o o ____/  Homepage:                      http://www.ultranet.com/~zappo
     )   (       Trebuchets:    http://www.ultranet.com/~zappo/trebuchet.shtml
    ( * * )      GNU:                                       http://www.gnu.org
     \___/       Trevor Shea Ludlam:            Oct 16th, 1999, 5lbs 11oz 18in



reply via email to

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