From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Wenshan Ren Newsgroups: gmane.emacs.help Subject: Re: [Emacs LISP] Login freenode using ERC with prompt for password only Date: Sat, 1 Dec 2012 12:52:22 -0800 (PST) Message-ID: <7da798a5-cb19-4800-b4f2-a03eff0677d6@googlegroups.com> References: <87624mxfkk.fsf@kuiper.lan.informatimago.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: ger.gmane.org 1354395314 9447 80.91.229.3 (1 Dec 2012 20:55:14 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 1 Dec 2012 20:55:14 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Dec 01 21:55:26 2012 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Teu5s-0003of-EU for geh-help-gnu-emacs@m.gmane.org; Sat, 01 Dec 2012 21:55:24 +0100 Original-Received: from localhost ([::1]:44055 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Teu5g-0008S8-Vf for geh-help-gnu-emacs@m.gmane.org; Sat, 01 Dec 2012 15:55:12 -0500 Original-Received: by 10.66.88.131 with SMTP id bg3mr963390pab.39.1354395143336; Sat, 01 Dec 2012 12:52:23 -0800 (PST) Original-Received: by 10.50.5.174 with SMTP id t14mr566935igt.11.1354395143107; Sat, 01 Dec 2012 12:52:23 -0800 (PST) Original-Path: usenet.stanford.edu!kt20no12882002pbb.1!news-out.google.com!s9ni21683pbb.0!nntp.google.com!kr7no11975404pbb.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help In-Reply-To: <87624mxfkk.fsf@kuiper.lan.informatimago.com> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=122.107.221.54; posting-account=gpzUGgoAAABcXbnOmXbweAYtHvxE5KBK Original-NNTP-Posting-Host: 122.107.221.54 User-Agent: G2/1.0 Injection-Date: Sat, 01 Dec 2012 20:52:23 +0000 Original-Xref: usenet.stanford.edu gnu.emacs.help:195682 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:88003 Archived-At: Thank you so much, your reply really made me better on Emacs Lisp. I can't understand the first function very well as a beginner, so I modified the second to meet my needs, very trivial, but works :) (defun myerc () (interactive) (let ((password-cache nil)) (erc :server "irc.freenode.net" :port "6667" :nick "Meatball_py" :password (password-read (format "password for Meatball at freenode?"))))) Thanks again. On Saturday, December 1, 2012 8:54:51 PM UTC+11, Pascal J. Bourguignon wrote: > Wenshan Ren writes: > > > > > Hello everyone, I am new to Emacs LISP and trying to write a emacs > > > lisp, which hopefully will enable me to login irc without choosing > > > server/port/nick. > > > > > > After reading "C-h f erc", I end up with > > > > > > (defun my-erc() (erc :server "irc.freenode.net" :port "6667" :nick "mynickname")) > > > > > > If I put `:pass "mypassword"` at the end of the list, it works > > > fine. However, I don't want to put my password in .emacs, so I hope > > > Emacs will ask me for password when needed. > > > > > > With the my-erc function I wrote, erc will login password and I have to identify myself afterwards. > > > > > > Could you give me some hints on solving this? > > > > You could consider storing your irc password in ~/.authinfo, where other > > passwords (for news, email, ftp, etc) can also be stored. > > > > (require 'cl) > > (defvar *authinfo-file* "~/.authinfo") > > (defun password-for-machine-login (machine login) > > (cdr (assoc "password" > > (find-if (lambda (entry) > > (and (string= machine (cdr (assoc "machine" entry))) > > (string= login (cdr (assoc "login" entry))))) > > (netrc-parse *authinfo-file*))))) > > > > (password-for-machine-login "irc.freenode.net" "pjb") > > --> "XXXXXXXX" > > > > > > or you can ask the password to the user each time (it grows old very > > soon): > > > > (defun password-for-machine-login (machine login) > > (let ((password-cache nil)) > > (password-read (format "password for %s at %s ?" login machine)))) > > > > (password-for-machine-login "irc.freenode.net" "pjb") > > --> "XXXXXXXX" > > > > -- > > __Pascal Bourguignon__ http://www.informatimago.com/ > > A bad day in () is better than a good day in {}.