[alt.sources] Getting Emacs to not echo characters

deven@rpi.edu (Deven T. Corzine) (12/10/89)

Original-posting-by: deven@rpi.edu (Deven T. Corzine)
Reposted-by: emv@math.lsa.umich.edu (Edward Vielmetti)
Posting-id: 891209.1955
Posting-number: Volume TEST, Number TEST
Archive-name: shell-filter.el

[This is an experimental alt.sources re-posting from the
newsgroup(s) gnu.emacs.
No attempt has been made to edit, clean, modify, or otherwise
change the contents of the original posting, or to contact the
author.  Please consider cross-posting all sources postings to
alt.sources as a matter of course.]

[Comments on this service to emv@math.lsa.umich.edu (Edward Vielmetti)]


On 6 Dec 89 18:28:21 GMT, hollen@eta.megatek.uucp (Dion Hollenbeck) said:

Dion> Deven T. Corzine thoughtfully posted a solution to this, but it
Dion> does not quite fit my problem.  When I am typing in a password,
Dion> I am in an Emacs shell and are doing a "rlogin" to another host
Dion> which is asking for my password.  Maybe somehow turning off
Dion> echoing in this shell would work.

Dion> The other problem I am having is also in the shell, after I have
Dion> completed the remote login.  Emacs echoes everything to the
Dion> screen in addition to the remote host echoing it and every line
Dion> is followed my ^M.  Is there a mode or process-filter which I
Dion> can apply to get rid of this behaviour?

The same things were bothering me, so I wrote a simple fix for them.

The following is from my .emacs:

--------
(defun shell-filter (proc str)
  "Output filter for shell-mode buffers."
  (save-excursion
    (set-buffer (process-buffer proc))
    (goto-char (process-mark proc))
    (let ((start (point))
          end)
      (insert-before-markers str)
      (setq end (point))
      (goto-char start)
      (while (or (looking-at "^\r\\|\r$")
                 (re-search-forward "^\r\\|\r$" end t))
        (replace-match ""))
      (goto-char start)
      (while (or (looking-at "\C-g")
                 (re-search-forward "\C-g" end t))
        (replace-match "")
        (ding 'noterminate)))))

(defun shell-save-history ()
  "Hook for shell-mode to delete the input from the buffer after sending
it.  (so double-echo is avoided)"
  (delete-region last-input-start last-input-end))

(setq shell-mode-hook
      '(lambda ()
         (set-process-filter (get-buffer-process (current-buffer))
                             'shell-filter))
      shell-read-history nil)

--------

The filter removes ^M's from the beginning or end of a line, and
removes any ^G's, dinging in their place.  The shell-save-history
function (is it called by the standard shell.el distribution?  hmm.)
does retroactive un-echoing.  it deletes the input, which is normally
then echoed by the shell or remote host.  In the case of password
prompting, it is not re-echoed.  So, the password shows while you type
it, but not after.  Not ideal, but an acceptable compromise for me.
(just put your hand over the screen or something.  :-)

Deven
-- 
Deven T. Corzine        Internet:  deven@rpi.edu, shadow@pawl.rpi.edu
Snail:  2151 12th St. Apt. 4, Troy, NY 12180   Phone:  (518) 274-0327
Bitnet:  deven@rpitsmts, userfxb6@rpitsmts     UUCP:  uunet!rpi!deven
Simple things should be simple and complex things should be possible.