2
0

curl-style.el 1.8 KB

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