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

Monday, August 17, 2009

Font-lock for executable files in emacs dired-mode

I often see the face dired-face-executable in people's .emacs files, but it isn't used in the latest dired sources. So I added the following hook to colorize the filename for executable files:

(defface ric-dired-executable '((t (:foreground "PaleGreen"))) "Exe files in dired.")
(defvar ric-dired-face-executable 'ric-dired-executable)

(add-hook
'dired-mode-hook
'(lambda ()
(add-to-list 'dired-font-lock-keywords
(list dired-re-exe
'(".+" (dired-move-to-filename) nil (0 ric-dired-face-executable))))))

Wednesday, July 8, 2009

Different font sizes on different X screens

One of my trusty pair of Dell 1905FP monitors finally gave up the ghost. A little shopping around showed that, despite my luddite tendencies, 16:9 widescreen is the way forward. Today my shiny new ASUS VH222H arrived. It looks beautiful, and emacs is enjoying spreading out into the extra space.

However, my monitors are no longer a perfectly-matched pair. Trusty old Dell is plodding along at 1280x1024, and new ASUS on the block is showing off at a mind-expanding 1920x1080. Most of the time this is not an issue, since the Dell displays browsers almost all the of time, while almost everything else (i.e. emacs) happens on ASUS. For terminals on the Dell I have always used a 10-point font, but at higher resolution I need 12-point (I'm not getting any younger, I'd like to continue to see, and you kids get off my lawn).

Rather than using Xinerama or Twinview (I have an Nvidia card), I fire up a separate X screen on each monitor (:0.0 and :0.1). Since I use a tiling window manager (dwm) I never want to share windows across monitors, and this way I can switch desktops (tags) on one monitor without affecting the other. There is just one X server, however, so how to have different font sizes on different screens?

For reference, my window managers are started as follows from ~/.xinitrc:

DISPLAY=:0.1 dwm &
DISPLAY=:0.0 dwm


I set fonts in ~/.Xdefaults. Resources are loaded by xrdb, which preprocesses Xdefaults using the C pre-processor cpp. Using the pre-loaded symbol WIDTH we can test resolution and set font accordingly:

#if WIDTH >= 1600
#define FONT -b&h-lucidatypewriter-medium-r-normal-sans-12-*-*-*-*-*-*-*
#else
#define FONT -b&h-lucidatypewriter-medium-r-normal-sans-10-*-*-*-*-*-*-*
#endif

XTerm*font: FONT
Emacs*font: FONT


We could also test on the symbol SCREEN_NUM (see xrdb -symbols for all pre-loaded pre-processor symbols), but the above is more portable.

Finally, reload resources:

xrdb -load ~/.Xdefaults

Wednesday, June 17, 2009

Posting to blogger from emacs using e-blog

g-client is a bit of a nightmare to get working. I plan to go back and play with it, since it sets up a lot of useful plumbing for google services. But for now, no go on the blog.

weblogger looks like it may work for other blogging services, but appears to have been broken by blogger API changes.

However, e-blog works great with a minimum of fuss. Simply install in a lisp directory, and add this to ~/.emacs:


(load-file '~/path/to/e-blog/e-blog.el')


Invoke with:

M-x e-blog-new-post


Here's a shortcut function:

(defun blog ()
(interactive)
(e-blog-new-post))