|
From: Brian P. <bp...@re...> - 2004-07-10 10:52:09
|
Currently erc-select is a interactive function which doesn't actually
set any of its arguments from the (interactive) form; instead, in the
main body of the function, it calls read-from-minibuffer several times
to get important information from the user. Some of this information
is stored in separate history lists, but other information (such as
the port number) is let into the general minibuffer history.
One thing I've done because answering lots of questions in the
minibuffer annoys me is made it so you can type 'nick@server:port' in
erc-select and it will parse out the relevant fields. If you don't
specify a field, it should fall back to its old behaviour of asking.
I'm not sure where or how to document this, though (it should be in
the read-from-minibuffer inside erc-select-read-args, but I couldn't
come up with reasonable wording).
As part of cleaning up erc-select's interface, I changed it to
(defun* erc-select (&optional (server erc-server) (port erc-port) (nick erc-nick) passwd)
This seems a lot clearer as to what variables you should be
customizing to change default options. However, it's also possible
with these changes that the arguments should be made non-optional.
2004-07-10 <bp...@re...>
* erc.el (erc-select-read-args): New function. Prompts the user
for arguments to pass to erc-select and erc-select-ssl.
(erc-select): Use (erc-select-read-args) when called interactively to get its arguments
(erc-select-ssl): Ditto.
(erc-compute-port): New function. Parallel to
erc-compute-server, but comes up with a default value
for an IRC server's port.
Index: erc.el
===================================================================
RCS file: /cvsroot/erc/erc/erc.el,v
retrieving revision 1.671
diff -F(def -r1.671 erc.el
2180,2197c2180,2198
< ;;;###autoload
< (defun erc-select (&optional server port nick)
< "Interactively select connection parameters and run ERC.
< Optional argument SERVER uses server as default for the input query.
< Optional argument PORT uses passed port as default for the input query.
< Optional argument NICK uses the passed nick as default for the input query."
< (interactive)
< (setq port (or port erc-port))
< (setq server (erc-compute-server server))
< (setq nick (erc-compute-nick nick))
< (let* ((server (read-from-minibuffer
< "IRC server: " server nil nil 'erc-server-history-list))
< (port
< (erc-string-to-port
< (read-from-minibuffer "IRC port: "
< (erc-port-to-string (or port "ircd")))))
< (nick
< (if (erc-already-logged-in server port nick)
---
> (defun erc-select-read-args ()
> "Prompt the user for values of nick, server, port, and password."
> (let (user-input server port nick passwd)
> (setq user-input (read-from-minibuffer "IRC server: " (erc-compute-server nil) nil nil 'erc-server-history-list))
>
> (if (string-match "\\(.*\\):\\(.*\\)\\'" user-input)
> (setq port (erc-string-to-port (match-string 2 user-input))
> user-input (match-string 1 user-input))
> (setq port (erc-string-to-port (read-from-minibuffer "IRC port: " (erc-port-to-string (erc-compute-port nil))))))
>
> (if (string-match "\\`\\(.*\\)@\\(.*\\)" user-input)
> (setq nick (match-string 1 user-input)
> user-input (match-string 2 user-input))
> (setq nick
> (if (erc-already-logged-in server port nick)
> (read-from-minibuffer
> (erc-format-message 'nick-in-use ?n nick)
> nick
> nil nil 'erc-nick-history-list)
2199,2205c2200,2205
< (erc-format-message 'nick-in-use ?n nick)
< nick
< nil nil 'erc-nick-history-list)
< (read-from-minibuffer
< "Nickname: " nick
< nil nil 'erc-nick-history-list)))
< (passwd (if erc-prompt-for-password
---
> "Nickname: " nick
> nil nil 'erc-nick-history-list))))
>
> (setq server user-input)
>
> (setq passwd (if erc-prompt-for-password
2210c2210
< erc-password)))
---
> erc-password))
2212a2213
>
2223,2224c2224
< (run-hook-with-args 'erc-before-connect server port nick)
< (erc server port nick erc-user-full-name t passwd)))
---
> (list server port nick passwd)))
2226,2227c2226,2228
< (defun erc-select-ssl (&optional server port nick)
< "Interactively select SSL connection parameters and run ERC.
---
> ;;;###autoload
> (defun* erc-select (&optional (server erc-server) (port erc-port) (nick erc-nick) passwd)
> "Interactively select connection parameters and run ERC.
2231c2232,2241
< (interactive)
---
> (interactive (erc-select-read-args))
>
> (run-hook-with-args 'erc-before-connect server port nick)
> (erc server port nick erc-user-full-name t passwd))
>
>
> (defun erc-select-ssl (&rest r)
> "Interactively select SSL connection parameters and run ERC.
> Arguments are as to erc-select."
> (interactive (erc-select-read-args))
2233c2243
< (erc-select server port nick)))
---
> (apply 'erc-select r)))
6468a6479,6488
> (defun erc-compute-port (port)
> "Return a port for an IRC server.
>
> Tries a number of increasingly more default methods until a non-nil
> value is found:
>
> - PORT
> - \"ircd\"."
> (or port "ircd"))
>
--
I'm awfully glad I'm a Beta, because I don't work so hard.
|