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

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

[elpa] master 34de254 2/5: [#7] Support using skeletons as expansions


From: Artur Malabarba
Subject: [elpa] master 34de254 2/5: [#7] Support using skeletons as expansions
Date: Wed, 12 Oct 2016 19:18:02 +0000 (UTC)

branch: master
commit 34de2548218d39b49da55d66d141c89e8ee1d85b
Author: Artur Malabarba <address@hidden>
Commit: Artur Malabarba <address@hidden>

    [#7] Support using skeletons as expansions
---
 sotlisp.el |   19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/sotlisp.el b/sotlisp.el
index c52fe95..8d036aa 100644
--- a/sotlisp.el
+++ b/sotlisp.el
@@ -81,6 +81,7 @@
 ;;   (with-temp-buffer (insert text))
 
 ;;; Code:
+(require 'skeleton)
 
 ;;; Predicates
 (defun sotlisp--auto-paired-p ()
@@ -203,8 +204,14 @@ See `sotlisp-define-function-abbrev'."
     (skip-chars-backward (rx alnum))
     (let* ((name (buffer-substring (point) r))
            (expansion (gethash name sotlisp--function-table)))
-      (if (not expansion)
-          (progn (goto-char r) nil)
+      (cond
+       ((not expansion) (progn (goto-char r) nil))
+       ((consp expansion)
+        (delete-region (point) r)
+        (let ((skeleton-end-newline nil))
+          (skeleton-insert (cons "" expansion)))
+        t)
+       ((stringp expansion)
         (delete-region (point) r)
         (if (sotlisp--function-quote-p)
             ;; After #' use the simple expansion.
@@ -214,7 +221,7 @@ See `sotlisp-define-function-abbrev'."
           (when (string-match "\\$" expansion)
             (setq sotlisp--needs-moving t)))
         ;; Must be last.
-        (sotlisp--post-expansion-cleanup)))))
+        (sotlisp--post-expansion-cleanup))))))
 
 (put 'sotlisp--expand-function 'no-self-insert t)
 
@@ -295,12 +302,12 @@ The space char is not included.  Any \"$\" are also 
removed."
     ("jos" . "just-one-space")
     ("jr" . "json-read$")
     ("jtr" . "jump-to-register ")
-    ("k" . "kbd \"$\"")
+    ("k" . ("kbd " (format "%S" (key-description (read-key-sequence-vector 
"Key: ")))))
     ("kb" . "kill-buffer")
     ("kn" . "kill-new ")
     ("kp" . "keywordp ")
     ("l" . "lambda ($)")
-    ("la" . "looking-at \"$\"")
+    ("la" . ("looking-at \"" - "\""))
     ("lap" . "looking-at-p \"$\"")
     ("lb" . "looking-back \"$\"")
     ("lbp" . "line-beginning-position")
@@ -658,7 +665,7 @@ With a prefix argument, defines a `defvar' instead of a 
`defcustom'."
           (skip-chars-backward "\r\n[:blank:]")
           (setq p (point-marker))
           (backward-up-list)))
-      ;; Re-comment everything before it. 
+      ;; Re-comment everything before it.
       (ignore-errors
         (comment-region beg p))
       ;; And everything after it.



reply via email to

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