From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Pascal J. Bourguignon" Newsgroups: gmane.emacs.help Subject: Re: [Emacs LISP] Login freenode using ERC with prompt for password only Date: Sat, 01 Dec 2012 10:54:51 +0100 Organization: Informatimago Message-ID: <87624mxfkk.fsf@kuiper.lan.informatimago.com> References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1354355712 2487 80.91.229.3 (1 Dec 2012 09:55:12 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 1 Dec 2012 09:55:12 +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 10:55:25 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 1TejnA-0006Ar-33 for geh-help-gnu-emacs@m.gmane.org; Sat, 01 Dec 2012 10:55:24 +0100 Original-Received: from localhost ([::1]:53713 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tejmy-0001TF-HB for geh-help-gnu-emacs@m.gmane.org; Sat, 01 Dec 2012 04:55:12 -0500 Original-Path: usenet.stanford.edu!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 47 Original-X-Trace: individual.net FIQLVbbV7OOYJvjLE7RpEgWPALU/KhcxS4/t3cIIHQgY0nRy6QtSmBtwTty2pH5TM4 Cancel-Lock: sha1:MzA1YzM3MWM0ZWQ1NGFjZjg1NzJlMjM2NDdkMjJkNGVmN2E3ZmI0Mg== sha1:3s3aiye1rea5N8KezTSgT5ZnfXI= Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwAQMAAABtzGvEAAAABlBMVEUAAAD///+l2Z/dAAAA oElEQVR4nK3OsRHCMAwF0O8YQufUNIQRGIAja9CxSA55AxZgFO4coMgYrEDDQZWPIlNAjwq9 033pbOBPtbXuB6PKNBn5gZkhGa86Z4x2wE67O+06WxGD/HCOGR0deY3f9Ijwwt7rNGNf6Oac l/GuZTF1wFGKiYYHKSFAkjIo1b6sCYS1sVmFhhhahKQssRjRT90ITWUk6vvK3RsPGs+M1RuR mV+hO/VvFAAAAABJRU5ErkJggg== X-Accept-Language: fr, es, en User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2 (gnu/linux) Original-Xref: usenet.stanford.edu gnu.emacs.help:195673 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:87994 Archived-At: 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 {}.