Hi,
this is a request for a slight change to comint.el. The background is
that we want to add (in matlab.el) a command to the comint-input-ring
without using comint-send-input:
>> Volker Franz <volker.franz(a)tuebingen.mpg.de> seems to
think that:
VF> When working in matlab-mode, I use the function
VF> matlab-shell-save-and-go a lot. Unfortunately, when using this
VF> function, the evaluated m-file will not appear in the history of the
VF> matlab-shell. I slightly rewrote the function such that the executed
VF> command will appear also in the matlab-shell history.
We decided not to simply insert the command to the matlab shell and
use comint-send-input on it:
>> "Eric" == Eric Ludlam <eludlam(a)mathworks.com>
writes:
Eric> [...] My concern with it, however, is for the case when there is
a
Eric> partially typed command sitting on the command line. The two would be
Eric> glommed together.
To accomplish this (without duplicating internal code of comint.el) it
would be beneficial to have a function which simply adds the input to
the comint-input-ring (in the same way as is done in
comint-send-input). The function `comint-add-to-input-history' does
right this. Eric Ludlam sent a similar patch to the Emacs maintainers.
Volker
----------------------------------------------------------------------
--- comint.el Mon Oct 30 18:11:50 2000
+++ comint.orig Fri Aug 11 05:43:33 2000
@@ -1237,17 +1237,6 @@
;;
;; Input processing stuff
;;
-(defun comint-add-to-input-history (cmd)
- "Add CMD to the input history if `comint-input-filter' returns
-non-nil when called on CMD. Also, 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.
@@ -1342,7 +1331,13 @@
(if comint-process-echoes
(delete-region pmark (point))
(insert-before-markers ?\n))
- (comint-add-to-input-history history)
+ (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 the input filters on the history instead
;; of the input, so that the input sentinel is called on the
;; history-expanded text and sees "cd foo" instead of "cd !$".
----------------------------------------------------------------------
--
___________________________________________________________
Volker H. Franz
Max-Planck-Institut fuer biologische Kybernetik
Spemannstr. 38
72076 Tuebingen
Tel : ++49 (0)7071/601-606
Fax : ++49 (0)7071/601-616
mailto:volker.franz@tuebingen.mpg.de
http://www.kyb.tuebingen.mpg.de/bu
___________________________________________________________