: Learning GNU Emacs, 3rd Edition

10.1.6 A Dired Example

10.1.6 A Dired Example

Let's tackle another Custom example with the help of the Options menu. Dired (discussed in Chapter 5) has many customizable features. One such feature is the dired-view-command-alist variable. This is a list of helper applications that allow you to open various kinds of files. This feature can be quite handy for viewing binary files such as images or PDF files. This list of helper applications is tailored to Linux. If you want to use other applications or you're on a Windows or Mac system, you'll need to customize this variable.

Before you customize this option, you need to open a directory or simply type C-x d to enter Dired. Next, from the Options ? Customize Emacs menu, select the Specific Option item.

Choose Options ? Customize Emacs ? Specific Option


The minibuffer prompts for a specific option to customize (Windows).

The minibuffer prompts for an option name. We want to customize dired-view-command-alist.

Type: dired-view-command-alist Enter


Editing a list entry in Custom (Windows).

You should see the familiar Custom options for saving and resetting the values along with the value of the dired-view-command-alist variable. For this particular variable, we have a list of entries for common file types including PostScript files, PDF documents, and images. To alter one of the existing entries, simply move to the String line and edit the text in grey to launch the application you would like to use. (You can also alter the filename pattern by editing the text in the Regexp line.) For example, PDF documents can be viewed with the open command in Mac OS X, so we could change that line as shown in Figure 10-7. In fact, on Mac OS X, you can use the generic open command for just about every type of file. On Windows it is even easier. Simply enter %s as the string, and Windows uses its default application to open that file type.

Figure10-7.Editing a list entry in Custom (Mac OS X)


If you don't use DVI documents, you can get rid of that association using the DEL button shown in Figure 10-8.

Figure10-8.Deleting a list entry in Custom (Mac OS X)


You can also add new document types and viewers by clicking on any of the INS buttons. (The order of the associations isn't important for this particular variable, but it might matter for other lists.) To insert a new association before the PDF entry, activate the INS button to the left of the PDF entry.

Click on INS to the left of the PDF entry.


The first step in adding a new item to a list in Custom (Windows).

Now you can add an association for playing MP3 files on a PC by editing both the Regexp and String lines. Note that you'd have to supply a path to your helper application (winamp in this example) that matched your system. As mentioned earlier, if winamp was already the default helper application for MP3s, you could simply type %s for the String instead of the complete path to winamp.

Type [.]mp3' for the Regexp and c:appsmediawinamp.exe %s for the String:


The second step in adding a new item (Windows).

You may have noticed the Save Changes option in the Options menu. This menu item saves changes you make through the Options menu. For example, you can modify such settings as whether or not the toolbar is visible or the Save Place in Files between Sessions option. It does not save changes you have made through Customeven if you launched Custom from one of the Options ? Customize Emacs submenu items. You'll still need to use the normal Custom options to save those changes.

For our Dired variable example, then, you'll need to select one of the Save options available. In this case, we'll save it for the current session only.

Click on Set for Current Session


Saving changes for this session only (Windows).

When you're done saving your changes, you can exit the buffer as usual by clicking the Finish button, typing q, or typing C-x k to kill the buffer.


: 0.353. /Cache: 3 / 1