emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] master 663f78a 2/7: [Fix #8] Add undo-boundaries before inserting


From: Artur Malabarba
Subject: [elpa] master 663f78a 2/7: [Fix #8] Add undo-boundaries before inserting the prefix
Date: Sun, 13 Sep 2015 15:01:11 +0000

branch: master
commit 663f78a78e3c41c2ee1dc1e9d2744c11d5c948e6
Author: Artur Malabarba <address@hidden>
Commit: Artur Malabarba <address@hidden>

    [Fix #8] Add undo-boundaries before inserting the prefix
---
 nameless.el |   26 +++++++++++++++-----------
 1 files changed, 15 insertions(+), 11 deletions(-)

diff --git a/nameless.el b/nameless.el
index 3d7f7b9..f7ae637 100644
--- a/nameless.el
+++ b/nameless.el
@@ -160,15 +160,16 @@ displayed as `::internal-impl', instead of 
`:-internal-impl'."
 (defvar-local nameless-current-name nil)
 (put 'nameless-current-name 'safe-local-variable #'stringp)
 
-(defun nameless--in-arglist-p ()
-  "Is point inside an arglist?"
+(defun nameless--in-arglist-p (l)
+  "Is point L inside an arglist?"
   (save-excursion
+    (goto-char l)
     (ignore-errors
       (backward-up-list)
       (or (progn (forward-sexp -1)
                  (looking-at-p "[a-z-]lambda\\_>"))
           (progn (forward-sexp -1)
-                 (looking-at-p 
"\\(cl-\\)?def\\(un\\|macro\\|inline\\)\\*?\\_>"))))))
+                 (looking-at-p "\\(cl-\\)?def"))))))
 
 (defun nameless-insert-name (&optional noerror)
   "Insert `nameless-current-name' or the alias at point.
@@ -207,19 +208,22 @@ configured, or if `nameless-current-name' is nil."
 (defun nameless-insert-name-or-self-insert (&optional self-insert)
   "Insert the name of current package, with a hyphen."
   (interactive "P")
-  (if (or self-insert
-          (not nameless-current-name)
-          (eq (char-before) ?\\)
-          (nameless--in-arglist-p))
-      (call-interactively #'self-insert-command)
-    (or (nameless-insert-name 'noerror)
-        (call-interactively #'self-insert-command))))
+  (let ((l (point)))
+    (call-interactively #'self-insert-command)
+    (unless (or self-insert
+                (not nameless-current-name)
+                (eq (char-before l) ?\\)
+                (nameless--in-arglist-p l))
+      (undo-boundary)
+      (delete-region l (point))
+      (unless (nameless-insert-name 'noerror)
+        (call-interactively #'self-insert-command)))))
 
 (put 'nameless-insert-name-or-self-insert 'delete-selection t)
 
 (defun nameless--name-regexp (name)
   "Return a regexp of the current name."
-  (concat "\\_<@?\\(" (regexp-quote name) "-\\)\\(\\s_\\|\\sw\\)"))
+  (concat "\\_<@?\\(_" (regexp-quote name) "-\\)\\(\\s_\\|\\sw\\)"))
 
 (defun nameless--private-name-regexp (name)
   "Return a regexp of the current private name."



reply via email to

[Prev in Thread] Current Thread [Next in Thread]