Monday, October 12, 2009

Transparent emacs on windows

Here's a handy function which lets you choose a transparent level (0 is fully transparent and 100 is opaque), for the main emacs frame in both focused and unfocused state.
(defun transparent(alpha-level no-focus-alpha-level)
"Let's you make the window transparent"
(interactive "nAlpha level (0-100): \nnNo focus alpha level (0-100): ")
(set-frame-parameter (selected-frame) 'alpha (list alpha-level no-focus-alpha-level))
(add-to-list 'default-frame-alist `(alpha ,alpha-level)))

To run M-x transparent. 

Enter the values you want for when the window has focus and when it does not. In the background you can see system status information on the desktop, which is another excellent utility from sysinternals called BgInfo. It let's you display useful info about your system right on your desktop, similar to tools you may find on linux. 

Friday, October 9, 2009

MSDOS iterating filenames in a file

In an earlier post I covered finding the writable files in a directory, which is something you often need to do when messing around with source control. For example, if there's a writable file in your source folder that isn't checked out, then you know you need to add it before checking in. In fact I have a tool that compares my changelist with the list of writable files, and lets me know if I'm about to break the build when I check in.

Anyway I digress. Once you have found the writable files using:

dir source_folder /a-r-d /s /b > files.txt

then you may want to run some operation on them; for example make them read only.

Here's how to do that with the windows for command (see here for documentation)

for /F %i in (files.txt) do attrib -R %i

The for command with the /F option can iterate through a file full of filenames, which is what we generated with the first command, and run the operation after the do instruction.

It's actually quite powerful; you can specify comment markers, delimiters, and choose which of a number of columns you want to make into variables.

Wednesday, September 23, 2009

Windows command window title

Did you know you could change the title in the window of a command prompt using the title command? Example:

title Poop ha ha

Now that's only really useful for making windows with rude words in their title bars right? Well actually, I've found a great use for it. If you have a bunch of command prompt windows open then you have no idea which one is which on the Windows taskbar, once they are stacked. So naming them is a really useful habit since once named you can see which window is which.