Showing posts with label emacs. Show all posts
Showing posts with label emacs. Show all posts

17 Oct 2011

Again about emacs gnus and gmail

Sometimes ago my gnus stopped sending emails through gmail SMTP server. The message was something like "connection refused". I didn't have time to dig the problem as in the office I'm using web mail due to company proxy and quite used to use it.

But after switching completely to Emacs 24 and starting using el-get with nognus I've decided to figure out what is the problem. Quick debugging of emacs smtpmail.el and network-stream.el showed me that problem comes from gnutls-cli which stopped connecting to port 587 of smtp.gmail.com with message "Connection refused". I've also recognized that in emacs 24 developers have introduced new parameter smtpmail-stream-type.
It has the following documentation:

Connection type SMTP connections.
This may be either nil (possibly upgraded to STARTTLS if possible), or `starttls' (refuse to send if STARTTLS isn't available), or `plain' (never use STARTTLS)..

Changing value to nil, starttls didn't help. After checking usage of the variable in open-network-stream function in network-stream.el I've recognized that it could have much more values:

:type specifies the connection type, one of the following:
  nil or `network'
             -- Begin with an ordinary network connection, and if
                the parameters :success and :capability-command
                are also supplied, try to upgrade to an encrypted
                connection via STARTTLS.  Even if that
                fails (e.g. if HOST does not support TLS), retain
                an unencrypted connection.
  `plain'    -- An ordinary, unencrypted network connection.
  `starttls' -- Begin with an ordinary connection, and try
                upgrading via STARTTLS.  If that fails for any
                reason, drop the connection; in that case the
                returned object is a killed process.
  `tls'      -- A TLS connection.
  `ssl'      -- Equivalent to `tls'.
  `shell'    -- A shell connection.
Also I found that we can use port 465 instead of 587 with smtp.gmail.com. After changing my configuration in .gnus to the following I can send emails from gnus again (hooray!!!):

(setq message-send-mail-function 'smtpmail-send-it
      smtpmail-starttls-credentials '(("smtp.gmail.com" 465 nil nil))
      smtpmail-auth-credentials '(("smtp.gmail.com" 465 "name@gmail.com" nil))
      smtpmail-default-smtp-server "smtp.gmail.com"
      smtpmail-smtp-server "smtp.gmail.com"
      smtpmail-smtp-service 465
;     smtpmail-debug-verb t
;     smtpmail-debug-info t
      smtpmail-local-domain nil
      smtpmail-stream-type 'ssl)




14 Mar 2011

Emacs el-get on windows

Emacs el-get allows you to install and manage elisp code for Emacs. It supports lots of differents types of sources and is able to installupdate and remove them, but more importantly it will init them for you.
It allows you to keep up-to-date you elisp packages like cedet, emacs-w3m and hundred others. But if you tried to use it on windows you will figure out that a lot of them fail to install. It is related to the fact that most of packages are using UNIX command line tools which are not working on windows out-of-box.
Fortunately most of them could be installed on windows with slight modifications. Below small how-to:
1. Download and install cygwin tools and and cygwin/bin folder to your PATH. For the most of the packages you will need:
- curl (I'll explain later why it is necessary)
- ssh
- openssl
- bzr/git/subversion etc - it depends on which version control system has been used for package. It could be easily identified from recipe file. Below simple example of yasnippet recipe:
(:name yasnippet
      :type svn
      :url "http://yasnippet.googlecode.com/svn/trunk/"
      :features "yasnippet"
      :post-init (lambda ()
           (yas/initialize)
           (add-to-list 'yas/snippet-dirs (concat el-get-dir "yasnippet/snippets"))
            (yas/reload-all)))

Pay attention to type. It is specifying used version control system. In the given example it is subversion. So to be able to install this package you need svn client in your path. It is not mandatory to have it from cygwin but I prefer to use cygwin one as everything could be installed by its setup from one place.

- make utility

- autotools (autoconf, automake and co.)

- etc. (please check what exactly recipe is using.)

2. Open bash from cygwin installation (simply run cygwin.bat file) and enter the following commands:
$ cd /usr/ssl/certs
$ curl http://curl.haxx.se/ca/cacert.pem | awk 'split_after==1{n++;split_after=0} /-----END CERTIFICATE-----/ {split_after=1} {print > "cert" n ".pem"}'
$ c_rehash
If you won't do that you will have certificate error during installation of el-get from github. These commands will imports many certificates for different sites which are collected by curl developers team.

3. Follow the instruction specified on el-get site.

4. If your favourite package gives error check the following:

- If you've installed client for version control mentioned in recipe and is path specified in your PATH?

- If site is available by web browser.

- If it fails during installation check what kind of commands have been used. Try to run them from CMD prompt (not bash). If needed correct them.

I'll give you example of my patches to emacs-w3m and cedet.

emacs-w3m

Original recipe was:
(:name emacs-w3m
      :type cvs
      :module "emacs-w3m"
      :url ":pserver:anonymous@cvs.namazu.org:/storage/cvsroot"
      :build `("autoconf" ("./configure" ,(concat "--with-emacs=" el-get-emacs)) "make")
      :info "doc")

autoconf, ./configure commands are shell scripts hence they are not executable from CMD prompt and this build will fail. Fixed version of recipe:
(:name emacs-w3m
      :type cvs
      :module "emacs-w3m"
      :url ":pserver:anonymous@cvs.namazu.org:/storage/cvsroot"
      :build `("autoconf" ("./configure" ,(concat "--with-emacs=" el-get-emacs)) "make")
      :build/windows-nt ("sh /usr/bin/autoconf" "sh ./configure" "make")
      :info "doc")

CEDET

Original recipe was:
(:name cedet
      :type bzr
      :url "bzr://cedet.bzr.sourceforge.net/bzrroot/cedet/code/trunk"
      :build ("touch `find . -name Makefile`" "make")
      :load-path ("./common"))
Patch for this recipe was more difficult as “`” symbol is not valid for CMD and you cannot pass whole this command to shell as touch binary. Moreover Makefile for CEDET use UNIX version of find command. Below how I fixed it:
(:name cedet
      :type bzr
      :url "bzr://cedet.bzr.sourceforge.net/bzrroot/cedet/code/trunk"
      :build ("touch `find . -name Makefile`" "make")
      :build/windows-nt ("echo #!/bin/sh > tmp.sh & echo touch `/usr/bin/find . -name Makefile` >> tmp.sh & echo make FIND=/usr/bin/find >> tmp.sh" 
          "sed 's/^M$//' tmp.sh  > tmp2.sh"
          "sh ./tmp2.sh" "rm ./tmp.sh ./tmp2.sh")
      :load-path ("./common"))
By this way you can fix almost any recipe. If you do it, don’t forget to send patch to original author and share with us ;)

9 Nov 2010

Emacs ELPA and Wanderlust

After installation of Wanderlust in Emacs I’ve recognized that package.el has stopped working with message:

Symbol’s function definition is void: mailcap-parse-mailcaps

I did some investigation and figured out that it is conflict between mailcap.el in FLIM package and mailcap.el in Gnus. The first one is not defining mailcap-parse-mailcaps function.

Quick fix is loading mailcap.el from Gnus manually before FLIM loading:

(load-file "C:/emacs/emacs-24.0.50/lisp/gnus/mailcap.el")



I’m not sure that this is correct solution but it seems work.