Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] proportional font layer #6377

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions layers/+emacs/proportional/README.org
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#+TITLE: Typography layer

* Table of Contents :TOC_4_gh:noexport:
- [[#description][Description]]
- [[#install][Install]]
- [[#key-bindings][Key bindings]]
- [[#typo-mode][Typo Mode]]
- [[#tildify-mode][Tildify Mode]]

* Description
This layer provides support for typographic text editing in Spacemacs. It
provides modes to automatically insert and cycle among typographic characters:

- [[https://github.com/jorgenschaefer/typoel][Typo Mode]] automatically inserts and cycles among typographic Unicode
characters on some keys.
- Tildify Mode automatically inserts non-breaking spaces where required. (Only
available on Emacs 25).

* Install
To use this configuration layer, add it to your =~/.spacemacs=. You will need to
add =typography= to the existing =dotspacemacs-configuration-layers= list in this
file.

Typographic editing however is disabled by default. To enable it by default set
=typography-enable-typographic-editing= to =t=:

#+BEGIN_SRC emacs-lisp
(setq-default dotspacemacs-configuration-layers
'(typography :variables typography-enable-typographic-editing t))
#+END_SRC

This setting enables automatic insertion of non-breaking spaces where required
and automatic insertion and cycling among of typographic quotes and dashes.

* Key bindings

| Key Bindings | Description |
|--------------+------------------------------------------------------------------|
| ~SPC t T~ | Toggle Typo Mode (automatic insertion of typographic characters) |
| ~SPC t ~~ | Toggle Tildify Mode (automatic insertion of non-breaking spaces) |
| ~SPC x ~~ | Insert non-breaking spaces in the current region |

The following keybindings are available in insert state.

** Typo Mode

| Key Bindings | Description |
|--------------+------------------------------------------|
| ~​"​~ | Cycle among quotation marks |
| ~`~ | Cycle among left single quotation marks |
| ~​'​~ | Cycle among right single quotation marks |
| ~-~ | Cycle among dashes |
| ~.~ | Cycle among ellipsis |
| ~<~ | Cycle among left angle brackets |
| ~>~ | Cycle among right angle brackets |

** Tildify Mode

| Key bindings | Description |
|--------------+-----------------------------------------|
| ~SPC~ | Insert non-breaking space when required |
16 changes: 16 additions & 0 deletions layers/+emacs/proportional/config.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
;;; config.el --- proportional Layer configuration
;;
;; Copyright (c) 2012-2016 Sylvain Benner & Contributors
;;
;; Author: Johannes Goslar <jogo@kronberger-spiele.de>
;; URL: https://github.com/syl20bnr/spacemacs
;;
;; This file is not part of GNU Emacs.
;;
;;; License: GPLv3

(defvar proportional-font "DejaVu Sans"
"Default proportional-font to activate.")

(defvar proportional-monospace-font "DejaVu Sans Mono"
"Default proportional-font to activate.")
5 changes: 5 additions & 0 deletions layers/+emacs/proportional/funcs.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
(defun proportional/use-monospace ()
(interactive)
"Switch the current buffer to a monospace font."
(face-remap-add-relative 'header-line `(:family ,proportional-monospace-font))
(face-remap-add-relative 'default `(:family ,proportional-monospace-font)))
34 changes: 34 additions & 0 deletions layers/+emacs/proportional/packages.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
;;; packages.el --- typography Layer packages File for Spacemacs
;;
;; Copyright (c) 2012-2016 Sylvain Benner & Contributors
;;
;; Author: Johannes Goslar <swiesner@lunaryorn.com>
;; URL: https://github.com/syl20bnr/spacemacs
;;
;; This file is not part of GNU Emacs.
;;
;;; License: GPLv3

(defconst proportional-packages
'((proportional :location local)))

(defun proportional/init-proportional ()
(add-to-list 'default-frame-alist `(font . ,proportional-font))
(set-frame-font proportional-font)
(set-fontset-font "fontset-default" 'symbol proportional-font)
(setq variable-pitch `((t :family ,proportional-font)))

(add-hook 'dired-mode-hook 'proportional/use-monospace)
(add-hook 'helm-mode 'proportional/use-monospace)
(add-hook 'spacemacs-buffer-mode-hook 'proportional/use-monospace)
(add-hook 'tabulated-list-mode 'proportional/use-monospace)
(add-hook 'magit-popup-mode-hook 'proportional/use-monospace)
(add-hook 'which-key-init-buffer-hook 'proportional/use-monospace)
(add-hook 'mu4e-headers-mode-hook 'proportional/use-monospace))

(defun proportional/post-init-which-key ()
(edebug)
(spacemacs|use-package-add-hook which-key
:post-init
(with-current-buffer which-key--buffer
(proportional/use-monospace))))