Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

put pretty function code into a hook function

I don't like the unicode replacements, and it feels cleaner to remove a function from a hook than to remove a font-lock keyword.

There is probably a good deal more duplication removal that could be done here, as the setups are essentially identical.
  • Loading branch information...
commit f0c131682089fbe9c8f32cf96fa7e97a8b968278 1 parent cda0de0
@stesla authored committed
Showing with 11 additions and 13 deletions.
  1. +11 −13 starter-kit-js.el
View
24 starter-kit-js.el
@@ -23,13 +23,8 @@
'(progn (define-key espresso-mode-map "{" 'paredit-open-curly)
(define-key espresso-mode-map "}" 'paredit-close-curly-and-newline)
;; fixes problem with pretty function font-lock
- (define-key espresso-mode-map (kbd ",") 'self-insert-command)
- (font-lock-add-keywords
- 'espresso-mode `(("\\(function *\\)("
- (0 (progn (compose-region (match-beginning 1)
- (match-end 1) "ƒ")
- nil)))))))
- )
+ (define-key espresso-mode-map (kbd ",") 'self-insert-command)))
+ (add-hook 'espresso-mode-hook 'pretty-functions))
(autoload 'js-mode "js" "Start js-mode" t)
(add-to-list 'auto-mode-alist '("\\.js$" . js-mode))
@@ -43,12 +38,15 @@
'(progn (define-key js-mode-map "{" 'paredit-open-curly)
(define-key js-mode-map "}" 'paredit-close-curly-and-newline)
;; fixes problem with pretty function font-lock
- (define-key js-mode-map (kbd ",") 'self-insert-command)
- (font-lock-add-keywords
- 'js-mode `(("\\(function *\\)("
- (0 (progn (compose-region (match-beginning 1)
- (match-end 1) "ƒ")
- nil))))))))
+ (define-key js-mode-map (kbd ",") 'self-insert-command)))
+ (add-hook 'js-mode-hook 'pretty-functions))
+
+(defun pretty-functions ()
+ (font-lock-add-keywords
+ nil `(("\\(function *\\)("
+ (0 (progn (compose-region (match-beginning 1)
+ (match-end 1) "ƒ")
+ nil))))))
(provide 'starter-kit-js)
;;; starter-kit-js.el ends here
Please sign in to comment.
Something went wrong with that request. Please try again.