From bfebf60c5ff2bf348dbbb8c59b9894cc930ea826 Mon Sep 17 00:00:00 2001 From: Andreas Gerler Date: Thu, 31 Oct 2019 16:52:16 +0100 Subject: [PATCH] update dash --- bba.org | 2 +- elpa/dash-20180910.1856/dash-autoloads.el | 26 ---- elpa/dash-20191024.1908/dash-autoloads.el | 15 +++ .../dash-pkg.el | 2 +- .../dash.el | 121 +++++++++++++----- 5 files changed, 103 insertions(+), 63 deletions(-) delete mode 100644 elpa/dash-20180910.1856/dash-autoloads.el create mode 100644 elpa/dash-20191024.1908/dash-autoloads.el rename elpa/{dash-20180910.1856 => dash-20191024.1908}/dash-pkg.el (55%) rename elpa/{dash-20180910.1856 => dash-20191024.1908}/dash.el (97%) diff --git a/bba.org b/bba.org index 84c54b54..5ffa4972 100644 --- a/bba.org +++ b/bba.org @@ -372,8 +372,8 @@ Some key bindings taken from [[https://ebzzry.github.io/emacs-pairs.html][emacs- #+BEGIN_SRC emacs-lisp :tangle yes (if (>= emacs-major-version 24) (progn - (add-to-list 'load-path "~/.emacs.d/elpa/dash-20180910.1856") (add-to-list 'load-path "~/.emacs.d/elpa/smartparens-20191015.1754") + (add-to-list 'load-path "~/.emacs.d/elpa/dash-20191024.1908") (require 'smartparens) (smartparens-global-mode 1) (defmacro def-pairs (pairs) diff --git a/elpa/dash-20180910.1856/dash-autoloads.el b/elpa/dash-20180910.1856/dash-autoloads.el deleted file mode 100644 index c5e79028..00000000 --- a/elpa/dash-20180910.1856/dash-autoloads.el +++ /dev/null @@ -1,26 +0,0 @@ -;;; dash-autoloads.el --- automatically extracted autoloads -;; -;;; Code: - -(add-to-list 'load-path (directory-file-name - (or (file-name-directory #$) (car load-path)))) - - -;;;### (autoloads nil "dash" "dash.el" (0 0 0 0)) -;;; Generated autoloads from dash.el - -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "dash" '("dash-" "-keep" "-butlast" "-non" "-only-some" "-zip" "-e" "->" "-a" "-gr" "-when-let" "-d" "-l" "-s" "-p" "-r" "-m" "-i" "-f" "-u" "-value-to-list" "-t" "--" "-c" "!cons" "!cdr"))) - -;;;*** - -;;;### (autoloads nil nil ("dash-pkg.el") (0 0 0 0)) - -;;;*** - -;; Local Variables: -;; version-control: never -;; no-byte-compile: t -;; no-update-autoloads: t -;; coding: utf-8 -;; End: -;;; dash-autoloads.el ends here diff --git a/elpa/dash-20191024.1908/dash-autoloads.el b/elpa/dash-20191024.1908/dash-autoloads.el new file mode 100644 index 00000000..ce4f638e --- /dev/null +++ b/elpa/dash-20191024.1908/dash-autoloads.el @@ -0,0 +1,15 @@ +;;; dash-autoloads.el --- automatically extracted autoloads +;; +;;; Code: +(add-to-list 'load-path (directory-file-name (or (file-name-directory #$) (car load-path)))) + +;;;### (autoloads nil nil ("dash.el") (23994 42603 671971 548000)) + +;;;*** + +;; Local Variables: +;; version-control: never +;; no-byte-compile: t +;; no-update-autoloads: t +;; End: +;;; dash-autoloads.el ends here diff --git a/elpa/dash-20180910.1856/dash-pkg.el b/elpa/dash-20191024.1908/dash-pkg.el similarity index 55% rename from elpa/dash-20180910.1856/dash-pkg.el rename to elpa/dash-20191024.1908/dash-pkg.el index 29e71235..3bca55c6 100644 --- a/elpa/dash-20180910.1856/dash-pkg.el +++ b/elpa/dash-20191024.1908/dash-pkg.el @@ -1,2 +1,2 @@ ;;; -*- no-byte-compile: t -*- -(define-package "dash" "20180910.1856" "A modern list library for Emacs" 'nil :commit "6514359b8606a6a9a94068ccd601fcd6379d6584" :keywords '("lists") :authors '(("Magnar Sveen" . "magnars@gmail.com")) :maintainer '("Magnar Sveen" . "magnars@gmail.com")) +(define-package "dash" "20191024.1908" "A modern list library for Emacs" 'nil :commit "9631947f2fbeed58b1d07a3ebc1340a3626b2823" :keywords '("lists") :authors '(("Magnar Sveen" . "magnars@gmail.com")) :maintainer '("Magnar Sveen" . "magnars@gmail.com")) diff --git a/elpa/dash-20180910.1856/dash.el b/elpa/dash-20191024.1908/dash.el similarity index 97% rename from elpa/dash-20180910.1856/dash.el rename to elpa/dash-20191024.1908/dash.el index ee67456a..f1b3e069 100644 --- a/elpa/dash-20180910.1856/dash.el +++ b/elpa/dash-20191024.1908/dash.el @@ -3,8 +3,8 @@ ;; Copyright (C) 2012-2016 Free Software Foundation, Inc. ;; Author: Magnar Sveen -;; Version: 2.14.1 -;; Package-Version: 20180910.1856 +;; Version: 2.16.0 +;; Package-Version: 20191024.1908 ;; Keywords: lists ;; This program is free software; you can redistribute it and/or modify @@ -34,6 +34,12 @@ ;;; Code: +;; TODO: `gv' was introduced in Emacs 24.3, so remove this and all +;; calls to `defsetf' when support for earlier versions is dropped. +(eval-when-compile + (unless (fboundp 'gv-define-setter) + (require 'cl))) + (defgroup dash () "Customize group for dash.el" :group 'lisp @@ -87,6 +93,14 @@ the target form." forms) ,retval))) +(defmacro --doto (eval-initial-value &rest forms) + "Anaphoric form of `-doto'. +Note: `it' is not required in each form." + (declare (indent 1)) + `(let ((it ,eval-initial-value)) + ,@forms + it)) + (defun -each (list fn) "Call FN with every item in LIST. Return nil, used for side-effects only." (--each list (funcall fn it))) @@ -675,7 +689,10 @@ See also: `-third-item'. \(fn LIST)") -(defalias '-third-item 'caddr +(defalias '-third-item + (if (fboundp 'caddr) + #'caddr + (lambda (list) (car (cddr list)))) "Return the third item of LIST, or nil if LIST is too short. See also: `-fourth-item'. @@ -696,28 +713,18 @@ See also: `-last-item'." (declare (pure t) (side-effect-free t)) (car (cdr (cdr (cdr (cdr list)))))) -;; TODO: gv was introduced in 24.3, so we can remove the if statement -;; when support for earlier versions is dropped -(eval-when-compile - (require 'cl) - (if (fboundp 'gv-define-simple-setter) - (gv-define-simple-setter -first-item setcar) - (require 'cl) - (with-no-warnings - (defsetf -first-item (x) (val) `(setcar ,x ,val))))) - (defun -last-item (list) "Return the last item of LIST, or nil on an empty list." (declare (pure t) (side-effect-free t)) (car (last list))) -;; TODO: gv was introduced in 24.3, so we can remove the if statement -;; when support for earlier versions is dropped -(eval-when-compile +;; Use `with-no-warnings' to suppress unbound `-last-item' or +;; undefined `gv--defsetter' warnings arising from both +;; `gv-define-setter' and `defsetf' in certain Emacs versions. +(with-no-warnings (if (fboundp 'gv-define-setter) (gv-define-setter -last-item (val x) `(setcar (last ,x) ,val)) - (with-no-warnings - (defsetf -last-item (x) (val) `(setcar (last ,x) ,val))))) + (defsetf -last-item (x) (val) `(setcar (last ,x) ,val)))) (defun -butlast (list) "Return a list of all items in list except for the last." @@ -914,9 +921,11 @@ See also: `-drop'" "Rotate LIST N places to the right. With N negative, rotate to the left. The time complexity is O(n)." (declare (pure t) (side-effect-free t)) - (if (> n 0) - (append (last list n) (butlast list n)) - (append (-drop (- n) list) (-take (- n) list)))) + (when list + (let* ((len (length list)) + (n-mod-len (mod n len)) + (new-tail-len (- len n-mod-len))) + (append (-drop new-tail-len list) (-take new-tail-len list))))) (defun -insert-at (n x list) "Return a list with X inserted into LIST at position N. @@ -1643,6 +1652,10 @@ All returned symbols are guaranteed to be unique." (t (cons (list s source) (dash--match-cons-1 match-form s)))))) +(defun dash--get-expand-function (type) + "Get expand function name for TYPE." + (intern-soft (format "dash-expand:%s" type))) + (defun dash--match-cons-1 (match-form source &optional props) "Match MATCH-FORM against SOURCE. @@ -1662,7 +1675,7 @@ SOURCE is a proper or improper list." ((cdr match-form) (cond ((and (symbolp (car match-form)) - (memq (car match-form) '(&keys &plist &alist &hash))) + (functionp (dash--get-expand-function (car match-form)))) (dash--match-kv (dash--match-kv-normalize-match-form match-form) (dash--match-cons-get-cdr skip-cdr source))) ((dash--match-ignore-place-p (car match-form)) (dash--match-cons-1 (cdr match-form) source @@ -1803,6 +1816,27 @@ kv can be any key-value store, such as plist, alist or hash-table." (t (cons (list s source) (dash--match-kv-1 (cdr match-form) s (car match-form))))))) +(defun dash-expand:&hash (key source) + "Generate extracting KEY from SOURCE for &hash destructuring." + `(gethash ,key ,source)) + +(defun dash-expand:&plist (key source) + "Generate extracting KEY from SOURCE for &plist destructuring." + `(plist-get ,source ,key)) + +(defun dash-expand:&alist (key source) + "Generate extracting KEY from SOURCE for &alist destructuring." + `(cdr (assoc ,key ,source))) + +(defun dash-expand:&hash? (key source) + "Generate extracting KEY from SOURCE for &hash? destructuring. +Similar to &hash but check whether the map is not nil." + (let ((src (make-symbol "src"))) + `(let ((,src ,source)) + (when ,src (gethash ,key ,src))))) + +(defalias 'dash-expand:&keys 'dash-expand:&plist) + (defun dash--match-kv-1 (match-form source type) "Match MATCH-FORM against SOURCE of type TYPE. @@ -1820,13 +1854,8 @@ Valid values are &plist, &alist and &hash." (lambda (kv) (let* ((k (car kv)) (v (cadr kv)) - (getter (cond - ((or (eq type '&plist) (eq type '&keys)) - `(plist-get ,source ,k)) - ((eq type '&alist) - `(cdr (assoc ,k ,source))) - ((eq type '&hash) - `(gethash ,k ,source))))) + (getter + (funcall (dash--get-expand-function type) k source))) (cond ((symbolp v) (list (list v getter))) @@ -1859,7 +1888,7 @@ Key-value stores are disambiguated by placing a token &plist, (let ((s (car match-form))) (cons (list s source) (dash--match (cddr match-form) s)))) - ((memq (car match-form) '(&keys &plist &alist &hash)) + ((functionp (dash--get-expand-function (car match-form))) (dash--match-kv (dash--match-kv-normalize-match-form match-form) source)) (t (dash--match-cons match-form source)))) ((vectorp match-form) @@ -2245,9 +2274,22 @@ The test for equality is done with `equal', or with `-compare-fn' if that's non-nil. Alias: `-uniq'" - (let (result) - (--each list (unless (-contains? result it) (!cons it result))) - (nreverse result))) + ;; Implementation note: The speedup gained from hash table lookup + ;; starts to outweigh its overhead for lists of length greater than + ;; 32. See discussion in PR #305. + (let* ((len (length list)) + (lut (and (> len 32) + ;; Check that `-compare-fn' is a valid hash-table + ;; lookup function or `nil'. + (memq -compare-fn '(nil equal eq eql)) + (make-hash-table :test (or -compare-fn #'equal) + :size len)))) + (if lut + (--filter (unless (gethash it lut) + (puthash it t lut)) + list) + (--each list (unless (-contains? lut it) (!cons it lut))) + (nreverse lut)))) (defalias '-uniq '-distinct) @@ -2300,7 +2342,11 @@ or with `-compare-fn' if that's non-nil." (defun -inits (list) "Return all prefixes of LIST." - (nreverse (-map 'reverse (-tails (nreverse list))))) + (let ((res (list list))) + (setq list (reverse list)) + (while list + (push (reverse (!cdr list)) res)) + res)) (defun -tails (list) "Return all suffixes of LIST" @@ -2533,11 +2579,15 @@ the new seed." (defun -cons-pair? (con) "Return non-nil if CON is true cons pair. -That is (A . B) where B is not a list." +That is (A . B) where B is not a list. + +Alias: `-cons-pair-p'" (declare (pure t) (side-effect-free t)) (and (listp con) (not (listp (cdr con))))) +(defalias '-cons-pair-p '-cons-pair?) + (defun -cons-to-list (con) "Convert a cons pair to a list with `car' and `cdr' of the pair respectively." (declare (pure t) (side-effect-free t)) @@ -2942,6 +2992,7 @@ structure such as plist or alist." "-unfold" "--unfold" "-cons-pair?" + "-cons-pair-p" "-cons-to-list" "-value-to-list" "-tree-mapreduce-from" -- 2.47.3