oscarbonilla.com
13Jan/080

Tête de Moine and… Challah?

This weekend I was surprised by an invite from a friend to have dinner at his house. I was even more surprised when he gifted me a Girolle and a Tête de Moine. Wow! What a present!

Tête de Moine and Challah

Unfortunately, I couldn't find any Zopf to eat my cheese with. If anyone knows of a Swiss bakery in the bay area, I'd like to know. At any rate, the bread you see in the picture is actually a Challah, which doesn't have milk and has honey, so it's not quite the same flavor. However, it was ok for having the Tête de Moine.

I've also found Tête de Moine at iGourmet, so I'll be able to get some more once I finish this one. Is there a place in the bay area where they sell Tête de Moine?

Tagged as: No Comments
4Jan/087

Beautiful Emacs (Windows Edition)

After fixing the font on my Carbon Emacs on Mac OS X, I'm spoiled with good fonts. Today I had to work on Windows and naturally, the only way to make Windows liveable is to work inside Emacs.

This is what a default installation of EmacsW32 looks like.

EmacsW32 Courier

Oh horror! You guys are kidding, right? Courier? Seriously?

Naturally, my first inclination was to use Inconsolata again. Just like in Mac OS X. However, this is what Inconsolata looks like.

Emacs W32 Inconsolata

WTF? What's with all the blurred text? Well, it turns out that anti-aliasing and text rasterization differ significantly between Mac OS X and Windows. Oh well. Scratch that plan.

Then I remembered that Incosolata is actually based on Consolas, which is a font Microsoft created specifically for programming.

I downloaded and installed Consolas, and voilà! Beautiful Emacs once again.

EmacsW32 Consolas

Now it was just a matter of figuring out what the font was called. I had changed the font by clicking on the Emacs frame and pressing the shift key. In order to see what that does, I ran the describe-key function by typing C-h k, then clicking on the frame while holding the shift key. That told me the function that is called is mouse-set-font and it's defined in c:/Program Files/Emacs/emacs/lisp/term/w32-win.elc. You can click on the file link and Emacs will take you to the function definition.

(defun mouse-set-font (&rest fonts)
  "Select an Emacs font from a list of known good fonts and fontsets.
 
If `w32-use-w32-font-dialog' is non-nil (the default), use the Windows
font dialog to display the list of possible fonts.  Otherwise use a
pop-up menu (like Emacs does on other platforms) initialized with
the fonts in `w32-fixed-font-alist'.
If `w32-list-proportional-fonts' is non-nil, add proportional fonts
to the list in the font selection dialog (the fonts listed by the
pop-up menu are unaffected by `w32-list-proportional-fonts')."
  (interactive
   (if w32-use-w32-font-dialog
       (let ((chosen-font (w32-select-font (selected-frame)
					   w32-list-proportional-fonts)))
	 (and chosen-font (list chosen-font)))
     (x-popup-menu
      last-nonmenu-event
      ;; Append list of fontsets currently defined.
      ;; Conditional on new-fontset so bootstrapping works on non-GUI compiles
      (if (fboundp 'new-fontset)
      (append w32-fixed-font-alist (list (generate-fontset-menu)))))))
  (if fonts
      (let (font)
	(while fonts
	  (condition-case nil
	      (progn
                (setq font (car fonts))
		(set-default-font font)
                (setq fonts nil))
	    (error (setq fonts (cdr fonts)))))
	(if (null font)
	    (error "Font not found")))))

Now, I don't know what all of that does, but it seems like (set-default-font font) is the one function that actually sets the font. In order to figure out what the font is called, I copied all of the function to the good old *scratch* buffer, and added a call to (message font) right after the call to (set-default-font font). Then I redefined the function by typing C-x C-e at the end of it. After shift clicking on the frame again and selecting the Consolas font I had all the information I needed.

Now it was just a matter of putting the following snippet in my .emacs file:

    (set-default-font
     "-outline-Consolas-normal-r-normal-normal-14-97-96-96-c-*-iso8859-1")

Ahh... I feel so much better now... now what was I doing in Windows again?

Tagged as: 7 Comments
2Jan/080

Lazy-loading emacs functionality

Quick, how big is your .emacs file? How long does it take emacs to load? A few days ago I found that my .emacs file had slowly grown to the point where it was taking emacs a significant amount of time to load. Something needed to be done.

A quick glance at the file told me I was loading a lot of modules that I seldom use. For instance, I occasionally write some code in Common Lisp or Haskell, so naturally I was loading slime and the haskell environment. I commented those out.

However, after commenting them out, I quickly realized that not loading them was problematic. When I wanted to use them, I had to open my .emacs file, uncomment the relevant portion, and M-x eval-region the code.

Then it occurred to me that I had a clear entry point for some of these modules. When I write Common Lisp, I usually start by loading SLIME's REPL by running M-x slime. I came up with the following code:

(defun slime ()
  (interactive)
  (add-to-list 'load-path "~/emacs/slime")
  (setq inferior-lisp-program "/usr/local/bin/sbcl")
  (require 'slime)
  (slime-setup)
  (slime))

Which basically sets up my slime environment and then loads slime. Note that the slime function itself is redefined as part of the evaluation of (require 'slime), so although this looks like a recursive call, it's not.

I've used this trick in several other cases and I think it's kind of neat. It helps me keep Emacs loading fast, but I still have all the bells and whistles available.

Tagged as: No Comments