From 31841e7c7485779a0534af891b85c97f17d4f664 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Sat, 20 Dec 2008 12:36:50 +0000 Subject: [PATCH] helper script for emacs users to get the code style done libssh2-style automatically --- libssh2-style.el | 51 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 libssh2-style.el diff --git a/libssh2-style.el b/libssh2-style.el new file mode 100644 index 0000000..20a24e8 --- /dev/null +++ b/libssh2-style.el @@ -0,0 +1,51 @@ +;;;; Emacs Lisp help for writing libssh2 code. ;;;; +;;;; $Id: libssh2-style.el,v 1.1 2008/12/20 12:36:50 bagder Exp $ + +;;; The libssh2 hacker's C conventions. +;;; See the sample.emacs file on how this file can be made to take +;;; effect automatically when editing libssh2 source files. + +(defconst libssh2-c-style + '((c-basic-offset . 4) + (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) + )) + ) + "Libssh2 C Programming Style") + +(defun libssh2-code-cleanup () + "tabify and delete trailing whitespace" + (interactive) + (untabify (point-min) (point-max)) + (delete-trailing-whitespace) +) + +;; Customizations for all of c-mode, c++-mode, and objc-mode +(defun libssh2-c-mode-common-hook () + "Libssh2 C mode hook" + ;; add libssh2 style and set it for the current buffer + (c-add-style "libssh2" libssh2-c-style t) + (setq tab-width 8 + indent-tabs-mode nil ; Use spaces, not tabs. + comment-column 40 + c-font-lock-extra-types (append '("libssh2_int64_t" "LIBSSH2_USERAUTH_KBDINT_PROMPT" "LIBSSH2_SESSION" "LIBSSH2_CHANNEL" "ssize_t" "size_t" "uint32_t" "LIBSSH2_LISTENER" "LIBSSH2_POLLFD")) + ) + ;; 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" 'libssh2-code-cleanup) + (setq c-recognize-knr-p nil) + ;;; (add-hook 'write-file-hooks 'delete-trailing-whitespace t) + (setq show-trailing-whitespace t) + ) + +;; 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 'libssh2-c-mode-common-hook)