shosei

.emacs interactive hilighting

Feb 23rd, 2012
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lisp 2.18 KB | None | 0 0
  1. (GNUEmacs
  2.     ;; "identical token highlighting" commands
  3.     (when (try-require 'highlight)
  4.  
  5.         (defface hlt-1 '((t (:background "#FFFFA0"))) nil)
  6.         (defface hlt-2 '((t (:background "#A0FFA0"))) nil)
  7.         (defface hlt-3 '((t (:background "#A0FFFF"))) nil)
  8.         (defface hlt-4 '((t (:background "#FFA0FF"))) nil)
  9.         (defface hlt-5 '((t (:background "#FFA0A0"))) nil)
  10.         (defface hlt-6 '((t (:background "#FFFFA0"))) nil)
  11.         (defface hlt-7 '((t (:background "#A0FFA0"))) nil)
  12.         (defface hlt-8 '((t (:background "#A0FFFF"))) nil)
  13.         (defface hlt-9 '((t (:background "#FFA0FF"))) nil)
  14.         (defface hlt-10 '((t (:background "#FFA0A0"))) nil)
  15.  
  16.         (global-set-key (kbd "C-S-p") 'hlt-previous-highlight)
  17.         (global-set-key (kbd "C-S-n") 'hlt-next-highlight)
  18.  
  19.         (defun hlt-highlight-current-word ()
  20.           (interactive)
  21.           (let ((var_name (current-word t)))
  22.             (when var_name
  23.               (save-excursion
  24.                 (hlt-highlight-regexp-region
  25.                  (point-min)
  26.                  (point-max)
  27.                  (regexp-quote var_name))))))
  28.  
  29.   ;; emulation of Vim's `*' search
  30.         (global-set-key (kbd "C-*") 'hlt-highlight-current-word)
  31.         ))
  32. ;; ;; bind the hi-lock commands to more finger-friendly sequences
  33. ;; (define-key hi-lock-map (kbd "C-z i") 'hi-lock-find-patterns)
  34. ;; (define-key hi-lock-map (kbd "C-z p") 'highlight-phrase)
  35. ;; (define-key hi-lock-map (kbd "C-z r") 'unhighlight-regexp)
  36.  
  37. ;; (define-key hi-lock-map (kbd "C-z h") 'highlight-regexp)
  38. ;; (define-key hi-lock-map (kbd "C-z C-h") 'highlight-lines-matching-regexp)
  39. ;; (define-key hi-lock-map (kbd "C-z b") 'hi-lock-write-interactive-patterns)
  40.  
  41. ;; ;; Highlight based on regexps
  42. ;; (global-set-key [M-f1] 'highlight-regexp)
  43. ;; (global-set-key [M-f2] 'highlight-lines-matching-regexp)
  44. ;; (global-set-key [M-f3] 'hi-lock-mode)
  45. ;; (global-set-key [M-f4] 'hi-lock-write-interactive-patterns)
  46.  
  47.  
  48. ;; ;; highlight current symbol
  49. ;; (when (try-require 'light-symbol)
  50. ;;   (light-symbol-mode))
  51.  
  52.  
  53. ;; highlight current symbol
  54. (setq highlight-symbol-idle-delay 0.5)
  55. (when (try-require 'highlight-symbol)
  56.   (highlight-symbol-mode))
Advertisement
Add Comment
Please, Sign In to add comment