Setting your Emacsens default directory when launched through a custom keyboard shortcut

Monday, April 2, 2012 Posted by

I noticed that Emacs was getting a default-directory value of / when launching it with a custom keyboard shortcut I set up in Gnome (2). The result is that opening a file started my search in the root (/) of the filesystem.

I suppose this is due to the way in which emacs was invoked (via the window manager). Given that there was no actual present working directory, I can understand that it would default back to using /.

At the time I was just setting the window title:

emacs -T Emacs

When considering how to work around this I first considered setting the default-directory in my .emacs file. This turned out to be a less an idea solution. Doing so causes it to become a global configuration value (all subsequent emacs launched via the terminal opened in ~). So instead, I changed my launcher command to this:

emacs -T Emacs -eval "(setq default-directory \"~/\")"

Works like a champ!

Excluding in the Emacs file completion buffer

Tuesday, January 3, 2012 Posted by

I realized tonight While hacking on Taboot that Emacs was showing particularly uninteresting files in the completion buffer when opening a file. For example, scripts.pyc.

I assumed that there was a facility for customizing this, so I did some research on the topic. Trying emacs filter possible completions and emacs filter list of completions both came up with the same documentation. The GNU documentation describes a customization facility similar to the filtering I sought after via the completion-ignored-extensions variable (part of the Dired group). However, it stops a bit short of what I was looking for. Quote from describe-variable for the variable (emphasis added):

Completion ignores file names ending in any string in this list. It does not ignore them if all possible completions end in one of these strings or when displaying a list of completions.

I went through some more search results and sure enough, stackoverflow provides again. In that response the author provided a fantastic defadvice which did exactly what I was looking for. By default it uses the value of your existing completion-ignored-extensions variable.

Mac OS X 10.7 – Getting songs off an iPod

Saturday, October 15, 2011 Posted by

A while back I wanted to backup the songs I’ve saved to my iPod. I was running Mac OS X Leopard (10.5). When I searched around I found a tool called iPodDisk. It worked great! Then Snow Leopard (10.6) came out.

The way the launcher for iPodDisk was written meant it only would launch on 10.4 or 10.5. When you launched iPodDisk you would receive the message:

“Sorry iPodDisk requires OS X 10.4 or later”

Fixing this was pretty simple. After searching their google code issue tracker I quickly came across issue #34, “Sorry iPodDisk requires OS X 10.4 or later“. The fix was simple, reply #3 in the thread said to just edit one line in the launcher so that the version check accepted a higher version.

Time goes on and eventually I did a full OS reinstall (for some reason or another) and just recently upgraded to 10.7 (Lion). I’d bought a new network storage unit (Western Digital My Book Live) and wanted to back up my iPod again. Of course, upon downloading and launching iPodDisk again it produced the same error it did previously. It was clear to me that iPodDisk was clearly not being maintained.

While searching for the fix again I decided to read some newer posts on the issue tracker. Reply #51 referenced MacFuse. The project site for that hasn’t made a new release since 2008 though. Reply #60 had the information I was finally looking for.

So the final solution that allowed me to backup my iPod on OS X 10.7, Lion, was to install these two pieces of software:

The result was perfect. The same functionality I had when using iPodDisk previously. When you launch iTunesFS it opens a new Finder window showing all mounted volumes. Navigate to the iTunesFS volume and you’re set.

Fedora 15 and the Lenovo T520 Thinkpad

Wednesday, September 14, 2011 Posted by

I just went through a harrowing experience of attempting to install Fedora 14 on a Lenovo T520 Thinkpad with my good friend, abutcher. The issue presented itself first as X failing to start after the installer loaded. After switching into low graphics mode we were able to go through the installer successfully. But that did not solve our problems completely. After booting into the desktop we were unable to change the display resolution from 1280×1024 to the native 1600×900.

We started as most people would, Googling for numerous combinations of “fedora 14 thinkpad T520″, “sandybridge linux”, “sandybridge fedora”, etc. The results were surprising. Numerous sources report the T520 works with “no special setup needed.” This was not true for us. We Tried installing a newer Kernel from rawhide and the newer xorg-x11-drv-intel driver (2.16). This did not fix the issue.

To compound our confusion, we noticed numerous posts referencing a BIOS option to disable the Nvidia 4200M (Optimus) card. Our system showed no signs of said card or any “internal”/”external” BIOS option.

Next we attempted installing Fedora 15. *ugh* GNOME 3 was not on our list of things to try today. But it was all we could think of.

This also did not work.

I started doing some heavy research. Somehow I ended up researching Kernel Mode Setting (KMS). The Debian Wiki was an especially useful resource for this.

Kernel Mode Setting (KMS) provides faster mode switching for X and console. It also provides native-resolution VTs on some laptops and netbooks which, prior to this, would use some standard mode, e.g. 800×600 on a 1024×600 panel.

This was relevant to my interests. “KMS provides native-resolution virtual terminals” you say? A quick trip to /boot/grub/grub.conf showed that we were booting our kernel with the nomodeset option. We made a new boot entry (protip: never change your boot loader without leaving a known “working” entry) and omitted the nomodeset option. We also set the value of the default variable to our new entry, set timeout to 10, and commented out the hiddenmenu directive.

This almost worked. We removed the xorg config file (/etc/X11/xorg.conf) and restarted the computer for good measure.

voila.

Our Lenovo Thinkpad T520 was booting X using the laptops native resolution.

