There are some features commonly found on MS-Windows-based editors
that some people find desirable to have. For example, the action of
the shift-arrow keys and the control-tab combination in
MS-Windows-based editors is rather convenient. Also, the behavior of
the cursor when scrolling in an MS-Windows-based editor is quite
intuitive. PC Mode emulates some of these features in GNU Emacs.

PC mode is not the only package that emulates aspects of
MS-Windows-based editors in GNU Emacs. There are other packages out
there that do similar things. Most notably, there is
pc-bindings-mode and pc-selection-mode.
What my PC mode offers is a certain unique combination of features
which I personally think are most desirable. Specifically, I am not
aware of any other GNU Emacs package that offers my cursor behavior
when scrolling, or my MS Visual Studio 8 style quick buffer selection
via control-tab.

UsingPC mode also makes it easy for users of Microsoft products such
as Microsoft Visual Studio to switch to GNU Emacs.

I am using PC Mode with GNU Emacs 22. If you are running a more
recent version of GNU Emacs, you're on your own. Since backward compatibility is not a
feature of GNU Emacs, PC Mode may or may not work. If you are running GNU Emacs Version 21, you
will have to install an earlier version of PC Mode. This earlier version can be found in
a subdirectory named emacs21 in the distribution.

There is no need to study a lot of documentation concerning PC
Mode. Just install it according to the instructions below, start using Emacs, and
try the following key combinations (note the behavior of
the cursor when scrolling):

PC mode can be downloaded from
here.
If you are using GNU Emacs 22, place the file
pc-mode.elc in some directory DIR and add the lines

(load-file "DIR/pc-mode.elc")
(pc-mode 1)

to your Emacs initialization file. If you are still using GNU Emacs 21, then place the file
pc-mode-21.elc in the directory DIR and add the lines

(load-file "DIR/pc-mode-21.elc")
(pc-mode 1)

to your Emacs initialization file. "DIR/" may of course be omitted
if the .elc file is in a directory where Emacs looks for lisp
files. Be sure to load the .elc file and not the
.el file. It is customary but not necessary to put the
.el file in the same directory as the .elc file.

Please note: Once PC Mode has been turned on, you must neither enable or
disable competing or related packages such as pc-selection-mode or
transient-mark-mode. Doing so will almost certainly override
key bindings that PC Mode needs or otherwise interfere with the proper
functioning of PC Mode.

MS-Windows-based text editors start a new selection, that is,
highlighted text, whenever the user moves the cursor or scrolls with
the shift key pressed. Further cursor movement or scrolling with the
shift key pressed will then extend or shrink the region.

The analog of the selection in GNU Emacs is the region, that
is, the text between the point and the mark. Traditionally, the Emacs
region is not highlighted. The only way to visualize it is to call
exchange-point-and-mark, e.g., by pressing Ctl-x
Ctl-x.

If transient-mark-mode and
delete-selection-mode are turned on in Emacs, then the
region behaves much more like the selection in an MS Windows
editor. However, to start an active region (or selection in Windows
speak), one still has to set the mark in the traditional way, e.g., by
pressing Ctl-SPC. Ordinary cursor movement or scrolling
will then extend or shrink the active region. To deactivate the region
without any further effect, one must call
keyboard-escape-quit, e.g., by pressing M-ESC
ESC.

What PC mode does is to make the arrow keys, the page
up/down keys, and the home and end keys behave as described above for
MS-Windows-based editors.

There are a number of more sophisticated ways of moving the cursor
under Emacs, e.g., Ctl-M-p
(backward-list). One might consider having the same
Windows-style behavior for these keys as well. However, PC mode
currently does not do that. The reason is that a key combination such
as Shift-Ctl-M-p does not seem to add any
convenience. Moreover, there are environments that cannot even distinguish
between Ctl-M-p and Shift-Ctl-M-p. To
create an active region (a selection in Windows speak) with a key such
as Ctl-M-p, you proceed as you normally would in
transient mark mode: set the mark with Ctl-SPC, then move
the cursor.

In PC mode, if you type Ctl-TAB or
Shift-Ctl-TAB, you will be shown a no-frills buffer
list. Special buffers that do not visit files such as
*Completions* or *Help* are not shown, with
the exception of the *Scratch*
buffer. Ctl-TAB or down-arrow moves down in the buffer
list, whereas Shift-Ctl-TAB or up-arrow moves up. To
switch to the selected buffer, you must type TAB or
RET. Any other key will abandon the buffer selection.

The choice of the window in which to show the newly selected buffer is
governed by the following rules:

