🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

3 total messages Started by eliot lear Wed, 22 Oct 1986 22:53
getpass needed
#2175
Author: eliot lear
Date: Wed, 22 Oct 1986 22:53
14 lines
801 bytes
Hi..  I am a relative novice working with emacs and was wondering
if there is a method available from gnu to turn off echo (preferably
in the minibuffer).  Reason I ask is that I am attempting to write
some form of library for encrypted files.

				Thanks in advance,

					    eliot lear

-- 

[lear@rutgers.rutgers.edu]
[{allegra,seismo}!rutgers!lear]
Re: getpass needed
#2183
Author: Matthew P Wiener
Date: Fri, 24 Oct 1986 18:19
44 lines
2601 bytes
Note-I originally posted an erroneous version, now cancelled.

In article <6431@topaz.RUTGERS.EDU> lear@topaz.RUTGERS.EDU (eliot lear) writes:
>Hi..  I am a relative novice working with emacs and was wondering
>if there is a method available from gnu to turn off echo (preferably
>in the minibuffer).  Reason I ask is that I am attempting to write
>some form of library for encrypted files.

The following library should do the trick.  You turn off echoing by binding
the individual letters yourself.  Just load the library, and then invoke with
(read-string-no-echo "Key: ") or whatever prompt you wish to use.

ucbvax!brahms!weemba	Matthew P Wiener/UCB Math Dept/Berkeley CA 94720
Without NNTP, the brahms gang itself would be impossible.  --Erik E Fair
------------------------------------------------------------------------
;;; GNU Emacs library to read in passwords from the minibuffer
;;; Standard GNU copying privileges apply

;; We need to define our own minibuffer keymap.
(setq minibuffer-local-no-echo-map (copy-keymap minibuffer-local-map))

;; We trap all printing characters.
(let ((i ?\040))
  (while (< i ?\177)
    (nconc minibuffer-local-no-echo-map (list (cons i 'read-char-no-echo)))
    (setq i (1+ i))))

;; We provide for the delete character.
(nconc minibuffer-local-no-echo-map '((?\177 . delete-char-no-echo)))

;; This function squirrels each typed-in character away.
(defun read-char-no-echo () (interactive)
  (setq no-echo-list (append no-echo-list (list (this-command-keys)))))

;; This function erases the last character from the input list.
(defun delete-char-no-echo () (interactive)
  (setq no-echo-list (nreverse (cdr (nreverse no-echo-list)))))

;; This is the function the user actually uses.
(defun read-string-no-echo (prompt)
  "Get a password from the minibuffer, prompting with PROMPT."
  (let (no-echo-list)
    (read-from-minibuffer prompt nil minibuffer-local-no-echo-map)
    (mapconcat 'identity no-echo-list nil)))
Re: getpass needed
#2186
Author: Matthew P Wiener
Date: Sat, 25 Oct 1986 09:41
26 lines
1559 bytes
Summary:
Expires:
Sender:
Followup-To:
Distribution:
Keywords:

The version of read-string-no-echo I recently posted used a sparse keymap,
which is a pretty dumb butt thing to do for this application.  So change
the first several lines, the ones defining the keymap, to the following:

(setq minibuffer-local-no-echo-map
      (vconcat (make-vector ?\040 nil)
	       (make-vector ?\140 'read-char-no-echo)))

(mapcar '(lambda (x) (aset minibuffer-local-no-echo-map (car x) (cdr x)))
	(cdr minibuffer-local-map))

(aset minibuffer-local-no-echo-map ?\177 'delete-char-no-echo)

This will load and run quicker.  Hopefully beginners might gain something
by comparing the two, so please excuse the repetition.

ucbvax!brahms!weemba	Matthew P Wiener/UCB Math Dept/Berkeley CA 94720
   Hark! The herald angels sing / Beechan's pills are just the thing.
     Peace on earth and mercy mild / Two for man and one for child.
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads