Книга: Learning GNU Emacs, 3rd Edition

3.4.2.5 Abbreviations and capitalization

3.4.2.5 Abbreviations and capitalization

Usually, Emacs capitalizes abbreviations exactly the way you want. If you run into special situations with abbreviations and capitalization, however, you may wantl to know what's going on behind the scenes. Here are the rules:

• If the abbreviation's definition contains any uppercase letters, Emacs always inserts the definition without changing anything. For example, if you define ora as an abbreviation for O'Reilly Media, O'Reilly will always be capitalized exactly as shown.

• If the abbreviation's definition is all lowercase, Emacs capitalizes according to the following rules:

     - If you type all of the letters of the abbreviation in lowercase, Emacs inserts the definition in lowercase.

     - If you type any of the letters of the abbreviation in uppercase, Emacs capitalizes the first letter of the first word.

     - If you type all of the letters of the abbreviation in uppercase, Emacs capitalizes the first letter of every word, unless the variable abbrev-all-caps is set to t; in this case, it capitalizes all letters.

Table 3-7 shows some examples.

Table 3-7. Word abbreviation capitalization

Abbreviation Definition You type: Expands to: Because:
lc lamb chop lc lamb chop lc is lowercase, so lamb chop is lowercase.
lc lamb chop Lc Lamb chop There's one capital in Lc, so Lamb is capitalized.
lc lamb chop lC Lamb chop There's one capital in lC, so Lamb is capitalized.
lc lamb chop LC Lamb Chop LC is all capitals, so both words are capitalized.
lc Lamb Chop lc Lamb Chop Capitals in the definition are always unchanged.
lc Lamb Chop LC Lamb Chop Capitals in the definition are always unchanged.

You don't need to remember the rules, but looking them over may help you out if you can't understand how Emacs is capitalizing. In our experience, defining abbreviations in lowercase circumvents most capitalization problems.

Table 3-8 summarizes word abbreviation commands.

Table 3-8. Word abbreviation commands

Keystrokes Command name Action
M-/ dabbrev-expand Complete this word based on the nearest word that starts with this string (press M-/ again if that's not the word you want).
(none) abbrev-mode Enter (or exit) word abbreviation mode.
C-x a - orC-x a i g inverse-add-global-abbrev After typing the global abbreviation, type the definition.
C-x a i l inverse-add-mode-abbrev After typing the local abbreviation, type the definition.
(none) unexpand-abbrev Undo the last word abbreviation.
(none) write-abbrev-file Write the word abbreviation file.
(none) edit-abbrevs Edit the word abbreviations.
(none) list-abbrevs View the word abbreviations.
(none) kill-all-abbrevs Kill abbreviations for this session.

Оглавление книги


Генерация: 0.090. Запросов К БД/Cache: 0 / 0
поделиться
Вверх Вниз