/font-awesome.el
https://github.com/krismolendyke/font-awesome.el · Lisp · 314 lines · 287 code · 14 blank · 13 comment · 2 complexity · 972d20157cfa4c633e8bcd74b5d84101 MD5 · raw file
- ;;; font-awesome.el --- A simple library for using FontAwesome icons.
- ;;; Commentary:
- ;;
- ;; FontAwesome is an icon font designed for use with the Twitter
- ;; Bootstrap front-end web framework but can be useful elsewhere like
- ;; a text editor, e.g., `org-mode'.
- ;;
- ;; `font-awesome' is a package which makes inserting FontAwesome icons
- ;; into Emacs easier. The OpenType font FontAwesome.otf is required
- ;; to be installed for the icons to be displayed properly. It can be
- ;; downloaded at http://fortawesome.github.io/Font-Awesome/
- ;;; Code:
- (defface font-awesome '((t :family "FontAwesome")) "The FontAwesome face.")
- (defconst font-awesome/icon-list
- '((#xf000 "glass")
- (#xf001 "music")
- (#xf002 "search")
- (#xf003 "envelope")
- (#xf004 "heart")
- (#xf005 "star")
- (#xf006 "star-empty")
- (#xf007 "user")
- (#xf008 "film")
- (#xf009 "th-large")
- (#xf00a "th")
- (#xf00b "th-list")
- (#xf00c "ok")
- (#xf00d "remove")
- (#xf00e "zoom-in")
- (#xf010 "zoom-out")
- (#xf011 "off")
- (#xf012 "signal")
- (#xf013 "cog")
- (#xf014 "trash")
- (#xf015 "home")
- (#xf016 "file")
- (#xf017 "time")
- (#xf018 "road")
- (#xf019 "download-alt")
- (#xf01a "download")
- (#xf01b "upload")
- (#xf01c "inbox")
- (#xf01d "play-circle")
- (#xf01e "repeat")
- (#xf021 "refresh")
- (#xf022 "list-alt")
- (#xf023 "lock")
- (#xf024 "flag")
- (#xf025 "headphones")
- (#xf026 "volume-off")
- (#xf027 "volume-down")
- (#xf028 "volume-up")
- (#xf029 "qrcode")
- (#xf02a "barcode")
- (#xf02b "tag")
- (#xf02c "tags")
- (#xf02d "book")
- (#xf02e "bookmark")
- (#xf02f "print")
- (#xf030 "camera")
- (#xf031 "font")
- (#xf032 "bold")
- (#xf033 "italic")
- (#xf034 "text-height")
- (#xf035 "text-width")
- (#xf036 "align-left")
- (#xf037 "align-center")
- (#xf038 "align-right")
- (#xf039 "align-justify")
- (#xf03a "list")
- (#xf03b "indent-left")
- (#xf03c "indent-right")
- (#xf03d "facetime-video")
- (#xf03e "picture")
- (#xf040 "pencil")
- (#xf041 "map-marker")
- (#xf042 "adjust")
- (#xf043 "tint")
- (#xf044 "edit")
- (#xf045 "share")
- (#xf046 "check")
- (#xf047 "move")
- (#xf048 "step-backward")
- (#xf049 "fast-backward")
- (#xf04a "backward")
- (#xf04b "play")
- (#xf04c "pause")
- (#xf04d "stop")
- (#xf04e "forward")
- (#xf050 "fast-forward")
- (#xf051 "step-forward")
- (#xf052 "eject")
- (#xf053 "chevron-left")
- (#xf054 "chevron-right")
- (#xf055 "plus-sign")
- (#xf056 "minus-sign")
- (#xf057 "remove-sign")
- (#xf058 "ok-sign")
- (#xf059 "question-sign")
- (#xf05a "info-sign")
- (#xf05b "screenshot")
- (#xf05c "remove-circle")
- (#xf05d "ok-circle")
- (#xf05e "ban-circle")
- (#xf060 "arrow-left")
- (#xf061 "arrow-right")
- (#xf062 "arrow-up")
- (#xf063 "arrow-down")
- (#xf064 "share-alt")
- (#xf065 "resize-full")
- (#xf066 "resize-small")
- (#xf067 "plus")
- (#xf068 "minus")
- (#xf069 "asterisk")
- (#xf06a "exclamation-sign")
- (#xf06b "gift")
- (#xf06c "leaf")
- (#xf06d "fire")
- (#xf06e "eye-open")
- (#xf070 "eye-close")
- (#xf071 "warning-sign")
- (#xf072 "plane")
- (#xf073 "calendar")
- (#xf074 "random")
- (#xf075 "comment")
- (#xf076 "magnet")
- (#xf077 "chevron-up")
- (#xf078 "chevron-down")
- (#xf079 "retweet")
- (#xf07a "shopping-cart")
- (#xf07b "folder-close")
- (#xf07c "folder-open")
- (#xf07d "resize-vertical")
- (#xf07e "resize-horizontal")
- (#xf080 "bar-chart")
- (#xf081 "twitter-sign")
- (#xf082 "facebook-sign")
- (#xf083 "camera-retro")
- (#xf084 "key")
- (#xf085 "cogs")
- (#xf086 "comments")
- (#xf087 "thumbs-up")
- (#xf088 "thumbs-down")
- (#xf089 "star-half")
- (#xf08a "heart-empty")
- (#xf08b "signout")
- (#xf08c "linkedin-sign")
- (#xf08d "pushpin")
- (#xf08e "external-link")
- (#xf090 "signin")
- (#xf091 "trophy")
- (#xf092 "github-sign")
- (#xf093 "upload-alt")
- (#xf094 "lemon")
- (#xf095 "phone")
- (#xf096 "check-empty")
- (#xf097 "bookmark-empty")
- (#xf098 "phone-sign")
- (#xf099 "twitter")
- (#xf09a "facebook")
- (#xf09b "github")
- (#xf09c "unlock")
- (#xf09d "credit-card")
- (#xf09e "rss")
- (#xf0a0 "hdd")
- (#xf0a1 "bullhorn")
- (#xf0a2 "bell")
- (#xf0a3 "certificate")
- (#xf0a4 "hand-right")
- (#xf0a5 "hand-left")
- (#xf0a6 "hand-up")
- (#xf0a7 "hand-down")
- (#xf0a8 "circle-arrow-left")
- (#xf0a9 "circle-arrow-right")
- (#xf0aa "circle-arrow-up")
- (#xf0ab "circle-arrow-down")
- (#xf0ac "globe")
- (#xf0ad "wrench")
- (#xf0ae "tasks")
- (#xf0b0 "filter")
- (#xf0b1 "briefcase")
- (#xf0b2 "fullscreen")
- (#xf0c0 "group")
- (#xf0c1 "link")
- (#xf0c2 "cloud")
- (#xf0c3 "beaker")
- (#xf0c4 "cut")
- (#xf0c5 "copy")
- (#xf0c6 "paper-clip")
- (#xf0c7 "save")
- (#xf0c8 "sign-blank")
- (#xf0c9 "reorder")
- (#xf0ca "list-ul")
- (#xf0cb "list-ol")
- (#xf0cc "strikethrough")
- (#xf0cd "underline")
- (#xf0ce "table")
- (#xf0d0 "magic")
- (#xf0d1 "truck")
- (#xf0d2 "pinterest")
- (#xf0d3 "pinterest-sign")
- (#xf0d4 "google-plus-sign")
- (#xf0d5 "google-plus")
- (#xf0d6 "money")
- (#xf0d7 "caret-down")
- (#xf0d8 "caret-up")
- (#xf0d9 "caret-left")
- (#xf0da "caret-right")
- (#xf0db "columns")
- (#xf0dc "sort")
- (#xf0dd "sort-down")
- (#xf0de "sort-up")
- (#xf0e0 "envelope-alt")
- (#xf0e1 "linkedin")
- (#xf0e2 "undo")
- (#xf0e3 "legal")
- (#xf0e4 "dashboard")
- (#xf0e5 "comment-alt")
- (#xf0e6 "comments-alt")
- (#xf0e7 "bolt")
- (#xf0e8 "sitemap")
- (#xf0e9 "umbrella")
- (#xf0ea "paste")
- (#xf0eb "lightbulb")
- (#xf0ec "exchange")
- (#xf0ed "cloud-download")
- (#xf0ee "cloud-upload")
- (#xf0f0 "user-md")
- (#xf0f1 "stethoscope")
- (#xf0f2 "suitcase")
- (#xf0f3 "bell-alt")
- (#xf0f4 "coffee")
- (#xf0f5 "food")
- (#xf0f6 "file-alt")
- (#xf0f7 "building")
- (#xf0f8 "hospital")
- (#xf0f9 "ambulance")
- (#xf0fa "medkit")
- (#xf0fb "fighter-jet")
- (#xf0fc "beer")
- (#xf0fd "h-sign")
- (#xf0fe "plus-sign-alt")
- (#xf100 "double-angle-left")
- (#xf101 "double-angle-right")
- (#xf102 "double-angle-up")
- (#xf103 "double-angle-down")
- (#xf104 "angle-left")
- (#xf105 "angle-right")
- (#xf106 "angle-up")
- (#xf107 "angle-down")
- (#xf108 "desktop")
- (#xf109 "laptop")
- (#xf10a "tablet")
- (#xf10b "mobile-phone")
- (#xf10c "circle-blank")
- (#xf10d "quote-left")
- (#xf10e "quote-right")
- (#xf110 "spinner")
- (#xf111 "circle")
- (#xf112 "reply"))
- "The list of available FontAwesome icons.
- This is used to create the hash table for fast icon lookups. The
- source for this list is
- http://fortawesome.github.io/Font-Awesome/design.html")
- (defconst font-awesome/icon-table
- (let ((table (make-hash-table :test 'equal)))
- (mapcar
- #'(lambda (icon-map)
- (let ((code (car icon-map))
- (name (cadr icon-map)))
- (puthash name code table)))
- font-awesome/icon-list)
- table)
- "The table of available FontAwesome icons.
- The mapping is icon name to hexadecimal icon code.")
- (defun font-awesome/get-icon (name)
- "Get the given icon as a string.
- If icon NAME cannot be found, return beer."
- (let ((icons (make-hash-table :test 'equal))
- (beer #xf0fc))
- (char-to-string
- (gethash name font-awesome/icon-table beer))))
- (defun font-awesome/propertize-icon (icon)
- "Propertize the given ICON."
- (propertize (font-awesome/get-icon icon) 'face 'font-awesome))
- (defun font-awesome/insert-icon (&optional icon)
- "Insert an ICON."
- (interactive)
- (insert (font-awesome/propertize-icon
- (or icon (completing-read "icon: " font-awesome/icon-table)))))
- (defun font-awesome/insert-all-icons ()
- "Insert all available FontAwesome icons."
- (interactive)
- (maphash
- (lambda (name icon)
- (insert
- (format "%s: %s\n" name (font-awesome/propertize-icon name))))
- font-awesome/icon-table))
- (provide 'font-awesome)
- ;;; font-awesome.el ends here