Created
January 2, 2011 04:58
-
-
Save tequilasunset/762297 to your computer and use it in GitHub Desktop.
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
(require 'cl) | |
(require 'popup) | |
(defvar popup-color-string | |
(let ((x 9) (y 3)) | |
(mapconcat 'identity | |
(loop with str = (make-string x ?\ ) repeat y collect str) | |
"\n")) | |
"*String displayed in tooltip.") | |
(defun popup-color-at-point () | |
"Popup color specified by word at point." | |
(interactive) | |
(let ((word (word-at-point)) | |
(bg (plist-get (face-attr-construct 'popup-tip-face) :background))) | |
(when word | |
(unless (member (downcase word) (mapcar #'downcase (defined-colors))) | |
(setq word (concat "#" word))) | |
(set-face-background 'popup-tip-face word) | |
(message "%s: %s" | |
(propertize "Popup color" | |
'face `(:background ,word)) | |
(propertize (substring-no-properties word) | |
'face `(:foreground ,word))) | |
(popup-tip popup-color-string) | |
(set-face-background 'popup-tip-face bg)))) | |
(global-set-key (kbd "C-c c") 'popup-color-at-point) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment