[comp.emacs] set automatic

ping@cubmol.bio.columbia.edu (Shiping Zhang) (01/25/91)

I want to know how to turn on vip-mode automatically when I invoke
emacs. I don't know what I should put in the .emacs file. Thanks for
any information.

-ping      ping@cubmol.bio.columbia.edu

cedman@golem.ps.uci.edu (Carl Edman) (01/25/91)

In article <1991Jan25.022333.4987@cubmol.bio.columbia.edu> ping@cubmol.bio.columbia.edu (Shiping Zhang) writes:
   I want to know how to turn on vip-mode automatically when I invoke
   emacs. I don't know what I should put in the .emacs file. Thanks for
   any information.

   -ping      ping@cubmol.bio.columbia.edu

Mode is not a global variable in emacs. Rather the mode depends on the
buffer. What mode is selected for a specific buffer depends on the
name of buffer and is determined with help of the variable auto-mode-alist.
It is a list of dotted pairs of regular expressions and modes.
Whenever a new file is loaded the name is checked against each of
these regexps and the mode of the first matching regexp becomes the
mode of the buffer. You can add automatic modes to your
auto-mode-alist like this (an example from my "~/.emacs" file):

(setq auto-mode-alist (cons '("\\.st$" . smalltalk-mode) auto-mode-alist))

If you only want to edit certain file types in vip mode simply add a
corresponding line to your "~/.emacs" file.

If on the other hand no regexp matches the buffer gets the contents of
the variable default-major-mode as a mode. So if you wanted this type
of behavior you would add a line like this to your "~/.emacs" file.

(setq default-major-mode 'vip-mode)

        Carl Edman


Theoretical Physicist,N.: A physicist whose  | Send mail
existence is postulated, to make the numbers |  to
balance but who is never actually observed   | cedman@golem.ps.uci.edu
in the laboratory.                           | edmanc@uciph0.ps.uci.edu
* Did you know that you can have a typo in your signature, send 100s of *
*  mails and 100s of world-wide posts, and nobody will ever tell you ?  *

cedman@golem.ps.uci.edu (Carl Edman) (01/26/91)

The above of course only applies to major modes. If you are using one
of the vi-minor modes the 'correct' way to set this up is to use the
mode hooks. e.g. if you want to use vi to edit c-files. Just add this
line:

        (setq c-mode-hook 'vip-mode)

Similar hooks apply to most modes. If text mode is your default mode
you can get vip by default by using:

        (setq text-mode-hook 'vip-mode)

If you already have some program in one hook and have a line like this
in your .emacs file (again from my .emacs file) it is slightly more
complicated.

        (setq text-mode-hook 'turn-on-auto-fill)

Try something like this:

        (setq text-mode-hook '(lambda () (turn-on-auto-fill) (vip-mode)))

Does that help ?

        Carl Edman


Theoretical Physicist,N.: A physicist whose  | Send mail
existence is postulated, to make the numbers |  to
balance but who is never actually observed   | cedman@golem.ps.uci.edu
in the laboratory.                           | edmanc@uciph0.ps.uci.edu
* Did you know that you can have a typo in your signature, send 100s of *
*  mails and 100s of world-wide posts, and nobody will ever tell you ?  *