From 57e61e37436cfea0af7fc545686379cbfa0eb66a Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 23 Jan 2003 06:00:02 +0000 Subject: This is the new Emacs style for curl hacking, based on work written by Mats Lidell in project Rockbox. --- curl-style.el | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 curl-style.el (limited to 'curl-style.el') diff --git a/curl-style.el b/curl-style.el new file mode 100644 index 000000000..b681a48c8 --- /dev/null +++ b/curl-style.el @@ -0,0 +1,54 @@ +;;;; Emacs Lisp help for writing curl code. ;;;; +;;;; $Id$ + +;;; The curl hacker's C conventions. + +;;; After loading this file and added the mode-hook you can in C +;;; files, put something like this to use the curl style +;;; automatically: +;; +;; /* ----------------------------------------------------------------- +;; * local variables: +;; * eval: (set c-file-style "curl") +;; * end: +;; */ +;; + +(defconst curl-c-style + '((c-basic-offset . 2) + (c-comment-only-line-offset . 0) + (c-hanging-braces-alist . ((substatement-open before after))) + (c-offsets-alist . ((topmost-intro . 0) + (topmost-intro-cont . 0) + (substatement . +) + (substatement-open . 0) + (statement-case-intro . +) + (statement-case-open . 0) + (case-label . 0) + )) + ) + "Curl C Programming Style") + +;; Customizations for all of c-mode, c++-mode, and objc-mode +(defun curl-c-mode-common-hook () + "Curl C mode hook" + ;; add curl style and set it for the current buffer + (c-add-style "curl" curl-c-style t) + (setq tab-width 8 + indent-tabs-mode nil ; Use spaces. Not tabs. + comment-column 40 + c-font-lock-extra-types (append '("bool")) + ) + ;; We like auto-newline and hungry-delete + (c-toggle-auto-hungry-state 1) + ;; keybindings for C, C++, and Objective-C. We can put these in + ;; c-mode-base-map because of inheritance ... + (define-key c-mode-base-map "\M-q" 'c-fill-paragraph) + ;; Cleanups + (setq c-cleanup-list '(list-close-comma defun-close-semi empty-defun-braces brace-else-brace brace-elseif-brace scope-operator)) + (setq c-recognize-knr-p nil) + ) + +;; Set this is in your .emacs if you want to use the c-mode-hook as +;; defined here right out of the box. +; (add-hook 'c-mode-common-hook 'curl-c-mode-common-hook) -- cgit v1.2.1 From ca52549557862c46ff69e5cee1c7b131737231bc Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 28 Jan 2003 08:03:13 +0000 Subject: revised and better --- curl-style.el | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'curl-style.el') diff --git a/curl-style.el b/curl-style.el index b681a48c8..db47dd2d8 100644 --- a/curl-style.el +++ b/curl-style.el @@ -37,15 +37,11 @@ (setq tab-width 8 indent-tabs-mode nil ; Use spaces. Not tabs. comment-column 40 - c-font-lock-extra-types (append '("bool")) + c-font-lock-extra-types (append '("bool" "CURL" "CURLcode" "ssize_t")) ) - ;; We like auto-newline and hungry-delete - (c-toggle-auto-hungry-state 1) ;; keybindings for C, C++, and Objective-C. We can put these in ;; c-mode-base-map because of inheritance ... (define-key c-mode-base-map "\M-q" 'c-fill-paragraph) - ;; Cleanups - (setq c-cleanup-list '(list-close-comma defun-close-semi empty-defun-braces brace-else-brace brace-elseif-brace scope-operator)) (setq c-recognize-knr-p nil) ) -- cgit v1.2.1 From 073448e0ea3d4ba4409be45ea5ebc58860bd9995 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 12 Mar 2003 08:11:24 +0000 Subject: support a few more common typedefs --- curl-style.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'curl-style.el') diff --git a/curl-style.el b/curl-style.el index db47dd2d8..247cc9daa 100644 --- a/curl-style.el +++ b/curl-style.el @@ -37,7 +37,7 @@ (setq tab-width 8 indent-tabs-mode nil ; Use spaces. Not tabs. comment-column 40 - c-font-lock-extra-types (append '("bool" "CURL" "CURLcode" "ssize_t")) + c-font-lock-extra-types (append '("bool" "CURL" "CURLcode" "ssize_t" "size_t" "socklen_t" "fd_set")) ) ;; keybindings for C, C++, and Objective-C. We can put these in ;; c-mode-base-map because of inheritance ... -- cgit v1.2.1 From d4df981463d93bc2df1e77806b4b3781e024b8f6 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 26 Jun 2003 06:19:37 +0000 Subject: Added time_t --- curl-style.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'curl-style.el') diff --git a/curl-style.el b/curl-style.el index 247cc9daa..a5a65923b 100644 --- a/curl-style.el +++ b/curl-style.el @@ -37,7 +37,7 @@ (setq tab-width 8 indent-tabs-mode nil ; Use spaces. Not tabs. comment-column 40 - c-font-lock-extra-types (append '("bool" "CURL" "CURLcode" "ssize_t" "size_t" "socklen_t" "fd_set")) + c-font-lock-extra-types (append '("bool" "CURL" "CURLcode" "ssize_t" "size_t" "socklen_t" "fd_set" "time_t")) ) ;; keybindings for C, C++, and Objective-C. We can put these in ;; c-mode-base-map because of inheritance ... -- cgit v1.2.1 From 979ba8a8b525950f0c1a830c37d8d996790f2aba Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 16 Dec 2003 09:53:39 +0000 Subject: add off_t as a recognized type for font-locking --- curl-style.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'curl-style.el') diff --git a/curl-style.el b/curl-style.el index a5a65923b..ad2e91b00 100644 --- a/curl-style.el +++ b/curl-style.el @@ -37,7 +37,7 @@ (setq tab-width 8 indent-tabs-mode nil ; Use spaces. Not tabs. comment-column 40 - c-font-lock-extra-types (append '("bool" "CURL" "CURLcode" "ssize_t" "size_t" "socklen_t" "fd_set" "time_t")) + c-font-lock-extra-types (append '("bool" "CURL" "CURLcode" "ssize_t" "size_t" "socklen_t" "fd_set" "time_t" "off_t")) ) ;; keybindings for C, C++, and Objective-C. We can put these in ;; c-mode-base-map because of inheritance ... -- cgit v1.2.1 From 83d77dc013a54cce1c5bf30fd0446b81efb4a2aa Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 22 Jan 2004 12:48:48 +0000 Subject: font-lock the curl_off_t type instead of the off_t --- curl-style.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'curl-style.el') diff --git a/curl-style.el b/curl-style.el index ad2e91b00..dddedb20a 100644 --- a/curl-style.el +++ b/curl-style.el @@ -37,7 +37,7 @@ (setq tab-width 8 indent-tabs-mode nil ; Use spaces. Not tabs. comment-column 40 - c-font-lock-extra-types (append '("bool" "CURL" "CURLcode" "ssize_t" "size_t" "socklen_t" "fd_set" "time_t" "off_t")) + c-font-lock-extra-types (append '("bool" "CURL" "CURLcode" "ssize_t" "size_t" "socklen_t" "fd_set" "time_t" "curl_off_t")) ) ;; keybindings for C, C++, and Objective-C. We can put these in ;; c-mode-base-map because of inheritance ... -- cgit v1.2.1 From 60e4b57ad8cffe7321ba310412e97b1cd36ce244 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 9 Mar 2004 22:55:47 +0000 Subject: added the new socket type --- curl-style.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'curl-style.el') diff --git a/curl-style.el b/curl-style.el index dddedb20a..ffa4a0ada 100644 --- a/curl-style.el +++ b/curl-style.el @@ -37,7 +37,7 @@ (setq tab-width 8 indent-tabs-mode nil ; Use spaces. Not tabs. comment-column 40 - c-font-lock-extra-types (append '("bool" "CURL" "CURLcode" "ssize_t" "size_t" "socklen_t" "fd_set" "time_t" "curl_off_t")) + c-font-lock-extra-types (append '("bool" "CURL" "CURLcode" "ssize_t" "size_t" "socklen_t" "fd_set" "time_t" "curl_off_t" "curl_socket_t")) ) ;; keybindings for C, C++, and Objective-C. We can put these in ;; c-mode-base-map because of inheritance ... -- cgit v1.2.1 From 0e60a118d060647fd661422fb4237f715b8451fc Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 24 Mar 2004 22:24:03 +0000 Subject: better comments, added some more variable types we use in the font-lock --- curl-style.el | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) (limited to 'curl-style.el') diff --git a/curl-style.el b/curl-style.el index ffa4a0ada..b96ce5f56 100644 --- a/curl-style.el +++ b/curl-style.el @@ -2,17 +2,8 @@ ;;;; $Id$ ;;; The curl hacker's C conventions. - -;;; After loading this file and added the mode-hook you can in C -;;; files, put something like this to use the curl style -;;; automatically: -;; -;; /* ----------------------------------------------------------------- -;; * local variables: -;; * eval: (set c-file-style "curl") -;; * end: -;; */ -;; +;;; See the sample.emacs file on how this file can be made to take +;;; effect automatically when editing curl source files. (defconst curl-c-style '((c-basic-offset . 2) @@ -37,7 +28,7 @@ (setq tab-width 8 indent-tabs-mode nil ; Use spaces. Not tabs. comment-column 40 - c-font-lock-extra-types (append '("bool" "CURL" "CURLcode" "ssize_t" "size_t" "socklen_t" "fd_set" "time_t" "curl_off_t" "curl_socket_t")) + c-font-lock-extra-types (append '("bool" "CURL" "CURLcode" "ssize_t" "size_t" "socklen_t" "fd_set" "time_t" "curl_off_t" "curl_socket_t" "in_addr_t" "CURLSHcode" "CURLMcode")) ) ;; keybindings for C, C++, and Objective-C. We can put these in ;; c-mode-base-map because of inheritance ... -- cgit v1.2.1 From c090fdbdf1027139d19fd5c2678ee380690f33fc Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 17 May 2004 06:54:20 +0000 Subject: automatically delete trailing white space on save in curl-mode --- curl-style.el | 2 ++ 1 file changed, 2 insertions(+) (limited to 'curl-style.el') diff --git a/curl-style.el b/curl-style.el index b96ce5f56..7a6dfc357 100644 --- a/curl-style.el +++ b/curl-style.el @@ -34,6 +34,8 @@ ;; c-mode-base-map because of inheritance ... (define-key c-mode-base-map "\M-q" 'c-fill-paragraph) (setq c-recognize-knr-p nil) + (add-hook 'write-file-hooks 'delete-trailing-whitespace) + (setq show-trailing-whitespace t) ) ;; Set this is in your .emacs if you want to use the c-mode-hook as -- cgit v1.2.1 From bd3aba5d6a1ad3e54b3502b4c5786c3bec9f842a Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 19 May 2004 08:16:08 +0000 Subject: The kill trailing whitespace needs to be set better as this way it takes effect globally which isn't nice. Commented it out for now. Display trailing whitespace still, to remind me. --- curl-style.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'curl-style.el') diff --git a/curl-style.el b/curl-style.el index 7a6dfc357..f3cf4f8ec 100644 --- a/curl-style.el +++ b/curl-style.el @@ -34,7 +34,7 @@ ;; c-mode-base-map because of inheritance ... (define-key c-mode-base-map "\M-q" 'c-fill-paragraph) (setq c-recognize-knr-p nil) - (add-hook 'write-file-hooks 'delete-trailing-whitespace) + ;;; (add-hook 'write-file-hooks 'delete-trailing-whitespace t) (setq show-trailing-whitespace t) ) -- cgit v1.2.1 From 37c269d0bacc3ac7d7c506998b4ddbf104c4f9d8 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 24 May 2004 12:12:09 +0000 Subject: meta-m runs delete-trailing-whitespace in curl-mode --- curl-style.el | 1 + 1 file changed, 1 insertion(+) (limited to 'curl-style.el') diff --git a/curl-style.el b/curl-style.el index f3cf4f8ec..10710a3de 100644 --- a/curl-style.el +++ b/curl-style.el @@ -33,6 +33,7 @@ ;; keybindings for C, C++, and Objective-C. We can put these in ;; c-mode-base-map because of inheritance ... (define-key c-mode-base-map "\M-q" 'c-fill-paragraph) + (define-key c-mode-base-map "\M-m" 'delete-trailing-whitespace) (setq c-recognize-knr-p nil) ;;; (add-hook 'write-file-hooks 'delete-trailing-whitespace t) (setq show-trailing-whitespace t) -- cgit v1.2.1 From 4191741fb673494875ef2b1da0468277463f7357 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 29 Jun 2004 18:45:52 +0000 Subject: Curl_addrinfo is another typedef we use frequently --- curl-style.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'curl-style.el') diff --git a/curl-style.el b/curl-style.el index 10710a3de..0069bbc69 100644 --- a/curl-style.el +++ b/curl-style.el @@ -28,7 +28,7 @@ (setq tab-width 8 indent-tabs-mode nil ; Use spaces. Not tabs. comment-column 40 - c-font-lock-extra-types (append '("bool" "CURL" "CURLcode" "ssize_t" "size_t" "socklen_t" "fd_set" "time_t" "curl_off_t" "curl_socket_t" "in_addr_t" "CURLSHcode" "CURLMcode")) + c-font-lock-extra-types (append '("bool" "CURL" "CURLcode" "ssize_t" "size_t" "socklen_t" "fd_set" "time_t" "curl_off_t" "curl_socket_t" "in_addr_t" "CURLSHcode" "CURLMcode" "Curl_addrinfo")) ) ;; keybindings for C, C++, and Objective-C. We can put these in ;; c-mode-base-map because of inheritance ... -- cgit v1.2.1 From 39af394a1c3ae1d8ac71ad263a7c524988702c2e Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 6 Oct 2004 07:50:18 +0000 Subject: removed tabs and trailing whitespace from source --- curl-style.el | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'curl-style.el') diff --git a/curl-style.el b/curl-style.el index 0069bbc69..25bcd1a37 100644 --- a/curl-style.el +++ b/curl-style.el @@ -20,6 +20,13 @@ ) "Curl C Programming Style") +(defun curl-code-cleanup () + "no docs" + (interactive) + (untabify (point-min) (point-max)) + (delete-trailing-whitespace) +) + ;; Customizations for all of c-mode, c++-mode, and objc-mode (defun curl-c-mode-common-hook () "Curl C mode hook" @@ -33,7 +40,7 @@ ;; keybindings for C, C++, and Objective-C. We can put these in ;; c-mode-base-map because of inheritance ... (define-key c-mode-base-map "\M-q" 'c-fill-paragraph) - (define-key c-mode-base-map "\M-m" 'delete-trailing-whitespace) + (define-key c-mode-base-map "\M-m" 'curl-code-cleanup) (setq c-recognize-knr-p nil) ;;; (add-hook 'write-file-hooks 'delete-trailing-whitespace t) (setq show-trailing-whitespace t) -- cgit v1.2.1 From 9137e717b04644592b9b527839470337fdd9f44d Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Sat, 2 May 2009 02:37:32 +0000 Subject: Use build-time configured curl_socklen_t instead of socklen_t --- curl-style.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'curl-style.el') diff --git a/curl-style.el b/curl-style.el index 25bcd1a37..1cb24f3b9 100644 --- a/curl-style.el +++ b/curl-style.el @@ -35,7 +35,7 @@ (setq tab-width 8 indent-tabs-mode nil ; Use spaces. Not tabs. comment-column 40 - c-font-lock-extra-types (append '("bool" "CURL" "CURLcode" "ssize_t" "size_t" "socklen_t" "fd_set" "time_t" "curl_off_t" "curl_socket_t" "in_addr_t" "CURLSHcode" "CURLMcode" "Curl_addrinfo")) + 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")) ) ;; keybindings for C, C++, and Objective-C. We can put these in ;; c-mode-base-map because of inheritance ... -- cgit v1.2.1 From 2309b4e330b96bc2e1f8e36b6184015e59544037 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 24 Mar 2010 11:02:54 +0100 Subject: remove the CVSish $Id$ lines --- curl-style.el | 1 - 1 file changed, 1 deletion(-) (limited to 'curl-style.el') diff --git a/curl-style.el b/curl-style.el index 1cb24f3b9..83cf8cc31 100644 --- a/curl-style.el +++ b/curl-style.el @@ -1,5 +1,4 @@ ;;;; Emacs Lisp help for writing curl code. ;;;; -;;;; $Id$ ;;; The curl hacker's C conventions. ;;; See the sample.emacs file on how this file can be made to take -- cgit v1.2.1