If the selected buffer is already shown in one or more Emacs windows, then
the nearest one of these (in Emacs' window order) is used.

If the current buffer is a special buffer such as *Completions* or
*Help*, then another window is used. This behavior is based on
the assumption that buffers such as compilation buffers or debugging
buffers are special output areas that should not be used for editing files.

Absent any of the above considerations, the currently selected window is used.

If you precede the first Ctl-TAB (or Shift-Ctl-TAB,
as the case may be) with a Ctl-u, then the buffer selection
behaves like the emacs funtion switch-to-buffer-other-window
(Ctl-4-b): the buffer that you have selected is always shown
in another window.

When you scroll a buffer in Emacs, the cursor tries to stay at its
current position in the text. (More precisely, in Emacs terminology,
the point tries not to move.) This attempt to leave the
cursor position unchanged in the text will of course not be successful
for very long: soon, the cursor will end up at the top or bottom of
the screen. If, for example, you have the cursor somewhere in the
middle of the screen, then scroll up one or more screenfulls to look
at something, then scroll back to where you were before, your cursor
has moved to the top of the screen. There is no conceivable
reason why you would want it there.

A more user-friendly way of handling the cursor upon scrolling
(although it may seem counterintuitive at first) is to leave the
physical cursor position on the screen unchanged. PC mode makes the
page-up and page-down keys behave that way.

Another feature that is common in MS-Windows-based editors is to have
control-up-arrow and control-down-arrow bound to scrolling by one line
(smooth scrolling). PC mode provides that binding. Again, the cursor
stays at its physical position on the screen. This kind of smooth
scrolling with the cursor being fixed on the screen is particularly
useful for looking at code indentation.

With smooth scrolling, I do sometimes find myself wanting the
cursor to stay at its position in the text. Therefore, PC mode binds
smooth scrolling with the cursor fixed in the text to alt-up-arrow and
alt-down-arrow.

Finally, PC mode provides a way to parallel-scroll through the current
buffer and the buffer in the next window. To try this, make two
windows—the term "window" being used in the sense of Emacs here—on
your screen and press control-page-up and control-page-down.

When you perform a query-replace via M-% and the mark is
active, that is, you have a highlighted region, then PC mode will make
the content of the region the default for the string to be
replaced. Moreover, PC mode will move the point to the beginning of
the active region. That way, the first occurrence to be replaced will
be the active region.

It is quite common for the replacement string to be similar to the
string that is to be replaced. Therefore, the string that is to be
replaced is a good default for the replacement string. However, PC
mode does not fill in a default for the replacement string. The reason
for that is the fact that the string to be replaced is always
available as the previous history item via M-p.

If you do a query-replace via M-% and the mark is not
active, then the default for the string to be replaced is the last
string that you have searched for.

If transient mark mode is on in Emacs, exchanging the point and the
mark—e.g., by pressing Ctl-x Ctl-x—will
activate the mark, that is, the region will become highlighted. Some
people find this annoying because they often use the mark as a "quick
bookmark," that is, they use Ctl-x Ctl-x to switch
between two positions in the text. Therefore, by default, PC mode
rebinds Ctl-x Ctl-x so that it does not change the
activation state of the mark. Instead, PC mode provides the function

pc-toggle-mark-active

for toggling the activation state of the mark. To bind this function
to a key, put something like

(global-set-key [?\C-c ?t] 'pc-toggle-mark-active)

in your Emacs initialization file.
If, on the other hand, you do want Ctl-x Ctl-x to always
activate the mark, put the line

(pc-exchanging-point-and-mark-activates-mark 1)

in your Emacs initialization file. This function can also be used
interactively to toggle the behavior of Ctl-x Ctl-x, as in

When you have an active selection in an MS-Window-based editor and
then copy that selection to the clipboard, the selection remains
active. Under Emacs' transient mark mode, by contrast, saving an
active region as kill (e.g., by pressing M-w), will
deactivate the mark, that is, the highlighting of the region
disappears. By default, PC mode emulates the Windows-style
behavior. However, you can toggle that behavior between Windows-style
and transient-mark-mode-style with

M-x pc-kill-ring-save-deactivates-mark

If you always want the region to be deactivated upon saving it as kill, you
can put the line

PC Mode supports three different kinds of quick buffer selection via
Ctrl-TAB. The default one is inspired by MS Visual Studio 8 (VC8); it is
described above in Section "Quick Buffer
Selection with Ctl-TAB."

The function

pc-control-tab-emulation-type-vc6

changes to a mode that is inspired by older versions of MS Visual Studio like VC6.
Here, typing Ctl-TAB or Shift-Ctl-TAB will tentatively
switch to other buffers. Typing TAB or RET will confirm
the switch, while any other key will abandon it.

Please note: The VC6-style buffer selection does not recognize the prefix argument Ctl-u for
switching to another window the way the default style does.

The function

pc-control-tab-emulation-type-emacs

changes to a mode where typing Ctl-TAB or
Shift-Ctl-TAB will dispaly the offer to switch to other
buffers in the minibuffer. Typing TAB or RET
will perform the switch. Any other key will abandon the buffer
selection and will be processed as usual in the current buffer. As
with the VC8 style, preceding the first Ctl-TAB
(or Shift-Ctl-TAB, as the case may be) with
a Ctl-u will cause the buffer to be selected in another
window.

GNU Emacs allows you to set the foreground and background color for
highlighting the region when the mark is active. PC Mode gives you
colors that very much resemble the colors commonly found in
Windows-based editors. Another color combination that some people like
is light pink on a dark red background. To obtain this, place the
lines