emacs-emojify

fork of https://github.com/iqbalansari/emacs-emojify
Log | Files | Refs | LICENSE

commit 62609316f269bed9e6775f9614783789a79268e7
parent 4eccfc7ce43d4dfd3cf65ea86b2975abb4b4e9ad
Author: Iqbal Ansari <iqbalansari02@yahoo.com>
Date:   Thu, 24 Nov 2016 23:10:32 +0530

Merge branch 'develop'

Diffstat:
ACHANGELOG.org | 55+++++++++++++++++++++++++++++++++++++++++++++++++++++++
MREADME.org | 7++++++-
Memojify.el | 87+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------
3 files changed, 135 insertions(+), 14 deletions(-)

diff --git a/CHANGELOG.org b/CHANGELOG.org @@ -0,0 +1,55 @@ +* Change Log + All notable changes to this project will be documented in this file. + The format is based on [[http://keepachangelog.com/][Keep a Changelog]]. + +** Unreleased + See [[https://github.com/iqbalansari/emacs-emojify/compare/v0.4...HEAD][Changes]] + +*** Fixed + - Do not try emojifying areas larger than 5000 points + - Fix display of emojis containing the plus sign (eg. ~:+1:~) + - Fix backspace to delete complete emojis in ~org-mode~ +*** Added + - New command ~emojify-describe-emoji-at-point~ can be used to view help about emoji displayed at point. + +** v0.4 - 2016-09-28 + See [[https://github.com/iqbalansari/emacs-emojify/compare/v0.3...v0.4][Changes]] + +*** Removed + - The customizable variable ~emojify-image-dir~ has been removed since it did not interact well with emojify-emojis-dir. +*** Fixed + - Emojify mode is disabled in ~magit-diff-mode~, ~ibuffer-mode~ and ~debugger-mode~. + - Emojify now does not rely on deprecated ~point-entered~ and ~point-left~ text properties for implementing uncovering logic, this makes emojify compatible with Emacs 25.1 + - Emojify mode is disabled when buffer switches to unibyte encoding +*** Changed + - Emoji images are now downloaded lazily instead of being packaged with code, this also makes it possible to use emoji sets other than EmojiOne. + - The behaviour when point enters an emoji in ~isearch-mode~ is now customizable, earlier the emoji was revealed by default. See ~emojify-reveal-on-isearch~. + - Images from EmojiOne v2.2.6 are used by default +*** Added + - ~unicode~ emojis appearing in source code are rendered by default. + - New command ~emojify-apropos-emoji~ can be used to search emojis matching given regex. + - New command ~emojify-insert-emoji~ can be used to insert emojis with completion. + - Users can now define custom emojis using ~emojify-user-emojis~ + - Emojify can now display composed text as emojis, this enables rendering of symbols used by ~prettify-symbols-mode~ or ~org-bullets-mode~ as emojis. See ~emojify-composed-text-p~ + +** v0.3 - 2015-12-21 + See [[https://github.com/iqbalansari/emacs-emojify/compare/v0.2...v0.3][Changes]] + +*** Fixed + - Multiple non-ascii emojis in sequence are displayed properly. + - Treat tuareg-mode as programming mode. +*** Added + - Deletion commands remove complete emoji instead of removing a single character. + - Emoji backgrounds are calculated based on the face at point. + +** v0.2 - 2015-09-15 + See [[https://github.com/iqbalansari/emacs-emojify/compare/v0.1...v0.2][Changes]] + +*** Removed + - The variable ~emojify-emoji-style~ has been replaced with ~emojify-emoji-styles~ + +*** Added + - The package can now display unicode emojis as well + +** v0.1 - 2015-09-14 + Initial public release diff --git a/README.org b/README.org @@ -1,6 +1,6 @@ * Emojify -[[https://melpa.org/#/emojify][file:https://melpa.org/packages/emojify-badge.svg]] [[http://stable.melpa.org/#/emojify][file:http://stable.melpa.org/packages/emojify-badge.svg]] [[https://travis-ci.org/iqbalansari/emacs-emojify][https://travis-ci.org/iqbalansari/emacs-emojify.svg?branch=master]] [[https://coveralls.io/github/iqbalansari/emacs-emojify?branch=master][https://coveralls.io/repos/github/iqbalansari/emacs-emojify/badge.svg?branch=master]] [[http://www.gnu.org/licenses/gpl-3.0.html][http://img.shields.io/:license-gpl3-blue.svg]] [[http://makeapullrequest.com][file:https://img.shields.io/badge/PRs-welcome-brightgreen.svg]] +[[./CHANGELOG.org][file:https://img.shields.io/badge/version-v0.4-blue.svg]] [[https://melpa.org/#/emojify][file:https://melpa.org/packages/emojify-badge.svg]] [[http://stable.melpa.org/#/emojify][file:http://stable.melpa.org/packages/emojify-badge.svg]] [[https://travis-ci.org/iqbalansari/emacs-emojify][https://travis-ci.org/iqbalansari/emacs-emojify.svg?branch=master]] [[https://coveralls.io/github/iqbalansari/emacs-emojify?branch=master][https://coveralls.io/repos/github/iqbalansari/emacs-emojify/badge.svg?branch=master]] [[http://www.gnu.org/licenses/gpl-3.0.html][http://img.shields.io/:license-gpl3-blue.svg]] [[http://makeapullrequest.com][file:https://img.shields.io/badge/PRs-welcome-brightgreen.svg]] ** Table of contents :TOC_3_gh: - [[#emojify][Emojify]] @@ -13,6 +13,7 @@ - [[#displaying-emojis][Displaying emojis]] - [[#searching-emojis][Searching emojis]] - [[#inserting-emojis][Inserting emojis]] + - [[#describing-emojis][Describing emojis]] - [[#customizations][Customizations]] - [[#displaying-composed-text-as-emojis][Displaying composed text as emojis]] - [[#configuring-the-types-of-emojis-displayed][Configuring the types of emojis displayed]] @@ -109,6 +110,10 @@ emoji data but old set of images. Download the latest emoji image using ~emojify-download-emoji~ and set ~emojify-emoji-set~ to the downloaded set. +*** Describing emojis + The command ~emojify-describe-emoji-at-point~ can be used to view + explanation about the command displayed at point. + ** Customizations *** Displaying composed text as emojis Emacs provides a way to modify how certain text is displayed using the diff --git a/emojify.el b/emojify.el @@ -72,6 +72,12 @@ ;; Compatibility functions +(defun emojify-user-error (format &rest args) + "Signal a pilot error, making a message by passing FORMAT and ARGS to ‘format-message’." + (if (fboundp 'user-error) + (apply #'user-error format args) + (apply #'error format args))) + (defun emojify-default-font-height () "Return the height in pixels of the current buffer's default face font. @@ -710,7 +716,7 @@ and then `emojify-emojis'." ;; Construct emojify-regexps such that github style are searched first ;; followed by unicode and then ascii emojis. - (setq emojify-regexps (list ":[[:alnum:]_-]+:" + (setq emojify-regexps (list ":[[:alnum:]+_-]+:" (regexp-opt unicode-emojis) (regexp-opt ascii-emojis)))) @@ -730,6 +736,7 @@ and then `emojify-emojis'." (define-key map [remap delete-char] #'emojify-delete-emoji-forward) (define-key map [remap delete-forward-char] #'emojify-delete-emoji-forward) (define-key map [remap backward-delete-char] #'emojify-delete-emoji-backward) + (define-key map [remap org-delete-backward-char] #'emojify-delete-emoji-backward) (define-key map [remap delete-backward-char] #'emojify-delete-emoji-backward) (define-key map [remap backward-delete-char-untabify] #'emojify-delete-emoji-backward) map)) @@ -961,6 +968,8 @@ should not be a problem 🤞." (buffer (current-buffer)) (emoji (emojify-get-emoji match))) (when (and emoji + (not (or (get-text-property match-beginning 'emojify-inhibit) + (get-text-property match-end 'emojify-inhibit))) (memql (intern (ht-get emoji "style")) emojify-emoji-styles) ;; Skip displaying this emoji if the its bounds are @@ -1084,10 +1093,10 @@ Redisplay emojis in the visible region if BEG and END are not specified" (end (save-excursion (goto-char (or end (cdr area))) (line-end-position)))) - - (emojify-execute-ignoring-errors-unless-debug - (emojify-undisplay-emojis-in-region beg end) - (emojify-display-emojis-in-region beg end)))) + (unless (> (- end beg) 5000) + (emojify-execute-ignoring-errors-unless-debug + (emojify-undisplay-emojis-in-region beg end) + (emojify-display-emojis-in-region beg end))))) (defun emojify-after-change-extend-region-function (beg end _len) "Extend the region to be emojified. @@ -1365,7 +1374,7 @@ buffer changes back to multibyte encoding." -;; Searching and inserting emojis +;; Searching emojis (defvar emojify-apropos-buffer-name "*Apropos Emojis*") @@ -1382,7 +1391,7 @@ buffer changes back to multibyte encoding." (save-excursion (goto-char (line-beginning-position)) (if (not (get-text-property (point) 'emojified)) - (user-error "No emoji at point") + (emojify-user-error "No emoji at point") (kill-new (get-text-property (point) 'emojify-text)) (message "Copied emoji to kill ring!")))) @@ -1429,9 +1438,7 @@ Borrowed from apropos.el" emojify--apropos-last-query))) (if (string-equal (regexp-quote pattern) pattern) (or (split-string pattern "[ \t]+" t) - (if (fboundp 'user-error) - (apply #'user-error "No word list given") - (apply #'error "No word list given"))) + (emojify-user-error "No word list given")) pattern))) ;;;###autoload @@ -1490,9 +1497,13 @@ Borrowed from apropos.el" (setq emojify--apropos-last-query (concat query " ")) (setq-local line-spacing 7))) - (select-window (display-buffer (get-buffer emojify-apropos-buffer-name) - (when in-apropos-buffer-p - (cons #'display-buffer-same-window nil)))))) + (pop-to-buffer (get-buffer emojify-apropos-buffer-name) + (when in-apropos-buffer-p + (cons #'display-buffer-same-window nil))))) + + + +;; Inserting emojis (defun emojify--insert-minibuffer-setup-hook () "Enables `emojify-mode' in minbuffer while inserting emojis. @@ -1540,6 +1551,56 @@ This respects the `emojify-emoji-styles' variable." +;; Help for emoji at point + +(defvar emojify-help-buffer-name "*Emoji Help*") + +(defun emojify-describe-emoji-at-point () + "Display help for EMOJI displayed at point." + (interactive) + (if (not (get-text-property (point) 'emojified)) + (emojify-user-error "No emoji at point!") + (let* ((emoji-text (get-text-property (point) 'emojify-text)) + (emoji (emojify-get-emoji emoji-text))) + (with-current-buffer (get-buffer-create emojify-help-buffer-name) + (let ((inhibit-read-only t)) + (erase-buffer) + (save-excursion + (insert (propertize emoji-text 'emojify-inhibit t) + " - Displayed as " + emoji-text + "\n\n") + (insert (propertize "Name" 'face 'font-lock-keyword-face) + ": " + (ht-get emoji "name") "\n") + (insert (propertize "Style" 'face 'font-lock-keyword-face) + ": " + (ht-get emoji "style") "\n") + (insert (propertize "Image used" 'face 'font-lock-keyword-face) + ": " + (expand-file-name (ht-get emoji "image") + (emojify-image-dir)) + "\n") + (when (and (not (string= (ht-get emoji "style") "unicode")) + (ht-get emoji "unicode")) + (insert (propertize "Unicode representation" + 'face 'font-lock-keyword-face) + ": " + (propertize (ht-get emoji "unicode") 'emojify-inhibit t) + "\n")) + (when (and (not (string= (ht-get emoji "style") "ascii")) + (ht-get emoji "ascii")) + (insert (propertize "Ascii representation" + 'face 'font-lock-keyword-face) + ": " + (propertize (ht-get emoji "ascii") 'emojify-inhibit t) + "\n")))) + (emojify-redisplay-emojis-in-region) + (view-mode +1)) + (display-buffer (get-buffer emojify-help-buffer-name))))) + + + ;; Integration with some miscellaneous functionality (defadvice mouse--drag-set-mark-and-point (after emojify-update-emoji-background (&rest ignored))