From 7e081a860b46d1dd2d303fc6ad4e1787ee7d0ee6 Mon Sep 17 00:00:00 2001 From: Gergely Polonkai Date: Wed, 28 Jan 2015 16:55:12 +0100 Subject: [PATCH] Add gitconfig-mode --- .../gitconfig-mode-autoloads.el | 24 ++++ elpa/gitconfig-mode-0.3/gitconfig-mode-pkg.el | 1 + elpa/gitconfig-mode-0.3/gitconfig-mode.el | 105 ++++++++++++++++++ 3 files changed, 130 insertions(+) create mode 100644 elpa/gitconfig-mode-0.3/gitconfig-mode-autoloads.el create mode 100644 elpa/gitconfig-mode-0.3/gitconfig-mode-pkg.el create mode 100644 elpa/gitconfig-mode-0.3/gitconfig-mode.el diff --git a/elpa/gitconfig-mode-0.3/gitconfig-mode-autoloads.el b/elpa/gitconfig-mode-0.3/gitconfig-mode-autoloads.el new file mode 100644 index 0000000..1fe7d36 --- /dev/null +++ b/elpa/gitconfig-mode-0.3/gitconfig-mode-autoloads.el @@ -0,0 +1,24 @@ +;;; gitconfig-mode-autoloads.el --- automatically extracted autoloads +;; +;;; Code: +(add-to-list 'load-path (or (file-name-directory #$) (car load-path))) + +;;;### (autoloads nil "gitconfig-mode" "gitconfig-mode.el" (21633 +;;;;;; 45695 432043 861000)) +;;; Generated autoloads from gitconfig-mode.el + +(autoload 'gitconfig-mode "gitconfig-mode" "\ +A major mode for editing .gitconfig files. + +\(fn)" t nil) + +(setq auto-mode-alist (append '(("/\\.gitconfig\\'" . gitconfig-mode) ("/\\.git/config\\'" . gitconfig-mode)) auto-mode-alist)) + +;;;*** + +;; Local Variables: +;; version-control: never +;; no-byte-compile: t +;; no-update-autoloads: t +;; End: +;;; gitconfig-mode-autoloads.el ends here diff --git a/elpa/gitconfig-mode-0.3/gitconfig-mode-pkg.el b/elpa/gitconfig-mode-0.3/gitconfig-mode-pkg.el new file mode 100644 index 0000000..cddf1dd --- /dev/null +++ b/elpa/gitconfig-mode-0.3/gitconfig-mode-pkg.el @@ -0,0 +1 @@ +(define-package "gitconfig-mode" "0.3" "Major mode for editing .gitconfig files" 'nil) diff --git a/elpa/gitconfig-mode-0.3/gitconfig-mode.el b/elpa/gitconfig-mode-0.3/gitconfig-mode.el new file mode 100644 index 0000000..2994719 --- /dev/null +++ b/elpa/gitconfig-mode-0.3/gitconfig-mode.el @@ -0,0 +1,105 @@ +;;; gitconfig-mode.el --- Major mode for editing .gitconfig files -*- lexical-binding: t; -*- + +;; Copyright (c) 2012, 2013 Sebastian Wiesner +;; +;; Author: Sebastian Wiesner +;; URL: https://github.com/lunaryorn/git-modes +;; Version: 0.3 +;; Keywords: convenience vc git + +;; This file is not part of GNU Emacs. + +;; This program is free software; you can redistribute it and/or modify it under +;; the terms of the GNU General Public License as published by the Free Software +;; Foundation; either version 2 of the License, or (at your option) any later +;; version. + +;; This program is distributed in the hope that it will be useful, but WITHOUT +;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +;; FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +;; details. + +;; You should have received a copy of the GNU General Public License along with +;; this program; if not, write to the Free Software Foundation, Inc., 51 +;; Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +;;; Commentary: + +;; A major mode for editing .gitconfig files. + +;;; Code: + +(require 'conf-mode) + +(defun gitconfig-line-indented-p () + "Determine whether the current line is indented correctly. + +Return t if so, or nil otherwise." + (save-excursion + (beginning-of-line) + (or (looking-at "^\\[\\_<.*?\\]") + (looking-at "^\t\\_<\\(?:\\sw|\\s_\\)")))) + +(defun gitconfig-point-in-indentation-p () + "Determine whether the point is in the indentation of the current line. + +Return t if so, or nil otherwise." + (save-excursion + (let ((pos (point))) + (back-to-indentation) + (< pos (point))))) + +(defun gitconfig-indent-line () + "Indent the current line." + (interactive) + (unless (gitconfig-line-indented-p) + (let ((old-point (point-marker)) + (was-in-indent (gitconfig-point-in-indentation-p))) + (beginning-of-line) + (delete-horizontal-space) + (unless (= (char-after) ?\[) + (insert-char ?\t 1)) + (if was-in-indent + (back-to-indentation) + (goto-char (marker-position old-point)))))) + +(defvar gitconfig-mode-syntax-table + (let ((table (make-syntax-table conf-unix-mode-syntax-table))) + ;; ; is a comment in .gitconfig + (modify-syntax-entry ?\; "<" table) + table) + "Syntax table to use in .gitconfig buffers.") + +(defvar gitconfig-mode-font-lock-keywords + `( + ;; Highlight section and subsection gitconfig headers, and override + ;; syntactic fontification in these. + ("^\\s-*\\[\\_<\\(\\(?:\\sw\\|\\s_\\)+\\)\\_>\\(?:\\s-+\\(\\s\".+?\\s\"\\)\\)?\\]\\s-*" + (1 'font-lock-type-face t nil) + (2 'font-lock-function-name-face t t)) + ("^\\s-*\\_<\\(\\(?:\\sw\\|\\s_\\)+\\)\\_>\\s-*\\(?:=.*\\)?$" + (1 'font-lock-variable-name-face)) + ;; Highlight booleans and numbers + (,(format "=\\s-*%s\\s-*$" + (regexp-opt '("yes" "no" "true" "false" "on" "off") 'words)) + (1 'font-lock-keyword-face)) + ("=\\s-*\\<\\([0-9]+\\)\\>\\s-*$" (1 'font-lock-constant-face)))) + +;;;###autoload +(define-derived-mode gitconfig-mode conf-unix-mode "Gitconfig" + "A major mode for editing .gitconfig files." + ;; .gitconfig is indented with tabs only + (conf-mode-initialize "#" gitconfig-mode-font-lock-keywords) + (setq indent-tabs-mode t) + (set (make-local-variable 'indent-line-function) + 'gitconfig-indent-line)) + +;;;###autoload +(setq auto-mode-alist + (append '(("/\\.gitconfig\\'" . gitconfig-mode) + ("/\\.git/config\\'" . gitconfig-mode)) + auto-mode-alist)) + +(provide 'gitconfig-mode) + +;;; gitconfig-mode.el ends here