[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] scratch/fix-33794-extend-electric-layout-mode e02256c 3/6:
From: |
João Távora |
Subject: |
[Emacs-diffs] scratch/fix-33794-extend-electric-layout-mode e02256c 3/6: Minor cleanup in new electric-layout-mode after Stefan's feedback |
Date: |
Sun, 23 Dec 2018 17:51:11 -0500 (EST) |
branch: scratch/fix-33794-extend-electric-layout-mode
commit e02256cf27f8181b378daa08793a7aca6dc1791d
Author: João Távora <address@hidden>
Commit: João Távora <address@hidden>
Minor cleanup in new electric-layout-mode after Stefan's feedback
* lisp/electric.el (electric-layout-post-self-insert-function-1):
Update comments and function names.
---
lisp/electric.el | 54 ++++++++++++++++++++++++++++++++----------------------
1 file changed, 32 insertions(+), 22 deletions(-)
diff --git a/lisp/electric.el b/lisp/electric.el
index 24c040d..6ea2eae 100644
--- a/lisp/electric.el
+++ b/lisp/electric.el
@@ -379,7 +379,7 @@ appearance.")
(when electric-layout-mode
(electric-layout-post-self-insert-function-1)))
-;; for edebug's sake a separate function
+;; for edebug's sake, a separate function
(defun electric-layout-post-self-insert-function-1 ()
(let (pos end)
(when (and (setq pos (electric--after-char-pos))
@@ -391,28 +391,38 @@ appearance.")
(when (eq last-command-event (car rule))
(let* ((rule (cdr rule))
(sym (if (functionp rule) (funcall rule) rule))
- (nl (lambda ()
- (let ((electric-layout-mode nil)
- (electric-pair-open-newline-between-pairs nil))
- (newline 1 t)))))
+ (nl-after
+ (lambda ()
+ ;; FIXME: we use `newline'which calls
+ ;; self-insert-command and ran
+ ;; post-self-insert-hook recursively. It
+ ;; happened to make electric-indent-mode work
+ ;; automatically with electric-layout-mode (at
+ ;; the cost of re-indenting lines multiple
+ ;; times), but I'm not sure it's what we want.
+ ;;
+ ;; FIXME: when `newline'ing, we exceptionally
+ ;; prevent a specific behaviour of
+ ;; `eletric-pair-mode', that of opening an extra
+ ;; newline between newly inserted matching paris.
+ ;; In theory that behaviour should be provided by
+ ;; `electric-layout-mode' instead, but its API is
+ ;; not powerful enough to detect the exact
+ ;; situation.
+ ;;
+ ;; FIXME: check eolp before inserting \n?
+ (let ((electric-layout-mode nil)
+ (electric-pair-open-newline-between-pairs nil))
+ (newline 1 t))))
+ (nl-before (lambda ()
+ (save-excursion
+ (goto-char (1- pos)) (skip-chars-backward "
\t")
+ (unless (bolp) (funcall nl-after))))))
(pcase sym
- ;; FIXME: we used `newline' down here which called
- ;; self-insert-command and ran post-self-insert-hook recursively.
- ;; It happened to make electric-indent-mode work automatically
with
- ;; electric-layout-mode (at the cost of re-indenting lines
- ;; multiple times), but I'm not sure it's what we want.
- ;;
- ;; FIXME: check eolp before inserting \n?
- ('before (save-excursion
- (goto-char (1- pos)) (skip-chars-backward " \t")
- (unless (bolp) (funcall nl))))
- ('after (funcall nl))
- ('after-stay (save-excursion (funcall nl)))
- ('around (save-excursion
- (goto-char (1- pos)) (skip-chars-backward " \t")
- (unless (bolp) (funcall nl)))
- (funcall nl))) ; FIXME: check eolp before
inserting \n?
- ))))))
+ ('before (funcall nl-before))
+ ('after (funcall nl-after))
+ ('after-stay (save-excursion (funcall nl-after)))
+ ('around (funcall nl-before) (funcall nl-after)))))))))
(put 'electric-layout-post-self-insert-function 'priority 40)
- [Emacs-diffs] branch scratch/fix-33794-extend-electric-layout-mode created (now 1173d50), João Távora, 2018/12/23
- [Emacs-diffs] scratch/fix-33794-extend-electric-layout-mode 6deb668 2/6: Rework electric-layout-post-self-insert-function (bug#33794), João Távora, 2018/12/23
- [Emacs-diffs] scratch/fix-33794-extend-electric-layout-mode cb1b4a8 1/6: Extend electric-layout-mode to handle more complex layouts, João Távora, 2018/12/23
- [Emacs-diffs] scratch/fix-33794-extend-electric-layout-mode e02256c 3/6: Minor cleanup in new electric-layout-mode after Stefan's feedback,
João Távora <=
- [Emacs-diffs] scratch/fix-33794-extend-electric-layout-mode e4ef7a2 4/6: Handle entries of multiple symbols in electric-layout-rules, João Távora, 2018/12/23
- [Emacs-diffs] scratch/fix-33794-extend-electric-layout-mode fae3e7c 5/6: Test electric.el in plainer c-mode without c-electric-{brace, paren}, João Távora, 2018/12/23
- [Emacs-diffs] scratch/fix-33794-extend-electric-layout-mode 1173d50 6/6: Slightly more powerful electric-layout-rules, João Távora, 2018/12/23