Emacsist RSS --- If never, make it ever: C-h C-h

Emacs Spotlight: Typographic Editing Modes

7001

这里 查看更多 Emacs 相关推荐文章最新 Emacs 圈的动态. 欢迎关注微信公众账号: Emacsist

In this post I’ll introduce you to two modes that bring some typographic editing features to Emacs: Typo Mode and Tildify Mode. These modes help you use typographic quotes, punctuation and spaces.

Typo Mode

Typo Mode is a 3rd party package that supports typographic quotes and punctuation. It comes in two flavours. typo-global-mode is a global minor mode which provides shortcuts for many special unicode characters under C-c 8, complementing the built-in C-x 8 keymap.

typo-mode itself is more interesting. This minor mode changes the behaviour of some keys like ", . or - to cycle among typographic variants of the corresponding character or to compose repeated occurrences into a single typographic character.

For example, " inserts (left double quotation mark). Subsequent pressing of" cycles among " (quotation mark), , (right double quotation mark), (left single quotation mark), and (right single quotation mark). The initial character is context-aware: After a left double quote the first character becomes , a single quotation mark, that is. Likewise, after an opening single quotation mark the first character is , i.e. the closing single quotation mark.

Typo Mode supports different languages with different quotation rules. The above shows the quotation rules of the English languages; Typo Mode also supports Czech, German, French, Finnish, Russian and Italian. Changing the language with M-x typo-change-language changes both the initial character and the subsequent cycling characters. For instance, in German language cycling starts at ? (low double comma quotation mark) which is the opening quotation character in German language.

In a similar way - cycles through different variants of hyphens and dashes.. continues to insert a normal dot, but inserting three dots in a row will insert a unicode ellipsis .

To enable Typo Mode add it to the hooks of the modes you’d like to use Typo Mode in:

(add-hook 'text-mode-hook #'typo-mode)

If you use Spacemacs enable the Typography layer.

Tildify Mode

Tildify Mode is a built-in mode in Emacs 25 and upwards that automatically inserts non-breaking spaces when appropriate. A non-breaking space is like a normal whitespace but inhibits word wrapping. It is typically used after single letters where a line breaking would be confusing and distracting. For instance, it’s bad style to have a line break after “I”, because a single letter at the end of a line is too easily overlooked.

A good word processor or a type setting system such as LaTeX normally handles non-breaking spaces automatically, but the layout engines of browser or plain text viewers are not that sophisticated and require explicit non-breaking spaces to achieve a good text layout. Tildify Mode helps you by inserting non-breaking spaces at obvious places such as single letter words.

Like Typo Mode you can enable Tildify Mode by adding it to appropriate hooks, e.g.

(when (version<= "25" emacs-version)
  (add-hook 'text-mode-hook #'tildify-mode))

Tildify Mode is also part of the Typography layer of Spacemacs.

原文出处: Sebastian Wiesner
原文地址: http://www.lunaryorn.com/2015/12/23/typographic-editing-modes.html
原文时间: 2015-12-23 07:00
本文地址: http://emacsist.com/10624
整理时间: 2015-12-24 13:17

本文由 Hick 整理,转载请保留以上信息;
COPYLEFTThe articles on this site come from Internet, thanks to all the original authors.
      If anything about COPYRIGHT, or LEFT, please contact Emacsist at gmail dot com .