[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 785d35c 01/13: After expanding, eat up space ahead if conv
From: |
Artur Malabarba |
Subject: |
[elpa] master 785d35c 01/13: After expanding, eat up space ahead if convenient |
Date: |
Wed, 05 Aug 2015 21:54:08 +0000 |
branch: master
commit 785d35c1283ac301e914063c247b4b4963edb9cd
Author: Artur Malabarba <address@hidden>
Commit: Artur Malabarba <address@hidden>
After expanding, eat up space ahead if convenient
---
sotlisp.el | 33 ++++++++++++++++++++++++---------
1 files changed, 24 insertions(+), 9 deletions(-)
diff --git a/sotlisp.el b/sotlisp.el
index 37df485..37baa4b 100644
--- a/sotlisp.el
+++ b/sotlisp.el
@@ -140,6 +140,28 @@ Point is left where the `$' char was. Does nothing if
variable
(sotlisp--auto-paired-p))
(forward-char 1)))
+(defun sotlisp--post-expansion-cleanup ()
+ "Do some processing conditioned on the expansion done.
+If the command that triggered the expansion was a whitespace
+char, perform the steps below and return t.
+
+If the expansion ended in a $, delete it and call
+`sotlisp--maybe-skip-closing-paren'.
+If it ended in a space and there's a space ahead, delete the
+space ahead."
+ ;; Inform `expand-abbrev' that `self-insert-command' should not
+ ;; trigger, by returning non-nil on SPC.
+ (when (sotlisp--whitespace-p)
+ ;; And maybe move out of closing paren if expansion ends with $.
+ (if (eq (char-before) ?$)
+ (progn (delete-char -1)
+ (setq sotlisp--needs-moving nil)
+ (sotlisp--maybe-skip-closing-paren))
+ (when (and (string-match (rx space) (string (char-after)))
+ (string-match (rx space) (string (char-before))))
+ (delete-char 1)))
+ t))
+
(defvar sotlisp--function-table (make-hash-table :test #'equal)
"Table where function abbrev expansions are stored.")
@@ -158,15 +180,8 @@ See `sotlisp-define-function-abbrev'."
(insert expansion)
(when (string-match "\\$" expansion)
(setq sotlisp--needs-moving t))))
- ;; Inform `expand-abbrev' that `self-insert-command' should not
- ;; trigger, by returning non-nil on SPC.
- (when (sotlisp--whitespace-p)
- ;; And maybe move out of closing paren if expansion ends with $.
- (when (eq (char-before) ?$)
- (delete-char -1)
- (setq sotlisp--needs-moving nil)
- (sotlisp--maybe-skip-closing-paren))
- t)))
+ ;; Must be last.
+ (sotlisp--post-expansion-cleanup)))
(put 'sotlisp--expand-function 'no-self-insert t)
- [elpa] master updated (e18833b -> 0bb0ee6), Artur Malabarba, 2015/08/05
- [elpa] master 785d35c 01/13: After expanding, eat up space ahead if convenient,
Artur Malabarba <=
- [elpa] master 960ea2f 02/13: Avoid errors on false positives, Artur Malabarba, 2015/08/05
- [elpa] master f7b4937 04/13: Refactor whitespace detection, Artur Malabarba, 2015/08/05
- [elpa] master c1deb05 03/13: Don't use looking-back, Artur Malabarba, 2015/08/05
- [elpa] master 7f38383 05/13: Don't expand in strings or comments, Artur Malabarba, 2015/08/05
- [elpa] master b957752 07/13: Don't indent if the user is starting to type a comment. Fix #51, Artur Malabarba, 2015/08/05
- [elpa] master 1e6676a 06/13: Version bump, Artur Malabarba, 2015/08/05
- [elpa] master f2c0fe9 08/13: Don't indent if undo-in-progress, Artur Malabarba, 2015/08/05
- [elpa] master 6ccb05d 10/13: More abbrevs, Artur Malabarba, 2015/08/05
- [elpa] master 3557254 09/13: Version bump, Artur Malabarba, 2015/08/05
- [elpa] master 98fe00f 11/13: Version bump, Artur Malabarba, 2015/08/05