nixmaniack / emacs-emojify

Display emojis in Emacs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Emojify

https://melpa.org/packages/emojify-badge.svg http://stable.melpa.org/packages/emojify-badge.svg https://travis-ci.org/iqbalansari/emacs-emojify.svg?branch=master

Table of contents

What is this?

Emojify is an Emacs extension to display emojis. It can display github style emojis like :smile: or plain ascii ones like :).

What does it look like?

Here is how the commit log of this project looks with emojify mode enabled

screenshots/emojify-in-action.png?raw=true

If you prefer a GIF you can view one here.

Requirements

This package requires Emacs v24.3 and above. Emacs should be compiled with support for PNG images. Additionally if Emacs is compiled with ImageMagick support emojify will use it to resize emojis if needed, however this is completely optional.

PNG support might require some additional steps to on Windows, you might find this stackoverflow answer helpful.

Installation

ELPA

emojify is available on MELPA and MELPA Stable. Please follow the instructions on MELPA website to enable it, if you haven’t already.

You can then install emojify from the package menu. Alternatively install it by doing the following

Refresh the package index

M-x package-refresh-contents RET

And then install it by doing

M-x package-install RET emojify

Usage

emojify-mode can be enabled/disabled separately for a buffer by using the command emojify-mode, to enable/disable it globally use the command global-emojify-mode.

To enable emojify-mode globally at startup add something like the following to your init file

(add-hook 'after-init-hook #'global-emojify-mode)

In programming modes only emojis in string and comments are displayed.

Customizations

Configuring the types of emojis displayed

Emojify by default displays plain text emojis like :) as well as github style emojis :smile:. However it can be instructed to display only one type of emoji. You can do so by customizing emojify-emoji-style using the customize interface. To change the value of the variable from Lisp using the function emojify-set-emoji-style (or set it before loading emojify), call it with one parameter the style of emojis that you want to be displayed. The possible values are

  • ascii - Display only plain ascii emojis
  • github - Display github style emojis
  • all - Display all of the above styles

Configuring how emojis are displayed

By default emojis are displayed using images. However you can instruct emojify to display it using unicode characters or ascii characters. To do so customize the variable emojify-display-style.

You can set it one of the following values

  • image - Display emojis using images, obviously this requires the Emacs instance to support image
  • unicode - Display emojis using unicode characters, this might be a good option on platforms with good emoji fonts
  • ascii - This is simplest and does not require any external dependencies In this case emojify will display ascii equivalents of github style emojis.

Configuring the buffers where emojify mode is enabled

You can control the buffers where emojify is enabled using emojify-inhibit-major-modes and emojify-inhibit-in-buffer-functions.

Major modes where emojify-mode should be not be enabled

As the names suggests emojify-inhibit-major-modes is a list of major-modes where emojify should not be enabled.

Inhibiting emojify-mode using custom functions

emojify-inhibit-in-buffer-functions is a list of functions that emojify calls before enabling emojify-mode in a buffer. If any of the functions return a non-nil value emojify-mode is not enabled in the buffer. Users can add custom functions to this list if they wish to inhibit emojify in certain buffers. The functions are called with one argument the buffer where emojify-mode is about to be enabled.

Configuring the texts that are displayed as emojis

emojify offers two variables to inhibit the display of certain emojis.

Controlling the display of emojis in programming modes

If enabled in programming modes emojify by default will display only emojis in string and comments. This behaviour can be customized using the variable emojify-prog-contexts. The variable can be set to one of the following values

  • comments - Display emojis only in comments
  • string - Display emojis only in string
  • both - Display emojis in comments as well as string
  • none - Do not display emojis in programming modes

Inhibiting display of emojis using custom functions

emojify-inhibit-functions is a list of function emojify calls before displaying certain text as emoji, if any of the functions return a non-nil value the corresponding text is not displayed as emoji. Users can add custom functions to this list, if they inhibit display of emojis in under certain conditions. The functions are called with three arguments

  • text - The text that is about to be displayed as an emoji
  • beg - The beginning point of text in the buffer
  • end - The ending point of text in the buffer

These functions are called with the buffer where emoji is being displayed selected.

Controlling behaviour when point enters an emoji

The behaviour when point enters an emoji can be customized using the variable emojify-point-entered-behaviour. It can have one of the following values

  • echo - Display the emojified text in the minibuffer
  • uncover - Temporary undisplay the emoji while point is in the emojified text

Additionally it can be set to a custom function, the function is called with four parameters

  • buffer - The buffer where the emoji is displayed
  • text - The text that is displayed as emoji
  • beg - The beginning position of the text displayed as emoji
  • end - The ending position of the text displayed as emoji

The return value of the function is ignored.

Note: The custom function will be called for once for each character in an emoji as point moves through them. Avoid manipulating the buffer in these functions

Controlling behaviour when mouse hovers over an emoji

When mouse hovers over a emoji, the underlying text is displayed in a help popup. This behaviour can be disabled by setting emojify-show-help to nil.

Known issues

  • Emojis are not properly updated after customizing emojify-display-style or emojify-prog-contexts. This would be fixed in future. For time being you will be fine as long as you set these variables before emojify has loaded.
  • There is currently no support for custom emojis/images. I plan to fix this in future.

Credits

Emoji set designed and offered free by Emoji One.

Licence

The emoji images are distributed under Creative Commons License (CC-BY-SA). The source code itself is distributed under GNU General Public License v3. See LICENSE.

About

Display emojis in Emacs

License:GNU General Public License v3.0


Languages

Language:Emacs Lisp 100.0%