Just to clarify:

  • Not ALL T520s come with the dual Intel Integrated Graphcs + Nvidia combination (ours did not)
  • This can really throw you off
  • The xorg-x11-drv-nouveau package/driver had nothing to do with this. That package provides an Nvidia driver (which did not affect us)
  • The kmod-nvidia package/driver also has nothing to do with this
  • This laptop has an integrated Intel HD 3000 Graphics chipset

VNC On Fedora 14 on Linode

Saturday, April 30, 2011 Posted by

Installed and configured tigervnc on my Linode host today, had a nasty problem getting fonts to display though. After KDE had loaded only the fixed width font used by vncconfig was showing, the rest were empty squares. Here’s what didn’t work on my Fedora 14 host:

  • xorg-x11-fonts-misc-7.2-12.fc14.noarch
  • 1:xorg-x11-xfs-1.0.5-8.fc14.x86_64
  • xorg-x11-server-Xvfb-1.9.5-1.fc14.x86_64

I contribute this to my lacking of any knowledge of what fonts KDE tries to use by default. After some googling I got lucky and found this thread where someone suggests the original poster install the liberation family of fonts. That ended up being what fixed the problem for me.

Them’s the rules (programming guidelines)

Friday, March 25, 2011 Posted by

In the future I hope to expand on this list. In general though, strive to follow the basics of the Unix Philosophy.

Law of Demeter

You should only know what your close friends tell you - http://en.wikipedia.org/wiki/Law_of_Demeter

  • Each unit should have only limited knowledge about other units: only units “closely” related to the current unit.
  • Each unit should only talk to its friends; don’t talk to strangers.
  • Only talk to your immediate friends.

Principle of least astonishment

Boring behavior is the new exciting - http://en.wikipedia.org/wiki/Principle_of_least_astonishment

  • “…when two elements of an interface conflict, or are ambiguous, the behaviour should be that which will least surprise the user…”

The “UNIX Way”

(Doing) less is more - http://www.faqs.org/docs/artu/ch01s06.html

  • Write programs that do one thing and do it well.

Make good with what you’re given, complain if you can’t

Rule of Repair: Repair what you can — but when you must fail, fail noisily and as soon as possible http://www.catb.org/~esr/writings/taoup/html/ch01s06.html#id2878538

  • Be liberal in what you accept, and conservative in what you send

Lots more docs published on PeopleAreDucks.com

Wednesday, September 22, 2010 Posted by

While I’ve been gone from the blogging world I’ve still been working on projects. Mostly I’ve been working on documentation.

  • Debian/Fedora Package Management comparison. Since switching my Slice to Fedora from Ubuntu I’ve picked up plenty of commands for managing packages. This is just a quick wiki page giving the roughly equivalent commands from Debian/Ubuntu to Fedora/RedHat.
  • regexp basics is a brief tutorial on regular expressions. My roommate abutcher put it together for his WVU CS210 (Advanced File and Data Structures) course. The DocBook 5 sources are available in git.
  • The biggest doc project I’ve been working on again (finally) is my Virtual Disk Guide aimed at power users and sysadmins. Currently it’s a rough draft and is constantly undergoing major changes and additions. It’s available as a single HTML document, chunked into multiple pages, and in PDF format. You can get the DocBook 5 formatted source to it through my GitHub account.

My Project Templates project has seen some much needed attention recently. The DocBook starter project has been completely redone. Here’s some reasons you might want to use it.

  • Includes a basic starter document with most of the available informational tags present but commented out so all you need to do is uncomment the elements you need for your document.
  • Inclues a customizable Makefile that can adapt itself to different operating systems (Debian/Ubuntu, Fedora/RedHat, and Mac OS X) by just uncommenting the proper directory paths for the schema and stylesheet files.
  • The Makefile has targets for: cleaning up, creating schema locator files for nxml-mode in emacs, publishing PDFs, and publishing chunked or single HTML documents.
  • The comments in the Makefile also tell you what packages you need to install to get the schema and stylesheet files.

Using the Makefile for publishing only requires having xsltproc and dblatex installed. Both of which are available through your favorite package manager.

Zone out completely

Friday, March 26, 2010 Posted by

While searching for modes which would help me edit bind9 configuration files I came across this mailing list post. It mentions zone-mode which ended up being great for editing the actual zone files A+. It also tipped me off to another emacs Easter Egg, M-x zone. Described thus:

zone is an interactive compiled Lisp function.
It is bound to <menu-bar> <tools> <games> <zone>.
(zone)
Zone out, completely.

It’s basically an emacs screensaver/psychedelic ascii mode using your focused buffer for content. It obfuscates the buffer in ways which involves wrapping your code around the screen or swapping characters around, and even just turning it all into curly braces and wiggling. Press a key to undo it all. Might be a neat trick to play on a friend, but I see no other usage for this mode.

DNS/LDAP

Sunday, March 21, 2010 Posted by

Hopefully getting something that resembles a DNS server polling from LDAP set up tonight. I love virtual machines.

Desktop Upgrade Tonight

Friday, February 19, 2010 Posted by

Tonight I’m upgrading my desktop (“fridge”) from Fedora 11 to 12. For my own personal benefit I’ll be documenting the process. Things I want to take note of in particular include: which additional files must be backed up for system services like samba, my current partition map, and what process I used to perform the upgrade (optical media, netboot?).