diff -Nru aggressive-indent-mode-1.8.3/aggressive-indent.el aggressive-indent-mode-1.9.0/aggressive-indent.el --- aggressive-indent-mode-1.8.3/aggressive-indent.el 2016-10-20 04:04:39.000000000 +0000 +++ aggressive-indent-mode-1.9.0/aggressive-indent.el 2017-06-27 19:23:56.000000000 +0000 @@ -4,7 +4,7 @@ ;; Author: Artur Malabarba ;; URL: https://github.com/Malabarba/aggressive-indent-mode -;; Version: 1.8.3 +;; Version: 1.8.4 ;; Package-Requires: ((emacs "24.1") (cl-lib "0.5")) ;; Keywords: indent lisp maint tools ;; Prefix: aggressive-indent @@ -113,50 +113,18 @@ :package-version '(aggressive-indent . "0.3.1")) (defcustom aggressive-indent-excluded-modes - '( - bibtex-mode - cider-repl-mode - coffee-mode - comint-mode - conf-mode - Custom-mode - diff-mode - doc-view-mode - dos-mode - erc-mode - feature-mode - fortran-mode - f90-mode - jabber-chat-mode - haml-mode - haskell-mode - haskell-interactive-mode - image-mode - inf-ruby-mode + '(inf-ruby-mode makefile-mode makefile-gmake-mode - minibuffer-inactive-mode - netcmd-mode python-mode - sass-mode - scala-mode - slim-mode - special-mode - shell-mode - snippet-mode - eshell-mode - tabulated-list-mode - term-mode - TeX-output-mode text-mode - yaml-mode - ) + yaml-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.3.1")) + :package-version '(aggressive-indent . "1.8.4")) (defcustom aggressive-indent-protected-commands '(undo undo-tree-undo undo-tree-redo whitespace-cleanup) "Commands after which indentation will NOT be performed. @@ -166,6 +134,14 @@ :type '(repeat symbol) :package-version '(aggressive-indent . "0.1")) +(defcustom aggressive-indent-protected-current-commands + '(query-replace-regexp query-replace) + "Like `aggressive-indent-protected-commands', but for the current command. +For instance, with the default value, this variable prevents +indentation during `query-replace' (but not after)." + :type '(repeat symbol) + :package-version '(aggressive-indent . "1.8.4")) + (defcustom aggressive-indent-comments-too nil "If non-nil, aggressively indent in comments as well." :type 'boolean @@ -188,12 +164,14 @@ ;;; Preventing indentation (defconst aggressive-indent--internal-dont-indent-if - '((memq this-command aggressive-indent-protected-commands) + '((memq last-command aggressive-indent-protected-commands) + (memq this-command aggressive-indent-protected-current-commands) (region-active-p) buffer-read-only undo-in-progress (null (buffer-modified-p)) (and (boundp 'smerge-mode) smerge-mode) + (equal (buffer-name) "*ediff-merge*") (let ((line (thing-at-point 'line))) (and (stringp line) ;; If the user is starting to type a comment. @@ -248,7 +226,7 @@ '(when (derived-mode-p 'ruby-mode) (let ((line (thing-at-point 'line))) (and (stringp line) - (string-match "\\b\\(if\\|case\\|do\\|begin\\) *$" line)))))) + (string-match "\\b\\(begin\\|case\\|d\\(?:ef\\|o\\)\\|if\\) *$" line)))))) (defcustom aggressive-indent-dont-indent-if '() "List of variables and functions to prevent aggressive indenting. @@ -256,10 +234,32 @@ As long as any one of these forms returns non-nil, aggressive-indent will not perform any indentation. -See `aggressive-indent--internal-dont-indent-if' for usage examples." +See `aggressive-indent--internal-dont-indent-if' for usage examples. + +Note that this is only used once, and only on the line where the +point is when we're about to start indenting. In order to +prevent indentation of further lines, see +`aggressive-indent-stop-here-hook'." :type '(repeat sexp) :package-version '(aggressive-indent . "0.2")) +(defcustom aggressive-indent-stop-here-hook nil + "A hook that runs on each line before it is indented. +If any function on this hook returns non-nil, it immediately +prevents indentation of the current line and any further +lines. + +Note that aggressive-indent does indentation in two stages. The +first stage indents the entire edited region, while the second +stage keeps indenting further lines until its own logic decide to +stop. This hook only affects the second stage. That is, it +effectly lets you add your own predicates to the logic that +decides when to stop. + +In order to prevent indentation before the first stage, see +`aggressive-indent-dont-indent-if' instead." + :type 'hook) + (defvar aggressive-indent--error-message "One of the forms in `aggressive-indent-dont-indent-if' had the following error, I've disabled it until you fix it: %S" "Error message thrown by `aggressive-indent-dont-indent-if'.") @@ -305,6 +305,40 @@ (ignore-errors (aggressive-indent-indent-defun l r)))) ;;; Indenting region +(defun aggressive-indent--indent-current-balanced-line (column) + "Indent current balanced line, if it starts at COLUMN. +Balanced line means anything contained in a sexp that starts at +the current line, or starts at the same line that one of these +sexps ends. + +Return non-nil only if the line's indentation actually changed." + (when (= (current-column) column) + (unless (= (point) + (progn (indent-according-to-mode) + (point))) + (let ((line-end (line-end-position))) + (forward-sexp 1) + (comment-forward (point-max)) + ;; We know previous sexp finished on a previous line when + ;; there's only be whitespace behind point. + (while (progn + (skip-chars-backward "[:blank:]") + (not (looking-at "^"))) + (forward-sexp 1) + (comment-forward (point-max))) + (when (looking-at "^") + (indent-region line-end (1- (point)))) + (skip-chars-forward "[:blank:]"))))) + +(defun aggressive-indent--extend-end-to-whole-sexps (beg end) + "Return a point >= END, so that it covers whole sexps from BEG." + (save-excursion + (goto-char beg) + (while (and (< (point) end) + (not (eobp))) + (forward-sexp 1)) + (point))) + ;;;###autoload (defun aggressive-indent-indent-region-and-on (l r) "Indent region between L and R, and then some. @@ -329,23 +363,10 @@ ;; And then we indent each following line until nothing happens. (forward-line 1) (skip-chars-forward "[:blank:]\n\r\xc") - (let* ((eod (ignore-errors - (save-excursion (end-of-defun) - (point-marker)))) - (point-limit (if (and eod (< (point) eod)) - eod (point-max-marker)))) - (while (and (null (eobp)) - (let ((op (point)) - (np (progn (indent-according-to-mode) - (point)))) - ;; As long as we're indenting things to the - ;; left, keep indenting. - (or (< np op) - ;; If we're indenting to the right, or - ;; not at all, stop at the limit. - (< (point) point-limit)))) - (forward-line 1) - (skip-chars-forward "[:blank:]\n\r\f")))) + (let ((base-column (current-column))) + (while (and (not (eobp)) + (not (run-hook-with-args-until-success 'aggressive-indent-stop-here-hook)) + (aggressive-indent--indent-current-balanced-line base-column))))) (goto-char p)))) (defun aggressive-indent--softly-indent-region-and-on (l r &rest _) @@ -383,22 +404,29 @@ typing, try tweaking this number." :type 'float) +(defvar-local aggressive-indent--idle-timer nil + "Idle timer used for indentation") + (defun aggressive-indent--indent-if-changed () "Indent any region that changed in the last command loop." - (when aggressive-indent--changed-list + (when (and aggressive-indent-mode aggressive-indent--changed-list) (save-excursion (save-selected-window (unless (or (run-hook-wrapped 'aggressive-indent--internal-dont-indent-if #'eval) (aggressive-indent--run-user-hooks)) (while-no-input - (sit-for aggressive-indent-sit-for-time t) - (redisplay) - (aggressive-indent--proccess-changed-list-and-indent))))))) + (aggressive-indent--proccess-changed-list-and-indent))))) + (when (timerp aggressive-indent--idle-timer) + (cancel-timer aggressive-indent--idle-timer)))) (defun aggressive-indent--keep-track-of-changes (l r &rest _) "Store the limits (L and R) of each change in the buffer." (when aggressive-indent-mode - (push (list l r) aggressive-indent--changed-list))) + (push (list l r) aggressive-indent--changed-list) + (when (timerp aggressive-indent--idle-timer) + (cancel-timer aggressive-indent--idle-timer)) + (setq aggressive-indent--idle-timer + (run-with-idle-timer aggressive-indent-sit-for-time t #'aggressive-indent--indent-if-changed)))) ;;; Minor modes ;;;###autoload @@ -417,7 +445,9 @@ (if aggressive-indent-mode (if (and global-aggressive-indent-mode (or (cl-member-if #'derived-mode-p aggressive-indent-excluded-modes) - (memq major-mode '(text-mode fundamental-mode)) + (equal indent-line-function #'indent-relative) + (derived-mode-p 'text-mode) + (eq major-mode 'fundamental-mode) buffer-read-only)) (aggressive-indent-mode -1) ;; Should electric indent be ON or OFF? @@ -426,12 +456,12 @@ (aggressive-indent--local-electric nil) (aggressive-indent--local-electric t)) (add-hook 'after-change-functions #'aggressive-indent--keep-track-of-changes nil 'local) - (add-hook 'before-save-hook #'aggressive-indent--proccess-changed-list-and-indent nil 'local) - (add-hook 'post-command-hook #'aggressive-indent--indent-if-changed nil 'local)) + (add-hook 'before-save-hook #'aggressive-indent--proccess-changed-list-and-indent nil 'local)) ;; Clean the hooks + (when (timerp aggressive-indent--idle-timer) + (cancel-timer aggressive-indent--idle-timer)) (remove-hook 'after-change-functions #'aggressive-indent--keep-track-of-changes 'local) (remove-hook 'before-save-hook #'aggressive-indent--proccess-changed-list-and-indent 'local) - (remove-hook 'post-command-hook #'aggressive-indent--indent-if-changed 'local) (remove-hook 'post-command-hook #'aggressive-indent--softly-indent-defun 'local))) (defun aggressive-indent--local-electric (on) diff -Nru aggressive-indent-mode-1.8.3/debian/changelog aggressive-indent-mode-1.9.0/debian/changelog --- aggressive-indent-mode-1.8.3/debian/changelog 2016-10-20 04:07:54.000000000 +0000 +++ aggressive-indent-mode-1.9.0/debian/changelog 2017-10-22 18:47:18.000000000 +0000 @@ -1,3 +1,14 @@ +aggressive-indent-mode (1.9.0-1) unstable; urgency=medium + + * New upstream release. + * Fix Version: header which upstream neglected to update. + * Switch to dgit-maint-merge(7) workflow. + - Add d/source/options + - Add d/source/patch-header. + * Bump std-ver to 4.1.1 (no changes required). + + -- Sean Whitton Sun, 22 Oct 2017 11:47:18 -0700 + aggressive-indent-mode (1.8.3-1) unstable; urgency=medium * New upstream version. diff -Nru aggressive-indent-mode-1.8.3/debian/control aggressive-indent-mode-1.9.0/debian/control --- aggressive-indent-mode-1.8.3/debian/control 2016-10-20 04:07:54.000000000 +0000 +++ aggressive-indent-mode-1.9.0/debian/control 2017-10-22 18:44:47.000000000 +0000 @@ -4,7 +4,7 @@ Maintainer: Debian Emacs addons team Uploaders: Sean Whitton Build-Depends: debhelper (>= 10), dh-elpa (>= 0.0.17) -Standards-Version: 3.9.8 +Standards-Version: 4.1.1 Homepage: https://github.com/Malabarba/aggressive-indent-mode Vcs-Git: https://anonscm.debian.org/git/pkg-emacsen/pkg/aggressive-indent-mode.git Vcs-Browser: https://anonscm.debian.org/cgit/pkg-emacsen/pkg/aggressive-indent-mode.git/ diff -Nru aggressive-indent-mode-1.8.3/debian/patches/0001-patch-README-for-Debian-package.patch aggressive-indent-mode-1.9.0/debian/patches/0001-patch-README-for-Debian-package.patch --- aggressive-indent-mode-1.8.3/debian/patches/0001-patch-README-for-Debian-package.patch 2016-10-20 04:07:54.000000000 +0000 +++ aggressive-indent-mode-1.9.0/debian/patches/0001-patch-README-for-Debian-package.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,54 +0,0 @@ -From: Sean Whitton -Date: Sat, 13 Feb 2016 12:20:49 -0700 -Subject: patch README for Debian package - ---- - README.md | 20 +++----------------- - 1 file changed, 3 insertions(+), 17 deletions(-) - -diff --git a/README.md b/README.md -index 68e07ad..78acd95 100644 ---- a/README.md -+++ b/README.md -@@ -1,4 +1,4 @@ --aggressive-indent-mode [![Melpa](http://melpa.org/packages/aggressive-indent-badge.svg)](http://melpa.org/#/aggressive-indent) [![Melpa-Stable](http://stable.melpa.org/packages/aggressive-indent-badge.svg)](http://stable.melpa.org/#/aggressive-indent) -+aggressive-indent-mode - ====================== - - `electric-indent-mode` is enough to keep your code nicely aligned when -@@ -20,11 +20,7 @@ than `electric-indent-mode`. - - ### Instructions ### - --This package is available fom Melpa, you may install it by calling -- -- M-x package-install RET aggressive-indent -- --Then activate it with -+Activate this package with - - (add-hook 'emacs-lisp-mode-hook #'aggressive-indent-mode) - (add-hook 'css-mode-hook #'aggressive-indent-mode) -@@ -36,16 +32,6 @@ every programming mode, you can do something like: - (global-aggressive-indent-mode 1) - (add-to-list 'aggressive-indent-excluded-modes 'html-mode) - --#### Manual Installation #### -- --If you don't want to install from Melpa, you can download it manually, --place it in your `load-path` along with its dependency `cl-lib` (which --you should already have if your `emacs-version` is at least 24.3). -- --Then require it with: -- -- (require 'aggressive-indent) -- - ### Customization ### - - The variable `aggressive-indent-dont-indent-if` lets you customize -@@ -62,4 +48,4 @@ following clause: - - ## Contribute ## - --[![Gratipay](https://cdn.rawgit.com/gratipay/gratipay-badge/2.1.3/dist/gratipay.png)](https://gratipay.com/Malabarba) -+Make a donation to the package author: diff -Nru aggressive-indent-mode-1.8.3/debian/patches/auto-gitignore aggressive-indent-mode-1.9.0/debian/patches/auto-gitignore --- aggressive-indent-mode-1.8.3/debian/patches/auto-gitignore 2016-10-20 04:07:55.000000000 +0000 +++ aggressive-indent-mode-1.9.0/debian/patches/auto-gitignore 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -Subject: Update .gitignore from Debian packaging branch - -The Debian packaging git branch contains these updates to the upstream -.gitignore file(s). This patch is autogenerated, to provide these -updates to users of the official Debian archive view of the package. - -[dgit (2.3) update-gitignore] ---- -diff --git a/.gitignore b/.gitignore -new file mode 100644 -index 0000000..19c4b56 ---- /dev/null -+++ b/.gitignore -@@ -0,0 +1,3 @@ -+/debian/files -+/debian/elpa-aggressive-indent* -+/debian/.debhelper diff -Nru aggressive-indent-mode-1.8.3/debian/patches/debian-changes aggressive-indent-mode-1.9.0/debian/patches/debian-changes --- aggressive-indent-mode-1.8.3/debian/patches/debian-changes 1970-01-01 00:00:00.000000000 +0000 +++ aggressive-indent-mode-1.9.0/debian/patches/debian-changes 2017-10-22 18:47:18.000000000 +0000 @@ -0,0 +1,78 @@ +The Debian packaging of aggressive-indent-mode is maintained in git, +using the merging workflow described in dgit-maint-merge(7). There +isn't a patch queue that can be represented as a quilt series. + +A detailed breakdown of the changes is available from their canonical +representation - git commits in the packaging repository. For +example, to see the changes made by the Debian maintainer in the first +upload of upstream version 1.2.3, you could use: + + % git clone https://git.dgit.debian.org/aggressive-indent-mode + % cd aggressive-indent-mode + % git log --oneline 1.2.3..debian/1.2.3-1 -- . ':!debian' + +(If you have dgit, use `dgit clone aggressive-indent-mode`, rather +than plain `git clone`.) + +A single combined diff, containing all the changes, follows. +--- /dev/null ++++ aggressive-indent-mode-1.9.0/.gitignore +@@ -0,0 +1,3 @@ ++/debian/files ++/debian/elpa-aggressive-indent* ++/debian/.debhelper +--- aggressive-indent-mode-1.9.0.orig/README.md ++++ aggressive-indent-mode-1.9.0/README.md +@@ -1,4 +1,4 @@ +-aggressive-indent-mode [![Melpa](http://melpa.org/packages/aggressive-indent-badge.svg)](http://melpa.org/#/aggressive-indent) [![Melpa-Stable](http://stable.melpa.org/packages/aggressive-indent-badge.svg)](http://stable.melpa.org/#/aggressive-indent) ++aggressive-indent-mode + ====================== + + `electric-indent-mode` is enough to keep your code nicely aligned when +@@ -20,11 +20,7 @@ than `electric-indent-mode`. + + ### Instructions ### + +-This package is available from Melpa, you may install it by calling +- +- M-x package-install RET aggressive-indent +- +-Then activate it with ++Activate this package with + + (add-hook 'emacs-lisp-mode-hook #'aggressive-indent-mode) + (add-hook 'css-mode-hook #'aggressive-indent-mode) +@@ -36,16 +32,6 @@ every programming mode, you can do somet + (global-aggressive-indent-mode 1) + (add-to-list 'aggressive-indent-excluded-modes 'html-mode) + +-#### Manual Installation #### +- +-If you don't want to install from Melpa, you can download it manually, +-place it in your `load-path` along with its dependency `cl-lib` (which +-you should already have if your `emacs-version` is at least 24.3). +- +-Then require it with: +- +- (require 'aggressive-indent) +- + ### Customization ### + + The variable `aggressive-indent-dont-indent-if` lets you customize +@@ -62,4 +48,4 @@ following clause: + + ## Contribute ## + +-[![Gratipay](https://cdn.rawgit.com/gratipay/gratipay-badge/2.1.3/dist/gratipay.png)](https://gratipay.com/Malabarba) ++Make a donation to the package author: +--- aggressive-indent-mode-1.9.0.orig/aggressive-indent.el ++++ aggressive-indent-mode-1.9.0/aggressive-indent.el +@@ -4,7 +4,7 @@ + + ;; Author: Artur Malabarba + ;; URL: https://github.com/Malabarba/aggressive-indent-mode +-;; Version: 1.8.4 ++;; Version: 1.9.0 + ;; Package-Requires: ((emacs "24.1") (cl-lib "0.5")) + ;; Keywords: indent lisp maint tools + ;; Prefix: aggressive-indent diff -Nru aggressive-indent-mode-1.8.3/debian/patches/series aggressive-indent-mode-1.9.0/debian/patches/series --- aggressive-indent-mode-1.8.3/debian/patches/series 2016-10-20 04:07:55.000000000 +0000 +++ aggressive-indent-mode-1.9.0/debian/patches/series 2017-10-22 18:47:18.000000000 +0000 @@ -1,2 +1 @@ -0001-patch-README-for-Debian-package.patch -auto-gitignore +debian-changes diff -Nru aggressive-indent-mode-1.8.3/debian/source/options aggressive-indent-mode-1.9.0/debian/source/options --- aggressive-indent-mode-1.8.3/debian/source/options 1970-01-01 00:00:00.000000000 +0000 +++ aggressive-indent-mode-1.9.0/debian/source/options 2017-10-22 18:41:40.000000000 +0000 @@ -0,0 +1,2 @@ +single-debian-patch +auto-commit diff -Nru aggressive-indent-mode-1.8.3/debian/source/patch-header aggressive-indent-mode-1.9.0/debian/source/patch-header --- aggressive-indent-mode-1.8.3/debian/source/patch-header 1970-01-01 00:00:00.000000000 +0000 +++ aggressive-indent-mode-1.9.0/debian/source/patch-header 2017-10-22 18:41:49.000000000 +0000 @@ -0,0 +1,17 @@ +The Debian packaging of aggressive-indent-mode is maintained in git, +using the merging workflow described in dgit-maint-merge(7). There +isn't a patch queue that can be represented as a quilt series. + +A detailed breakdown of the changes is available from their canonical +representation - git commits in the packaging repository. For +example, to see the changes made by the Debian maintainer in the first +upload of upstream version 1.2.3, you could use: + + % git clone https://git.dgit.debian.org/aggressive-indent-mode + % cd aggressive-indent-mode + % git log --oneline 1.2.3..debian/1.2.3-1 -- . ':!debian' + +(If you have dgit, use `dgit clone aggressive-indent-mode`, rather +than plain `git clone`.) + +A single combined diff, containing all the changes, follows. diff -Nru aggressive-indent-mode-1.8.3/README.md aggressive-indent-mode-1.9.0/README.md --- aggressive-indent-mode-1.8.3/README.md 2016-10-20 04:04:39.000000000 +0000 +++ aggressive-indent-mode-1.9.0/README.md 2017-06-27 19:23:56.000000000 +0000 @@ -20,7 +20,7 @@ ### Instructions ### -This package is available fom Melpa, you may install it by calling +This package is available from Melpa, you may install it by calling M-x package-install RET aggressive-indent