Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Every time I learn something about Emacs or incorporate someone's nifty elisp code, it pays off and keeps paying.

Latest:

  ; CSS color values colored by themselves
  ; http://xahlee.org/emacs/emacs_html.html
  
  (defvar hexcolour-keywords
    '(("#[abcdef[:digit:]]\\{6\\}"
       (0 (put-text-property
           (match-beginning 0)
           (match-end 0)
           'face (list :background 
                       (match-string-no-properties 0)))))))
  
  (defun hexcolour-add-to-font-lock ()
    (font-lock-add-keywords nil hexcolour-keywords))
  
  (add-hook 'css-mode-hook 'hexcolour-add-to-font-lock)


Until you pick one that has the background colour by accident!

Be weird to see that floating semicolon in there.


The #rrggbb text is still displayed with normal text color. So it will never look like a floating semicolon. Try it. It is not even a problem when #rrggbb color is same as the foreground, as I have (global-hl-line-mode 1)


Clever idea! Now I want to hear about some of your other favorites.


Thank you. [re:Favorites] The best I can do for now: http://github.com/ki/my-dot-emacs/blob/master/dot-emacs.txt


.txt?


Just a name :) It is ~/.emacs in my machine.

http://github.com/ki/my-dot-emacs/raw/master/dot-emacs.txt


You might prefer to manage your dotfiles with something like:

http://github.com/jrockway/dotfiles/tree/master/bin


Cool. Thanks!




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: