curl-style.el 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. ;;;; Emacs Lisp help for writing curl code. ;;;;
  2. ;;;; $Id$
  3. ;;; The curl hacker's C conventions.
  4. ;;; See the sample.emacs file on how this file can be made to take
  5. ;;; effect automatically when editing curl source files.
  6. (defconst curl-c-style
  7. '((c-basic-offset . 2)
  8. (c-comment-only-line-offset . 0)
  9. (c-hanging-braces-alist . ((substatement-open before after)))
  10. (c-offsets-alist . ((topmost-intro . 0)
  11. (topmost-intro-cont . 0)
  12. (substatement . +)
  13. (substatement-open . 0)
  14. (statement-case-intro . +)
  15. (statement-case-open . 0)
  16. (case-label . 0)
  17. ))
  18. )
  19. "Curl C Programming Style")
  20. (defun curl-code-cleanup ()
  21. "no docs"
  22. (interactive)
  23. (untabify (point-min) (point-max))
  24. (delete-trailing-whitespace)
  25. )
  26. ;; Customizations for all of c-mode, c++-mode, and objc-mode
  27. (defun curl-c-mode-common-hook ()
  28. "Curl C mode hook"
  29. ;; add curl style and set it for the current buffer
  30. (c-add-style "curl" curl-c-style t)
  31. (setq tab-width 8
  32. indent-tabs-mode nil ; Use spaces. Not tabs.
  33. comment-column 40
  34. c-font-lock-extra-types (append '("bool" "CURL" "CURLcode" "ssize_t" "size_t" "curl_socklen_t" "fd_set" "time_t" "curl_off_t" "curl_socket_t" "in_addr_t" "CURLSHcode" "CURLMcode" "Curl_addrinfo"))
  35. )
  36. ;; keybindings for C, C++, and Objective-C. We can put these in
  37. ;; c-mode-base-map because of inheritance ...
  38. (define-key c-mode-base-map "\M-q" 'c-fill-paragraph)
  39. (define-key c-mode-base-map "\M-m" 'curl-code-cleanup)
  40. (setq c-recognize-knr-p nil)
  41. ;;; (add-hook 'write-file-hooks 'delete-trailing-whitespace t)
  42. (setq show-trailing-whitespace t)
  43. )
  44. ;; Set this is in your .emacs if you want to use the c-mode-hook as
  45. ;; defined here right out of the box.
  46. ; (add-hook 'c-mode-common-hook 'curl-c-mode-common-hook)