Выбрать главу

The lpr-buffer and lpr-region commands always check the variable lpr-switches to determine whether any options should be passed to the Unix lpr command. These options are used to request a particular printer and for many other purposes; see the manpage for lpr for more information. For example, if you want to use the printer named lpt1 whenever you print from Emacs, you would want to set lpr-switches to -Plpt1. To do so, add the following line to your .emacs file:

(setq lpr-switches '("-Plpt1"))

Note the single quote preceding, and the parentheses surrounding, the string "-Plpt1". This is just weird-but-necessary Lisp syntax; see Chapter 11 for more details.

You can also print from Dired. To print the file the cursor is on, type P. Emacs puts the default printing command in the minibuffer, and you can modify it.

Emacs also includes commands to print a buffer as a PostScript file. If you have formatted text in the file, you can print the buffer with those attributes by typing M-x ps-print-buffer-with-faces.

Table 5-3 provides a summary of commands for printing.

Table 5-3. Printing commands

Keystrokes Action
M-x print-buffer FilePrint Buffer Print the buffer (similar to Unix pr | lpr).
M-x print-region FilePrint Region Print the region (similar to Unix pr | lpr).
M-x lpr-buffer Print buffer with no page numbers (similar to Unix lpr).
M-x lpr-region Print region with no page numbers (similar to Unix lpr).
P OperatePrint From Dired, put the default print command in the minibuffer; you can change it or press Enter to execute it.
M-x ps-print-buffer-with-faces FilePostscript Print Buffer Print the buffer with text attributes.
M-x ps-print-region-with-faces FilePostscript Print Region Print the region with text attributes.

5.4 Reading Manpages in Emacs

You can read Unix online documentation (called manpages) from within Emacs by typing M-x man or by selecting Man from the Help menu.[30] This command creates a buffer with a formatted manpage in it, which you can scroll through (or copy from) using Emacs commands. Simply type: M-x man Enter Unix-command-name Enter.

For the Unix command name, you can use either a simple name, like ls, or a manpage section name like ttytab(5).

The advantage of using the man command is that you can scroll through the manpage easier than you can in some terminal applications or shell windows. Also, if you try to view manpages in shell mode, they may come out garbled if the settings aren't right, whereas man gives you clean text.

5.5 Using Time Management Tools

Emacs is a natural place to organize all your work. It won't replace your Palm or other handheld, but ongoing work in this area may help you sync your favorite device with your Emacs-based schedule. Here we cover the main features that Emacs itself offers—the calendar and the diary.

5.5.1 Displaying the Calendar

To display the calendar, type M-x calendar. Emacs displays a calendar window with three months: last month, this month, and next month.

Type: M-x calendar

Emacs puts the cursor on today's date and displays the date on the mode line. There's no room to write on the calendar; that's what the diary is for, which we'll discuss shortly.

By default, weeks start on Sunday. If you'd like them to start on Monday instead, type M-x set-variable calendar-week-start Enter 1 Enter. You enter the calendar again to have this take effect. If you'd like to have the calendar always start on Monday, add this line to your .emacs file:

(setq calendar-week-start-day 1)

If you'd like to see the calendar each time you start Emacs, you can add this line to your .emacs file:

(calendar)

5.5.1.1 Moving in the calendar

When you're in the calendar, Emacs sensibly moves by day rather than by character. C-f moves you to the next day; C-b moves you to the previous day. C-n moves you to the same day of the next week; C-p moves you back a week. The arrow keys work the same way. M-} and M-{ move forward and backward by month, and C-x [ and C-x ] move forward and backward by year. C-v scrolls forward by three months; M-v scrolls back three months.

The movement commands just discussed move you relative to the cursor position. If you're on Tuesday and you press C-n, you'll move to next Tuesday. If you're on January 25 and press M-} you'll move to February 25. If you're on August 15, 2004 and press C-x [, you'll move to August 15, 2003.

Other commands move to the beginning or the end of the week, month, or year. C-a and C-e move to the beginning and end of the week, M-a moves to the beginning of the month, and M-< moves to the beginning of the year. Table 5-4 summarizes these calendar movement commands.

To go to a particular date, press g d. Emacs asks for the year, then the month, and then the day. Emacs moves you to the day selected (this command is well-suited for answering that all-important question, "On what day of the week does my birthday fall in 2020?").

вернуться

30

This feature works on Linux, but not on Windows. To make it work on Mac OS X, set shell-file-name to /bin/sh.