Last active
May 3, 2020 11:46
-
-
Save ShingoFukuyama/02f5032b43a447b3fbad to your computer and use it in GitHub Desktop.
Show Font Awesome icons on Emacs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; Assume you have already installed Font Awesome on the system | |
;; http://fortawesome.github.io/Font-Awesome/ | |
(require 'ov) | |
;; Overlay Library | |
;; https://github.com/ShingoFukuyama/ov.el | |
;; Example 1: Insert all fonts at the cursor position | |
(defun font-awesome-insert-all () | |
(interactive) | |
(mapc (lambda (font) | |
(insert " ") | |
(ov-set (ov-insert (car font)) 'face '(:family "FontAwesome" :height 1.5))) | |
font-awesome-list)) | |
;; (font-awesome-insert-all) | |
;; Example 2: Insert icon that has key action | |
(defun font-awesome-insert-apple () | |
(interactive) | |
(let* ((apple (rassoc "fa-apple" font-awesome-list)) | |
(char (car apple)) | |
ov) | |
(setq ov (ov-insert char)) | |
(ov-set ov 'face '(:family "FontAwesome" :foreground "#cc3300")) | |
(ov-keymap ov | |
;; Show message in minibuffer | |
"RET" '(message "Apple Selected!!!!!!") | |
;; Add a new apple | |
"a" '(font-awesome-insert-apple)))) | |
;; (font-awesome-insert-apple) | |
(setq font-awesome-list '(("\xf000" . "fa-glass") | |
("\xf001" . "fa-music") | |
("\xf002" . "fa-search") | |
("\xf003" . "fa-envelope-o") | |
("\xf004" . "fa-heart") | |
("\xf005" . "fa-star") | |
("\xf006" . "fa-star-o") | |
("\xf007" . "fa-user") | |
("\xf008" . "fa-film") | |
("\xf009" . "fa-th-large") | |
("\xf00a" . "fa-th") | |
("\xf00b" . "fa-th-list") | |
("\xf00c" . "fa-check") | |
("\xf00d" . "fa-times") | |
("\xf00e" . "fa-search-plus") | |
("\xf010" . "fa-search-minus") | |
("\xf011" . "fa-power-off") | |
("\xf012" . "fa-signal") | |
("\xf013" . "fa-cog") | |
("\xf014" . "fa-trash-o") | |
("\xf015" . "fa-home") | |
("\xf016" . "fa-file-o") | |
("\xf017" . "fa-clock-o") | |
("\xf018" . "fa-road") | |
("\xf019" . "fa-download") | |
("\xf01a" . "fa-arrow-circle-o-down") | |
("\xf01b" . "fa-arrow-circle-o-up") | |
("\xf01c" . "fa-inbox") | |
("\xf01d" . "fa-play-circle-o") | |
("\xf01e" . "fa-repeat") | |
("\xf021" . "fa-refresh") | |
("\xf022" . "fa-list-alt") | |
("\xf023" . "fa-lock") | |
("\xf024" . "fa-flag") | |
("\xf025" . "fa-headphones") | |
("\xf026" . "fa-volume-off") | |
("\xf027" . "fa-volume-down") | |
("\xf028" . "fa-volume-up") | |
("\xf029" . "fa-qrcode") | |
("\xf02a" . "fa-barcode") | |
("\xf02b" . "fa-tag") | |
("\xf02c" . "fa-tags") | |
("\xf02d" . "fa-book") | |
("\xf02e" . "fa-bookmark") | |
("\xf02f" . "fa-print") | |
("\xf030" . "fa-camera") | |
("\xf031" . "fa-font") | |
("\xf032" . "fa-bold") | |
("\xf033" . "fa-italic") | |
("\xf034" . "fa-text-height") | |
("\xf035" . "fa-text-width") | |
("\xf036" . "fa-align-left") | |
("\xf037" . "fa-align-center") | |
("\xf038" . "fa-align-right") | |
("\xf039" . "fa-align-justify") | |
("\xf03a" . "fa-list") | |
("\xf03b" . "fa-outdent") | |
("\xf03c" . "fa-indent") | |
("\xf03d" . "fa-video-camera") | |
("\xf03e" . "fa-picture-o") | |
("\xf040" . "fa-pencil") | |
("\xf041" . "fa-map-marker") | |
("\xf042" . "fa-adjust") | |
("\xf043" . "fa-tint") | |
("\xf044" . "fa-pencil-square-o") | |
("\xf045" . "fa-share-square-o") | |
("\xf046" . "fa-check-square-o") | |
("\xf047" . "fa-arrows") | |
("\xf048" . "fa-step-backward") | |
("\xf049" . "fa-fast-backward") | |
("\xf04a" . "fa-backward") | |
("\xf04b" . "fa-play") | |
("\xf04c" . "fa-pause") | |
("\xf04d" . "fa-stop") | |
("\xf04e" . "fa-forward") | |
("\xf050" . "fa-fast-forward") | |
("\xf051" . "fa-step-forward") | |
("\xf052" . "fa-eject") | |
("\xf053" . "fa-chevron-left") | |
("\xf054" . "fa-chevron-right") | |
("\xf055" . "fa-plus-circle") | |
("\xf056" . "fa-minus-circle") | |
("\xf057" . "fa-times-circle") | |
("\xf058" . "fa-check-circle") | |
("\xf059" . "fa-question-circle") | |
("\xf05a" . "fa-info-circle") | |
("\xf05b" . "fa-crosshairs") | |
("\xf05c" . "fa-times-circle-o") | |
("\xf05d" . "fa-check-circle-o") | |
("\xf05e" . "fa-ban") | |
("\xf060" . "fa-arrow-left") | |
("\xf061" . "fa-arrow-right") | |
("\xf062" . "fa-arrow-up") | |
("\xf063" . "fa-arrow-down") | |
("\xf064" . "fa-share") | |
("\xf065" . "fa-expand") | |
("\xf066" . "fa-compress") | |
("\xf067" . "fa-plus") | |
("\xf068" . "fa-minus") | |
("\xf069" . "fa-asterisk") | |
("\xf06a" . "fa-exclamation-circle") | |
("\xf06b" . "fa-gift") | |
("\xf06c" . "fa-leaf") | |
("\xf06d" . "fa-fire") | |
("\xf06e" . "fa-eye") | |
("\xf070" . "fa-eye-slash") | |
("\xf071" . "fa-exclamation-triangle") | |
("\xf072" . "fa-plane") | |
("\xf073" . "fa-calendar") | |
("\xf074" . "fa-random") | |
("\xf075" . "fa-comment") | |
("\xf076" . "fa-magnet") | |
("\xf077" . "fa-chevron-up") | |
("\xf078" . "fa-chevron-down") | |
("\xf079" . "fa-retweet") | |
("\xf07a" . "fa-shopping-cart") | |
("\xf07b" . "fa-folder") | |
("\xf07c" . "fa-folder-open") | |
("\xf07d" . "fa-arrows-v") | |
("\xf07e" . "fa-arrows-h") | |
("\xf080" . "fa-bar-chart-o") | |
("\xf081" . "fa-twitter-square") | |
("\xf082" . "fa-facebook-square") | |
("\xf083" . "fa-camera-retro") | |
("\xf084" . "fa-key") | |
("\xf085" . "fa-cogs") | |
("\xf086" . "fa-comments") | |
("\xf087" . "fa-thumbs-o-up") | |
("\xf088" . "fa-thumbs-o-down") | |
("\xf089" . "fa-star-half") | |
("\xf08a" . "fa-heart-o") | |
("\xf08b" . "fa-sign-out") | |
("\xf08c" . "fa-linkedin-square") | |
("\xf08d" . "fa-thumb-tack") | |
("\xf08e" . "fa-external-link") | |
("\xf090" . "fa-sign-in") | |
("\xf091" . "fa-trophy") | |
("\xf092" . "fa-github-square") | |
("\xf093" . "fa-upload") | |
("\xf094" . "fa-lemon-o") | |
("\xf095" . "fa-phone") | |
("\xf096" . "fa-square-o") | |
("\xf097" . "fa-bookmark-o") | |
("\xf098" . "fa-phone-square") | |
("\xf099" . "fa-twitter") | |
("\xf09a" . "fa-facebook") | |
("\xf09b" . "fa-github") | |
("\xf09c" . "fa-unlock") | |
("\xf09d" . "fa-credit-card") | |
("\xf09e" . "fa-rss") | |
("\xf0a0" . "fa-hdd-o") | |
("\xf0a1" . "fa-bullhorn") | |
("\xf0f3" . "fa-bell") | |
("\xf0a3" . "fa-certificate") | |
("\xf0a4" . "fa-hand-o-right") | |
("\xf0a5" . "fa-hand-o-left") | |
("\xf0a6" . "fa-hand-o-up") | |
("\xf0a7" . "fa-hand-o-down") | |
("\xf0a8" . "fa-arrow-circle-left") | |
("\xf0a9" . "fa-arrow-circle-right") | |
("\xf0aa" . "fa-arrow-circle-up") | |
("\xf0ab" . "fa-arrow-circle-down") | |
("\xf0ac" . "fa-globe") | |
("\xf0ad" . "fa-wrench") | |
("\xf0ae" . "fa-tasks") | |
("\xf0b0" . "fa-filter") | |
("\xf0b1" . "fa-briefcase") | |
("\xf0b2" . "fa-arrows-alt") | |
("\xf0c0" . "fa-users") | |
("\xf0c1" . "fa-link") | |
("\xf0c2" . "fa-cloud") | |
("\xf0c3" . "fa-flask") | |
("\xf0c4" . "fa-scissors") | |
("\xf0c5" . "fa-files-o") | |
("\xf0c6" . "fa-paperclip") | |
("\xf0c7" . "fa-floppy-o") | |
("\xf0c8" . "fa-square") | |
("\xf0c9" . "fa-bars") | |
("\xf0ca" . "fa-list-ul") | |
("\xf0cb" . "fa-list-ol") | |
("\xf0cc" . "fa-strikethrough") | |
("\xf0cd" . "fa-underline") | |
("\xf0ce" . "fa-table") | |
("\xf0d0" . "fa-magic") | |
("\xf0d1" . "fa-truck") | |
("\xf0d2" . "fa-pinterest") | |
("\xf0d3" . "fa-pinterest-square") | |
("\xf0d4" . "fa-google-plus-square") | |
("\xf0d5" . "fa-google-plus") | |
("\xf0d6" . "fa-money") | |
("\xf0d7" . "fa-caret-down") | |
("\xf0d8" . "fa-caret-up") | |
("\xf0d9" . "fa-caret-left") | |
("\xf0da" . "fa-caret-right") | |
("\xf0db" . "fa-columns") | |
("\xf0dc" . "fa-sort") | |
("\xf0dd" . "fa-sort-asc") | |
("\xf0de" . "fa-sort-desc") | |
("\xf0e0" . "fa-envelope") | |
("\xf0e1" . "fa-linkedin") | |
("\xf0e2" . "fa-undo") | |
("\xf0e3" . "fa-gavel") | |
("\xf0e4" . "fa-tachometer") | |
("\xf0e5" . "fa-comment-o") | |
("\xf0e6" . "fa-comments-o") | |
("\xf0e7" . "fa-bolt") | |
("\xf0e8" . "fa-sitemap") | |
("\xf0e9" . "fa-umbrella") | |
("\xf0ea" . "fa-clipboard") | |
("\xf0eb" . "fa-lightbulb-o") | |
("\xf0ec" . "fa-exchange") | |
("\xf0ed" . "fa-cloud-download") | |
("\xf0ee" . "fa-cloud-upload") | |
("\xf0f0" . "fa-user-md") | |
("\xf0f1" . "fa-stethoscope") | |
("\xf0f2" . "fa-suitcase") | |
("\xf0a2" . "fa-bell-o") | |
("\xf0f4" . "fa-coffee") | |
("\xf0f5" . "fa-cutlery") | |
("\xf0f6" . "fa-file-text-o") | |
("\xf0f7" . "fa-building-o") | |
("\xf0f8" . "fa-hospital-o") | |
("\xf0f9" . "fa-ambulance") | |
("\xf0fa" . "fa-medkit") | |
("\xf0fb" . "fa-fighter-jet") | |
("\xf0fc" . "fa-beer") | |
("\xf0fd" . "fa-h-square") | |
("\xf0fe" . "fa-plus-square") | |
("\xf100" . "fa-angle-double-left") | |
("\xf101" . "fa-angle-double-right") | |
("\xf102" . "fa-angle-double-up") | |
("\xf103" . "fa-angle-double-down") | |
("\xf104" . "fa-angle-left") | |
("\xf105" . "fa-angle-right") | |
("\xf106" . "fa-angle-up") | |
("\xf107" . "fa-angle-down") | |
("\xf108" . "fa-desktop") | |
("\xf109" . "fa-laptop") | |
("\xf10a" . "fa-tablet") | |
("\xf10b" . "fa-mobile") | |
("\xf10c" . "fa-circle-o") | |
("\xf10d" . "fa-quote-left") | |
("\xf10e" . "fa-quote-right") | |
("\xf110" . "fa-spinner") | |
("\xf111" . "fa-circle") | |
("\xf112" . "fa-reply") | |
("\xf113" . "fa-github-alt") | |
("\xf114" . "fa-folder-o") | |
("\xf115" . "fa-folder-open-o") | |
("\xf118" . "fa-smile-o") | |
("\xf119" . "fa-frown-o") | |
("\xf11a" . "fa-meh-o") | |
("\xf11b" . "fa-gamepad") | |
("\xf11c" . "fa-keyboard-o") | |
("\xf11d" . "fa-flag-o") | |
("\xf11e" . "fa-flag-checkered") | |
("\xf120" . "fa-terminal") | |
("\xf121" . "fa-code") | |
("\xf122" . "fa-reply-all") | |
("\xf122" . "fa-mail-reply-all") | |
("\xf123" . "fa-star-half-o") | |
("\xf124" . "fa-location-arrow") | |
("\xf125" . "fa-crop") | |
("\xf126" . "fa-code-fork") | |
("\xf127" . "fa-chain-broken") | |
("\xf128" . "fa-question") | |
("\xf129" . "fa-info") | |
("\xf12a" . "fa-exclamation") | |
("\xf12b" . "fa-superscript") | |
("\xf12c" . "fa-subscript") | |
("\xf12d" . "fa-eraser") | |
("\xf12e" . "fa-puzzle-piece") | |
("\xf130" . "fa-microphone") | |
("\xf131" . "fa-microphone-slash") | |
("\xf132" . "fa-shield") | |
("\xf133" . "fa-calendar-o") | |
("\xf134" . "fa-fire-extinguisher") | |
("\xf135" . "fa-rocket") | |
("\xf136" . "fa-maxcdn") | |
("\xf137" . "fa-chevron-circle-left") | |
("\xf138" . "fa-chevron-circle-right") | |
("\xf139" . "fa-chevron-circle-up") | |
("\xf13a" . "fa-chevron-circle-down") | |
("\xf13b" . "fa-html5") | |
("\xf13c" . "fa-css3") | |
("\xf13d" . "fa-anchor") | |
("\xf13e" . "fa-unlock-alt") | |
("\xf140" . "fa-bullseye") | |
("\xf141" . "fa-ellipsis-h") | |
("\xf142" . "fa-ellipsis-v") | |
("\xf143" . "fa-rss-square") | |
("\xf144" . "fa-play-circle") | |
("\xf145" . "fa-ticket") | |
("\xf146" . "fa-minus-square") | |
("\xf147" . "fa-minus-square-o") | |
("\xf148" . "fa-level-up") | |
("\xf149" . "fa-level-down") | |
("\xf14a" . "fa-check-square") | |
("\xf14b" . "fa-pencil-square") | |
("\xf14c" . "fa-external-link-square") | |
("\xf14d" . "fa-share-square") | |
("\xf14e" . "fa-compass") | |
("\xf150" . "fa-caret-square-o-down") | |
("\xf151" . "fa-caret-square-o-up") | |
("\xf152" . "fa-caret-square-o-right") | |
("\xf153" . "fa-eur") | |
("\xf154" . "fa-gbp") | |
("\xf155" . "fa-usd") | |
("\xf156" . "fa-inr") | |
("\xf157" . "fa-jpy") | |
("\xf158" . "fa-rub") | |
("\xf159" . "fa-krw") | |
("\xf15a" . "fa-btc") | |
("\xf15b" . "fa-file") | |
("\xf15c" . "fa-file-text") | |
("\xf15d" . "fa-sort-alpha-asc") | |
("\xf15e" . "fa-sort-alpha-desc") | |
("\xf160" . "fa-sort-amount-asc") | |
("\xf161" . "fa-sort-amount-desc") | |
("\xf162" . "fa-sort-numeric-asc") | |
("\xf163" . "fa-sort-numeric-desc") | |
("\xf164" . "fa-thumbs-up") | |
("\xf165" . "fa-thumbs-down") | |
("\xf166" . "fa-youtube-square") | |
("\xf167" . "fa-youtube") | |
("\xf168" . "fa-xing") | |
("\xf169" . "fa-xing-square") | |
("\xf16a" . "fa-youtube-play") | |
("\xf16b" . "fa-dropbox") | |
("\xf16c" . "fa-stack-overflow") | |
("\xf16d" . "fa-instagram") | |
("\xf16e" . "fa-flickr") | |
("\xf170" . "fa-adn") | |
("\xf171" . "fa-bitbucket") | |
("\xf172" . "fa-bitbucket-square") | |
("\xf173" . "fa-tumblr") | |
("\xf174" . "fa-tumblr-square") | |
("\xf175" . "fa-long-arrow-down") | |
("\xf176" . "fa-long-arrow-up") | |
("\xf177" . "fa-long-arrow-left") | |
("\xf178" . "fa-long-arrow-right") | |
("\xf179" . "fa-apple") | |
("\xf17a" . "fa-windows") | |
("\xf17b" . "fa-android") | |
("\xf17c" . "fa-linux") | |
("\xf17d" . "fa-dribbble") | |
("\xf17e" . "fa-skype") | |
("\xf180" . "fa-foursquare") | |
("\xf181" . "fa-trello") | |
("\xf182" . "fa-female") | |
("\xf183" . "fa-male") | |
("\xf184" . "fa-gittip") | |
("\xf185" . "fa-sun-o") | |
("\xf186" . "fa-moon-o") | |
("\xf187" . "fa-archive") | |
("\xf188" . "fa-bug") | |
("\xf189" . "fa-vk") | |
("\xf18a" . "fa-weibo") | |
("\xf18b" . "fa-renren") | |
("\xf18c" . "fa-pagelines") | |
("\xf18d" . "fa-stack-exchange") | |
("\xf18e" . "fa-arrow-circle-o-right") | |
("\xf190" . "fa-arrow-circle-o-left") | |
("\xf191" . "fa-caret-square-o-left") | |
("\xf192" . "fa-dot-circle-o") | |
("\xf193" . "fa-wheelchair") | |
("\xf194" . "fa-vimeo-square") | |
("\xf195" . "fa-try") | |
("\xf196" . "fa-plus-square-o") | |
)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you for this one !