2
0

sample.emacs 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. ;; This file was contributed by Mats Lidell
  2. ;; Here's a sample .emacs file that might help you along the way.
  3. ;; First comes a setup that is ideal when you are only working with curl. Just
  4. ;; select the next few lines, paste it into your .emacs and change the path to
  5. ;; the tools folder. (If you are using more than one style. Look further down
  6. ;; this file.)
  7. (load-file "<YOUR-PATH-TO-CURL>/curl-style.el")
  8. (add-hook 'c-mode-common-hook 'curl-c-mode-common-hook)
  9. ;; If you are using more than one style in maybe more than one project the
  10. ;; example below might help out. It uses a predicate hook pair to select the
  11. ;; right hook to use.
  12. (defvar my-style-selective-mode-hook nil
  13. "Holds a list of predicate and hooks pairs. (list (PREDICATE . HOOK)
  14. ...) It is used by my-mode-selective-mood-hook-function for choosing
  15. the right hook to run.")
  16. (defun my-style-selective-mode-hook-function ()
  17. "Run each PREDICATE in `my-style-selective-mode-hook' to see if the
  18. HOOK in the pair should be executed. If the PREDICATE evaluate to non
  19. nil HOOK is executed and the rest of the hooks are ignored."
  20. (let ((h my-style-selective-mode-hook))
  21. (while (not (eval (caar h)))
  22. (setq h (cdr h)))
  23. (funcall (cdar h))))
  24. ;;; Example configuration.
  25. ;; Add the selective hook to the c-mode-common-hook
  26. (add-hook 'c-mode-common-hook 'my-style-selective-mode-hook-function)
  27. ;; Add your own hooks and predicates. The predicate should evaluate to
  28. ;; non nil if the hook in the pair is supposed to be evaluated. In the
  29. ;; example a part of the path is used to select what style to
  30. ;; use. Choose what is appropriate for you.
  31. (add-hook 'my-style-selective-mode-hook
  32. '((string-match "curl" (buffer-file-name)) . curl-c-mode-common-hook))
  33. (add-hook 'my-style-selective-mode-hook
  34. '((string-match "other" (buffer-file-name)) . other-c-mode-common-hook))
  35. ;; Make sure the default style is appended.
  36. (add-hook 'my-style-selective-mode-hook '(t . my-c-mode-common-hook) t)