Created
May 26, 2012 02:34
-
-
Save emasaka/2791789 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 'hi-lock) | |
| (defun grepf->regexp (file) | |
| (with-temp-buffer | |
| (insert-file-contents file) | |
| (goto-char (point-max)) | |
| (when (looking-back "\n") | |
| (delete-char -1) ) | |
| (goto-char (point-min)) | |
| (while (search-forward "\n" nil t) | |
| (replace-match "\\|" nil t) ) | |
| (buffer-substring (point-min) (point-max)) )) | |
| (defun hi-lock-from-file (file &optional face) | |
| "Set face of each match of regexps in FILE to FACE. | |
| Interactively, prompt for FILE then FACE. | |
| FILE is grep -f style" | |
| (interactive | |
| (list | |
| (read-file-name "Pattern File:" ) | |
| (hi-lock-read-face-name))) | |
| (hi-lock-face-buffer (grepf->regexp file) face) ) | |
| (define-key hi-lock-map "\C-xwf" 'hi-lock-from-file) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment