[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Help with simple function
From: |
Kalle Olavi Niemitalo |
Subject: |
Re: Help with simple function |
Date: |
09 Jan 2003 21:26:55 +0200 |
User-agent: |
Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50 |
Peter Davis <pd@world.std.com> writes:
> I don't even know how to create the pop-servers variable so it
> will accept this list format.
If you assign a value to a variable (with setq), you implicitly
create it. Variables thus created accept all types of values.
Only some built-in variables have type restrictions.
Of course, there is plenty of code that assumes that the value of
compile-command is a string, for example; but if you choose a
name that is not already in use, there is no conflict.
> 2) Have emacs/XEmacs prompt for the password the first time this is
> used, and store it in there (so I don't have to keep it in my .gnus
> file)
(defun pd-server-password (server)
"Return the password for SERVER.
If it is empty, prompt for it and save the value."
(let ((password (plist-get server :password)))
(when (equal password "")
(setq password (read-passwd (format "Password for %s@%s: "
(plist-get server :username)
(plist-get server :server))))
;; The docstring of plist-put says you should save the value it
;; returns. However, we know that :password is already a key
;; in the plist, so plist-put will destructively change the value.
(plist-put server :password password))
password))
> 3) Call the Perl script once for each server, passing the arguments,
> password, etc.
(with-output-to-temp-buffer "*popfetch*"
(dolist (server pop-servers)
(call-process "perl" nil standard-output nil
"c:/home/popfetch.pl"
(plist-get server :server)
(plist-get server :username)
(pd-server-password server))))
One should probably display the buffer earlier.