[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master c91a588 14/60: Simplify some code
From: |
João Távora |
Subject: |
[elpa] master c91a588 14/60: Simplify some code |
Date: |
Thu, 21 Jan 2016 22:35:52 +0000 |
branch: master
commit c91a58840b86ae92061a003ec07db1010fde6c90
Author: Noam Postavsky <address@hidden>
Commit: Noam Postavsky <address@hidden>
Simplify some code
* yasnippet.el (yas-define-snippets): Modify the list instead of
reconstructing it.
(yas-load-snippet-buffer-and-close): Replace listp and second with
cdr-safe. Use string-prefix-p rather than string-match-p.
---
yasnippet.el | 42 ++++++++++++------------------------------
1 files changed, 12 insertions(+), 30 deletions(-)
diff --git a/yasnippet.el b/yasnippet.el
index f1bfe65..1f6c7de 100644
--- a/yasnippet.el
+++ b/yasnippet.el
@@ -1665,33 +1665,16 @@ file with the same uuid would replace the previous
snippet.
You can use `yas--parse-template' to return such lists based on
the current buffers contents."
(if yas--creating-compiled-snippets
- (progn
+ (let ((print-length nil))
(insert ";;; Snippet definitions:\n;;;\n")
- (let ((literal-snippets (list))
- (print-length nil))
- (dolist (snippet snippets)
- (let ((key (nth 0 snippet))
- (template-content (nth 1 snippet))
- (name (nth 2 snippet))
- (condition (nth 3 snippet))
- (group (nth 4 snippet))
- (expand-env (nth 5 snippet))
- (file nil) ;; omit on purpose
- (binding (nth 7 snippet))
- (uuid (nth 8 snippet)))
- (push `(,key
- ,template-content
- ,name
- ,condition
- ,group
- ,expand-env
- ,file
- ,binding
- ,uuid)
- literal-snippets)))
- (insert (pp-to-string
- `(yas-define-snippets ',mode ',literal-snippets)))
- (insert "\n\n")))
+ (dolist (snippet snippets)
+ ;; We omit file because the snippet will be loaded from
+ ;; the compiled file instead, so deleting or changing
+ ;; the original won't have any effect.
+ (setcar (nthcdr 6 snippet) nil))
+ (insert (pp-to-string
+ `(yas-define-snippets ',mode ',snippets)))
+ (insert "\n\n"))
;; Normal case.
(let ((snippet-table (yas--table-get-create mode))
(template nil))
@@ -2584,10 +2567,9 @@ and `kill-buffer' instead."
;;
(not (yas--template-file yas--editing-template))
(not (file-writable-p (yas--template-file
yas--editing-template)))
- (and (listp yas-snippet-dirs)
- (second yas-snippet-dirs)
- (not (string-match (expand-file-name (first
yas-snippet-dirs))
- (yas--template-file
yas--editing-template)))))
+ (and (cdr-safe yas-snippet-dirs)
+ (not (string-prefix-p (expand-file-name (car
yas-snippet-dirs))
+ (yas--template-file
yas--editing-template)))))
(y-or-n-p (yas--format "Looks like a library or new snippet. Save
to new file? ")))
(let* ((option (first (yas--guess-snippet-directories (yas--template-table
yas--editing-template))))
(chosen (and option
- [elpa] master 23133da 05/60: Update README.mdown, (continued)
- [elpa] master 23133da 05/60: Update README.mdown, João Távora, 2016/01/21
- [elpa] master 0e7ea94 06/60: Replaced 'shadow' with 'override' throughout documentation, João Távora, 2016/01/21
- [elpa] master 4fd8ab1 02/60: README.mdown (per-buffer): Remove needless lambda, João Távora, 2016/01/21
- [elpa] master d619107 03/60: yasnippet.el (yas-initialize): Mark obsolete, João Távora, 2016/01/21
- [elpa] master 890bd7e 04/60: Merge pull request #569 from npostavs/doc-obsolete, João Távora, 2016/01/21
- [elpa] master 5aebe46 08/60: Closes #549: Adjust `load' verbosity to `yas-verbosity', João Távora, 2016/01/21
- [elpa] master 4692c81 09/60: Fix "invalid function: quote", João Távora, 2016/01/21
- [elpa] master 5ebf347 11/60: Minor doc fixes, João Távora, 2016/01/21
- [elpa] master 197db9f 10/60: Merge pull request #578 from aluaces/patch-1, João Távora, 2016/01/21
- [elpa] master 7f4f6be 07/60: Merge pull request #571 from PhilHudson/master, João Távora, 2016/01/21
- [elpa] master c91a588 14/60: Simplify some code,
João Távora <=
- [elpa] master 7bce1a6 12/60: Add new function yas-lookup-snippet, João Távora, 2016/01/21
- [elpa] master e8934ce 13/60: Merge pull request #596 from npostavs/lookup-snippet, João Távora, 2016/01/21
- [elpa] master 0ada0fc 15/60: Add documentation for snippet compilation, João Távora, 2016/01/21
- [elpa] master 4bd3d98 16/60: Merge pull request #599 from zmwangx/snippet-compilation-doc, João Távora, 2016/01/21
- [elpa] master 2f6cfef 17/60: Closes #601: updated snippets submodule, João Távora, 2016/01/21
- [elpa] master 68b0ab6 20/60: Accept documented snippet list formats, João Távora, 2016/01/21
- [elpa] master cc1c758 18/60: Reorganize snippet construction from list code, João Távora, 2016/01/21
- [elpa] master 01139a2 23/60: * yasnippet.el (yas--define-snippets-2): Use file-name-NONdirectory., João Távora, 2016/01/21
- [elpa] master 8df6a6e 25/60: Fix invalid yas-key-syntaxes element warning, João Távora, 2016/01/21
- [elpa] master 7703a55 24/60: * doc/snippet-organization.org (.yas-skip): Add info., João Távora, 2016/01/21