Mon, 15 Dec 2008
If you happen to be using Windows Emacs and Cygwin Python there's an annoying interaction where “M-x run-python” hangs. The easiest way to fix it is to mount the directory where you have your emacs installation into the Cygwin file name structure. For instance, I have my emacs installation in C:\emacs\emacs-22.2, and in a cygwin shell I did mount -b ‘C:\emacs' /emacs, and now running the Cygwin python works.
The emacs function run-python adds the emacs data-directory to the PYTHONPATH in the emacs process-environment before running python; unfortunately, since this is the MS Windows emacs, its data-directory starts with a drive letter and a colon. When the Cygwin python initializes sys.path it splits PYTHONPATH at the colons, which means sys.path ends up with the drive letter as one component (usually interpreted as a relative path) and everything after the colon as another component. It that's a valid Cygwin pathname for the Emacs data directory (which is what the above mount command did), things work (accidentally).
Thu, 11 Dec 2008
It turns out that if you execute the command xterm-mouse-mode (or evaluate (xterm-mouse-mode 1) in your initialization file) when running Emacs under Screen it allows “non-modified single clicks” to work. Normal mouse functionality is still available by holding the Shift key while clicking. I use the PuTTY ssh client for remote access to various servers, and this works well Emacs in Screen under PuTTY, too.
Wed, 10 Sep 2008
Well, it looks like a leader is slowly emerging in my quest for an Emacs based mail reader: Wanderlust
It handles MH- and Maildir-format mailboxes, UTF-8 in headers, has good facilities for reading and composing MIME messages, and I finally got it to work with Lotus Domino/Notes IMAP/SSL, amazingly.
Moreover, it looks like I'm probably going to switch to using a Maildir-format mailbox, which will work well with my use of Unison: MH-format mailboxes' use of plain numbers for message IDs/filenames (which can change a lot) makes things a little more confusing when syncing mailboxes with Unison.
Moving away from MH-format mailboxes is a bit of a shame, since it means that I'll be losing the ability to use the MH command line programs for accessing my e-mail. I've used MH in the past, and have always liked the command line access it gives you. Ah well. I wish mdmh had advanced further.
Sat, 06 Sep 2008
I'm still having my personal e-mail crisis.
I said, earlier,
Anyway, I've finally come up with a way to switch back and forth between Gnus, Mew, and MH-E while keeping up with my current e-mail[…].
That was a bit premature. What I should have said was that I'd found a way to make sure I didn't lose any e-mail permanently when switching back and fourth between e-mail clients. I'm using maildrop to copy my incoming mail to the normal mail spool file and to a separate archive mail file for each day. So, for instance, all the mail I got on 2008/09/05 is archived in the mbox-format file ~/Inboxes/2008-09-05.inbox.
I also said, earlier
Wanderlust seems moribund.
It turns out that Wanderlust only seems moribund, especially to those who only speak English. If you check the mailing lists there's still some activity, and if you poke around on the Wanderlust site you can find a newer snapshot. Unfortunately, Wanderlust uses several other libraries (APEL, FLIM, and SEMI) and these are also hard to find much information about if you only speak English. So I've been fiddling around with it, and have figured out enough to get it working for me. (Thank goodness for the FreeBSD ports system.)
Oddly enough, although Wanderlust mostly understands MH-format mailboxes, there seems to be no built-in way to get it to read mail out of a standard mbox-format spool file and into your inbox. I guess the assumption is that if you're not using IMAP then you've probably moved on to using a maildir-format spool file, since they're supposed to be more reliable.
Well, I'm not. I'm trying to compare Wanderlust, MH-E, and Mew, and MH-E doesn't understand maildir-format mailboxes, so I have to stick to mbox-format. (Ok, I suppose I could mung things so MH-E uses Mew's incm to read the spool file.)
Moreover, I've got a fairly odd pattern of e-mail folders. For years in VM I've saved my e-mail in in separate folders with names like 2008/08/users.bond_tk or 2008/08/list.clisp, with VM defaulting the folder names automatically. I think I've mostly figured out how to do this in MH-E, Mew, and Wanderlust, and I've mostly figured out how to get the three of them to coexist peacefully, so I can really give them a good comparison. We'll see how it goes.
Like many Emacs subsystems, the Emacs e-mail clients tend to use modes with single-character commands for many things, and most the commands are just regular keys, not key combinations. I've gotten so used to this that I find using e-mail clients that require mousing to be extremely painful. Moreover, I've become very accustomed to being able to customize my e-mail client extensively using Lisp.
What it all boils down to is that I'm not happy unless my e-mail client is part of Emacs.
Sat, 16 Aug 2008
Fri, 15 Aug 2008
Ok, suppose you want to evaluate a particular bit of code after emacs loads a particular emacs-lisp file, but you want to pass values of local variables into that code. The function eval-after-load makes you quote the expression and doesn't allow passing values into the expression. How about this?
(require 'cl)
(defmacro* eval-after-load* (file varlist &rest body)
"Like `eval-after-load', but bind variables according to VARLIST in
the current environment of the `eval-after-load' expression, not the
environment when BODY is evaluated. This allows easy passing of values
into BODY.
Each element of VARLIST is a symbol (which is bound to the current value
of that symbol) or a list (SYMBOL VALUEFORM) (which binds SYMBOL to the
value of VALUEFORM in the environment of the `eval-after-load' expression."
`(eval-after-load ,file
'(let ,(loop for v in varlist
collect (if (symbolp v)
`(,v ,(eval v))
`(,(car v) ,(eval (cadr v))))
into new-varlist
finally return new-varlist) ,@body)))
(put 'eval-after-load* 'lisp-indent-function
(1+ (get 'eval-after-load 'lisp-indent-function)))
Here's a contrived example which demonstrates when things happen.
(let ((f (make-temp-file "tkb-madness" nil ".el"))
(x 1))
(unwind-protect
(progn
(save-excursion
(let ((buf (find-file f)))
(insert (format "(y-or-n-p \"In the file '%s'! \")" f))
(save-buffer)
(kill-buffer buf)))
(y-or-n-p "This happens before the eval-after-load*")
(eval-after-load* f
(x
(y (y-or-n-p "This happens when the eval-after-load* is executed?"))
(z 2))
(y-or-n-p (format "x: %d y: %S z: %d" x y z))
(y-or-n-p "This happends during the delayed expressions"))
(y-or-n-p "This happens after the eval-after-load* expression")
(load f))
(when (file-exists-p f) (delete-file f))))
You should see something like:
Wrote /tmp/tkb-madness88647vuE.el This happens before the eval-after-load*(y or n) This happens when the eval-after-load* is executed?(y or n) This happens after the eval-after-load* expression(y or n) Loading /tmp/tkb-madness88647vuE.el (source)... In the file '/tmp/tkb-madness88647vuE.el'! (y or n) x: 1 y: t z: 2(y or n) This happends during the delayed expressions(y or n) Loading /tmp/tkb-madness88647vuE.el (source)...done
(y-or-n-p is used instead of message so you see each message when it happens.)
Does the eval-after-load* macro make sense?
Ever use the emacs command describe-char? It's even more fun with proper unicode lookup data!
;; First, we'll bind it to a key.
(global-set-key "\C-cD" #'describe-char)
;; Now we'll download it if necessary.
(let ((udf-url "http://www.unicode.org/Public/UNIDATA/UnicodeData.txt")
(udf-dest "~/tmp/UnicodeData.txt"))
(if (file-readable-p udf-dest)
;; Let describe-char know it exists.
(setq describe-char-unicodedata-file udf-dest)
;; It doesn't exist, and we need to download it!
(when (y-or-n-p (format "You need to download %s ! Do it? " udf-url))
;; Really weird: wget -O 'file' complains that file doesn't exist.
(let* ((cmd (format "cd ~/tmp/ && wget -O %s --progress=dot '%s'"
udf-dest udf-url))
(buf (get-buffer-create (format " *wget '%s'*" udf-url)))
(proc (start-process-shell-command "wget-unicode-Data"
buf cmd)))
(display-buffer buf)
(set-process-sentinel
proc
`(lambda (proc event)
(unless (string-match "^finished" event)
(error "unexpected status '%s' getting '%s'" ,udf-url event))
(setq describe-char-unicodedata-file ,udf-dest)
(message "Try describe-char now! ☣☥☸▧◉✘✽☮⅙▧⚅☑☢☹☺♠♥♦♣♨♻⚔")))
(message "Downloading... check describe-char later")
nil))))
Once this is run and it tells you to try describe-char you can position your cursor over one of the Unicode characters in the message (“C-h e” to display the “*Messages*” buffer) and press “C-cD” and look for the “Name:” line. You'll see something like this:
character: ♻ (299515, #o1110773, #x491fb, U+267B)
charset: mule-unicode-2500-33ff (Unicode characters of the range U+2500..U+33FF.)
code point: #x23 #x7B
syntax: w which means: word
buffer code: #x9C #xF2 #xA3 #xFB
file code: #xE2 #x99 #xBB (encoded by coding system mule-utf-8)
display: terminal code #xE2 #x99 #xBB
Unicode data:
Name: BLACK UNIVERSAL RECYCLING SYMBOL
Category: other symbol
Combining class: Spacing
Bidi category: Other Neutrals
Tue, 05 Aug 2008
I've been having a personal e-mail crisis for the past couple of months. (If you've noticed that my e-mail has been even slower and more erratic than usual, that's why.) I've been trying to figure out a better mail setup and due to my complicated use patterns it has been tricky.
I have dialup Internet access at home, at speeds that are moderately slow even for dialup. I have a personal server elsewhere that does have good internet access, and that's were my e-mail is delivered. My main work computer is a Windows XP laptop. I often work at client sites, and sometimes work at places that have no Internet access, or very limited access with strict controls. I need to read, or at least refer to my e-mail at all those places.
For years I've used Emacs and ViewMail (aka VM) to read my personal e-mail, syncing my e-mail directories between my Internet server, my home machine, and my work laptop with Unison, and primarily reading e-mail on my Internet server. This has worked reasonably well.
I live in Emacs anyway (the Control key is the most worn key on my keyboard for some reason…) and am thoroughly happy with it for editing (and probably dependent on it), and VM has been very comfortable as well. However, development of VM went into hibernation after the release of version 7.19, and so hadn't kept pace with later e-mail developments. Recently the original author of VM, Kyle Jones, handed over development to Robert Widhopf-Fenk and development has picked up again, but it's still lacking some features that I need, and unfortunately I don't have time to devote to adding them myself.
I can't imagine giving up Emacs for reading e-mail, since it integrates so well with the rest of what I do and I enjoy using Emacs and Emacs Lisp, so I'm looking for a new Emacs-based mail reader. So far I haven't been happy with any of my choices.
Back when I read USENET news regularly I used Gnus and loved it. It is distributed with Emacs and seems to have regular development and maintenance. In theory, Gnus can also be used to read e-mail, but because of its news reader design it takes a very unconventional approach to reading e-mail. I'm not entirely comfortable with it, and I haven't figured out the best way to integrate my huge archive of old mail. Moreover, the documentation is quirky and difficult and the programming interfaces are quirky and complicated.
There are other Emacs mail readers. I used RMAIL for a while before I moved to VM, but I can't see moving back. Wanderlust seems moribund. I've used the RAND MH Message Handling System (MH) in the past, outside of Emacs, and there are a couple of modern versions of that (nmh, Mailutils). It turns out there are actually a couple of extensive Emacs interfaces to it: Mew and MH-E. I've looked a little at both, and have had some luck with each. I'll have to see how they compare over time.
I'd be interested in learning about any other Emacs-based e-mail clients. The EmacsWiki doesn't seem to have any other likely prospects, though.
Anyway, I've finally come up with a way to switch back and forth between Gnus, Mew, and MH-E while keeping up with my current e-mail, so I can search for better ways to deal with my old e-mail and compare new email. I should be back to dealing with e-mail quickly and effectively.
A really impressive and unlikely success would be to find a new way of reading mail that lets me access my work e-mail, which is in our corporate Notes e-mail system, from Emacs.