[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 36abeb1 002/108: First Commit.
From: |
Artur Malabarba |
Subject: |
[elpa] master 36abeb1 002/108: First Commit. |
Date: |
Wed, 25 Mar 2015 18:38:45 +0000 |
branch: master
commit 36abeb14220a2c81cf1772689de7c472ede7c5c3
Author: Artur Malabarba <address@hidden>
Commit: Artur Malabarba <address@hidden>
First Commit.
---
aggressive-indent.el | 136 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 136 insertions(+), 0 deletions(-)
diff --git a/aggressive-indent.el b/aggressive-indent.el
new file mode 100644
index 0000000..6a434dc
--- /dev/null
+++ b/aggressive-indent.el
@@ -0,0 +1,136 @@
+;;; aggressive-indent.el --- Minor mode to keep your code always indented.
More aggressive than electric-indent-mode.
+
+;; Copyright (C) 2014 Artur Malabarba <address@hidden>
+
+;; Author: Artur Malabarba <address@hidden>
+;; URL: http://github.com/Bruce-Connor/aggressive-indent-mode
+;; Version: 0.1
+;; Package-Requires: ((emacs "24.1") (names "0.5") (cl-lib "0.5"))
+;; Keywords: indent lisp maint tools
+;; Prefix: aggressive-indent
+;; Separator: -
+
+;;; Commentary:
+;;
+;;
+
+;;; Instructions:
+;;
+;; INSTALLATION
+;;
+;; This package is available fom Melpa, you may install it by calling
+;; M-x package-install RET aggressive-indent.
+;;
+;; Then activate it with
+;; (add-hook 'emacs-lisp-mode-hook #'aggressive-indent-mode)
+;;
+;; You can also use an equivalent hook for another mode,
+;; `aggressive-indent' is not exclusive to emacs-lisp code.
+;;
+;; Alternatively, you can download it manually, place it in your
+;; `load-path' and require it with
+;;
+;; (require 'aggressive-indent)
+
+;;; License:
+;;
+;; 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.
+;;
+
+;;; Change Log:
+;; 0.1 - 2014/10/15 - Release.
+;;; Code:
+
+(require 'cl-lib)
+(require 'names)
+
+;;;###autoload
+(define-namespace aggressive-indent- :group indent
+
+(defconst version "0.1" "Version of the aggressive-indent.el package.")
+(defun bug-report ()
+ "Opens github issues page in a web browser. Please send any bugs you find.
+Please include your emacs and aggressive-indent versions."
+ (interactive)
+ (message "Your `aggressive-indent-version' is: %s, and your emacs version
is: %s.
+Please include this in your report!"
+ aggressive-indent-version emacs-version)
+ (browse-url
"https://github.com/Bruce-Connor/aggressive-indent-mode/issues/new"))
+
+
+;;; Start of actual Code:
+(defcustom excluded-modes '(text-mode tabulated-list-mode special-mode)
+ "Modes in which `aggressive-indent-mode' should not be activated.
+This variable is only used if `global-aggressive-indent-mode' is
+active. If the minor mode is turned on with the local command,
+`aggressive-indent-mode', this variable is ignored."
+ :type '(repeat symbol)
+ :package-version '(aggressive-indent . "0.1"))
+
+(defcustom protected-commands '(undo undo-tree-undo undo-tree-redo)
+ "Commands after which indentation will NOT be performed.
+Aggressive indentation could break things like `undo' by locking
+the user in a loop, so this variable is used to control which
+commands will NOT be followed by a re-indent."
+ :type '(repeat symbol)
+ :package-version '(aggressive-indent . "0.1"))
+
+(defun -softly-indent-defun ()
+ "Indent current defun unobstrusively.
+Like `aggressive-indent-indent-defun', except do nothing if
+mark is active (to avoid deactivaing it), or if buffer is not
+modified (to avoid creating accidental modifications).
+Also, never throw errors nor messages.
+
+Meant for use in hooks. Interactively, use the other one."
+ (unless (or (region-active-p)
+ buffer-read-only
+ (null (buffer-modified-p))
+ (memq last-command protected-commands))
+ (ignore-errors
+ (cl-letf (((symbol-function 'message) #'ignore))
+ (indent-defun)))))
+
+:autoload
+(defun indent-defun ()
+ "Indent current defun.
+Throw an error if parentheses are unbalanced."
+ (interactive)
+ (indent-region
+ (save-excursion (beginning-of-defun 1) (point))
+ (save-excursion (end-of-defun 1) (point))))
+
+
+;;; Minor modes
+:autoload
+(define-minor-mode mode nil nil " ->"
+ '(("\C-c\C-q" . aggressive-indent-indent-defun))
+ (if mode
+ (if (and global-aggressive-indent-mode
+ (cl-member-if #'derived-mode-p excluded-modes))
+ (mode -1)
+ (setq-local electric-indent-mode nil)
+ (add-hook 'post-command-hook #'-softly-indent-defun nil 'local))
+ (remove-hook 'post-command-hook #'-softly-indent-defun 'local)))
+
+:autoload
+(define-globalized-minor-mode global-aggressive-indent-mode
+ mode mode)
+
+:autoload
+(defalias #'aggressive-indent-global-mode
+ #'global-aggressive-indent-mode)
+)
+
+(provide 'aggressive-indent)
+;;; aggressive-indent.el ends here.
- [elpa] master d48181e 003/108: Readme, (continued)
- [elpa] master d48181e 003/108: Readme, Artur Malabarba, 2015/03/25
- [elpa] master 29bbd66 004/108: Changed Lighter, Artur Malabarba, 2015/03/25
- [elpa] master 32387c7 006/108: Merge pull request #1 from purcell/patch-1, Artur Malabarba, 2015/03/25
- [elpa] master 7854cfc 007/108: Replace ’ by ', Artur Malabarba, 2015/03/25
- [elpa] master 82bf8bd 009/108: Merge pull request #2 from Silex/master, Artur Malabarba, 2015/03/25
- [elpa] master 4c2f34e 010/108: Add excluded mode, Artur Malabarba, 2015/03/25
- [elpa] master 3a4b76a 011/108: Merge branch 'dev', Artur Malabarba, 2015/03/25
- [elpa] master 027e7ed 012/108: Add variable dont-indent-if, so the user can prevent indentation., Artur Malabarba, 2015/03/25
- [elpa] master f23224a 014/108: Reactivate `electric-indent-mode'., Artur Malabarba, 2015/03/25
- [elpa] master 964bfae 016/108: Add yaml mode to excluded modes., Artur Malabarba, 2015/03/25
- [elpa] master 36abeb1 002/108: First Commit.,
Artur Malabarba <=
- [elpa] master 759f365 018/108: Merge pull request #8 from tuhdo/master, Artur Malabarba, 2015/03/25
- [elpa] master eaa8cee 013/108: Whitespace, Artur Malabarba, 2015/03/25
- [elpa] master 2e993b8 008/108: Remove trailing whitespace, Artur Malabarba, 2015/03/25
- [elpa] master a1429e5 019/108: Fix variable I forgot to namespace, Artur Malabarba, 2015/03/25
- [elpa] master 7cd4e57 015/108: Fix Version, Artur Malabarba, 2015/03/25
- [elpa] master aebe081 020/108: Improve css-mode support, Artur Malabarba, 2015/03/25
- [elpa] master 1c74518 023/108: Fix last-command -> this-command bug, Artur Malabarba, 2015/03/25
- [elpa] master ebcafdb 022/108: Version Bump, Artur Malabarba, 2015/03/25
- [elpa] master a07019e 021/108: Move up the screencast, Artur Malabarba, 2015/03/25
- [elpa] master 8af72c5 024/108: Factor out the soft part into a macro., Artur Malabarba, 2015/03/25