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