update packages
This commit is contained in:
@@ -1,12 +1,14 @@
|
||||
;;; dash.el --- A modern list library for Emacs -*- lexical-binding: t -*-
|
||||
|
||||
;; Copyright (C) 2012-2024 Free Software Foundation, Inc.
|
||||
;; Copyright (C) 2012-2025 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Magnar Sveen <magnars@gmail.com>
|
||||
;; Version: 2.19.1
|
||||
;; Maintainer: Basil L. Contovounesios <basil@contovou.net>
|
||||
;; Package-Version: 20250312.1307
|
||||
;; Package-Revision: fcb5d831fc08
|
||||
;; Package-Requires: ((emacs "24"))
|
||||
;; Keywords: extensions, lisp
|
||||
;; Homepage: https://github.com/magnars/dash.el
|
||||
;; URL: https://github.com/magnars/dash.el
|
||||
|
||||
;; This program is free software: you can redistribute it and/or modify
|
||||
;; it under the terms of the GNU General Public License as published by
|
||||
@@ -30,6 +32,15 @@
|
||||
;;; Code:
|
||||
|
||||
(eval-when-compile
|
||||
(unless (fboundp 'static-if)
|
||||
(defmacro static-if (condition then-form &rest else-forms)
|
||||
"Expand to THEN-FORM or ELSE-FORMS based on compile-time CONDITION.
|
||||
Polyfill for Emacs 30 `static-if'."
|
||||
(declare (debug (sexp sexp &rest sexp)) (indent 2))
|
||||
(if (eval condition lexical-binding)
|
||||
then-form
|
||||
(cons 'progn else-forms))))
|
||||
|
||||
;; TODO: Emacs 24.3 first introduced `gv', so remove this and all
|
||||
;; calls to `defsetf' when support for earlier versions is dropped.
|
||||
(unless (fboundp 'gv-define-setter)
|
||||
@@ -784,19 +795,24 @@ See also: `-flatten'"
|
||||
list)
|
||||
|
||||
(defalias '-concat #'append
|
||||
"Concatenate all the arguments and make the result a list.
|
||||
"Concatenate all SEQUENCES and make the result a list.
|
||||
The result is a list whose elements are the elements of all the arguments.
|
||||
Each argument may be a list, vector or string.
|
||||
|
||||
All arguments except the last argument are copied. The last argument
|
||||
is just used as the tail of the new list.
|
||||
is just used as the tail of the new list. If the last argument is not
|
||||
a list, this results in a dotted list.
|
||||
|
||||
As an exception, if all the arguments except the last are nil, and the
|
||||
last argument is not a list, the return value is that last argument
|
||||
unaltered, not a list.
|
||||
|
||||
\(fn &rest SEQUENCES)")
|
||||
|
||||
(defalias '-copy #'copy-sequence
|
||||
"Create a shallow copy of LIST.
|
||||
|
||||
\(fn LIST)")
|
||||
The elements of LIST are not copied; they are shared with the original.
|
||||
\n(fn LIST)")
|
||||
|
||||
(defmacro --splice (pred form list)
|
||||
"Splice lists generated by FORM in place of items satisfying PRED in LIST.
|
||||
@@ -1036,13 +1052,9 @@ See also: `-first-item', etc."
|
||||
(declare (pure t) (side-effect-free t))
|
||||
(car (last list)))
|
||||
|
||||
;; 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))
|
||||
(defsetf -last-item (x) (val) `(setcar (last ,x) ,val))))
|
||||
(static-if (fboundp 'gv-define-setter)
|
||||
(gv-define-setter -last-item (val x) `(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."
|
||||
@@ -1241,6 +1253,17 @@ For another variant, see also `-take-while'."
|
||||
(declare (important-return-value t))
|
||||
(--drop-while (funcall pred it) list))
|
||||
|
||||
;; Added in Emacs 29.
|
||||
(static-if (fboundp 'take)
|
||||
(defun dash--take (n list)
|
||||
"Return the first N elements of LIST.
|
||||
Like `take', but ensure result is fresh."
|
||||
(let ((prefix (take n list)))
|
||||
(if (eq prefix list)
|
||||
;; If same list is returned, make a copy.
|
||||
(copy-sequence prefix)
|
||||
prefix))))
|
||||
|
||||
(defun -take (n list)
|
||||
"Return a copy of the first N items in LIST.
|
||||
Return a copy of LIST if it contains N items or fewer.
|
||||
@@ -1248,7 +1271,9 @@ Return nil if N is zero or less.
|
||||
|
||||
See also: `-take-last'."
|
||||
(declare (side-effect-free t))
|
||||
(--take-while (< it-index n) list))
|
||||
(static-if (fboundp 'dash--take)
|
||||
(dash--take n list)
|
||||
(--take-while (< it-index n) list)))
|
||||
|
||||
(defun -take-last (n list)
|
||||
"Return a copy of the last N items of LIST in order.
|
||||
@@ -1274,7 +1299,9 @@ Return nil if LIST contains N items or fewer.
|
||||
|
||||
See also: `-drop'."
|
||||
(declare (side-effect-free t))
|
||||
(nbutlast (copy-sequence list) n))
|
||||
(static-if (fboundp 'dash--take)
|
||||
(dash--take (- (length list) n) list)
|
||||
(nbutlast (copy-sequence list) n)))
|
||||
|
||||
(defun -split-at (n list)
|
||||
"Split LIST into two sublists after the Nth element.
|
||||
@@ -2440,7 +2467,7 @@ Similar to &hash but check whether the map is not nil."
|
||||
`(let ((,src ,source))
|
||||
(when ,src (gethash ,key ,src)))))
|
||||
|
||||
(defalias 'dash-expand:&keys 'dash-expand:&plist)
|
||||
(defalias 'dash-expand:&keys #'dash-expand:&plist)
|
||||
|
||||
(defun dash--match-kv-1 (match-form source type)
|
||||
"Match MATCH-FORM against SOURCE of type TYPE.
|
||||
@@ -2901,16 +2928,14 @@ example:
|
||||
(let ((cmp -compare-fn))
|
||||
(cond ((memq cmp '(nil equal)) #'assoc)
|
||||
((eq cmp #'eq) #'assq)
|
||||
;; Since Emacs 26, `assoc' accepts a custom `testfn'.
|
||||
;; Version testing would be simpler here, but feature
|
||||
;; testing gets more brownie points, I guess.
|
||||
((condition-case nil
|
||||
(with-no-warnings (assoc nil () #'eql))
|
||||
(wrong-number-of-arguments t))
|
||||
(lambda (key alist)
|
||||
(--first (and (consp it) (funcall cmp (car it) key)) alist)))
|
||||
((with-no-warnings
|
||||
(lambda (key alist)
|
||||
((lambda (key alist)
|
||||
;; Since Emacs 26, `assoc' accepts a custom `testfn'.
|
||||
;; Version testing would be simpler here, but feature
|
||||
;; testing gets more brownie points, I guess.
|
||||
(static-if (condition-case nil
|
||||
(assoc nil () #'eql)
|
||||
(wrong-number-of-arguments t))
|
||||
(--first (and (consp it) (funcall cmp (car it) key)) alist)
|
||||
(assoc key alist cmp)))))))
|
||||
|
||||
(defun dash--hash-test-fn ()
|
||||
@@ -3298,9 +3323,10 @@ Return the sorted list. LIST is NOT modified by side effects.
|
||||
COMPARATOR is called with two elements of LIST, and should return non-nil
|
||||
if the first element should sort before the second."
|
||||
(declare (important-return-value t))
|
||||
;; Not yet worth changing to (sort list :lessp comparator);
|
||||
;; still seems as fast or slightly faster.
|
||||
(sort (copy-sequence list) comparator))
|
||||
(static-if (condition-case nil (sort []) (wrong-number-of-arguments))
|
||||
;; Since Emacs 30.
|
||||
(sort list :lessp comparator)
|
||||
(sort (copy-sequence list) comparator)))
|
||||
|
||||
(defmacro --sort (form list)
|
||||
"Anaphoric form of `-sort'."
|
||||
@@ -3635,7 +3661,13 @@ structure such as plist or alist."
|
||||
|
||||
;;; Combinators
|
||||
|
||||
(defalias '-partial #'apply-partially)
|
||||
(defalias '-partial #'apply-partially
|
||||
"Return a function that is a partial application of FUN to ARGS.
|
||||
ARGS is a list of the first N arguments to pass to FUN.
|
||||
The result is a new function which does the same as FUN, except that
|
||||
the first N arguments are fixed at the values with which this function
|
||||
was called.
|
||||
\n(fn FUN &rest ARGS)")
|
||||
|
||||
(defun -rpartial (fn &rest args)
|
||||
"Return a function that is a partial application of FN to ARGS.
|
||||
@@ -3801,11 +3833,9 @@ See also: `-orfn' and `-not'."
|
||||
;; Open-code for speed.
|
||||
(cond ((cdr preds) (lambda (&rest args) (--every (apply it args) preds)))
|
||||
(preds (car preds))
|
||||
;; As a `pure' function, this runtime check may generate
|
||||
;; backward-incompatible bytecode for `(-andfn)' at compile-time,
|
||||
;; but I doubt that's a problem in practice (famous last words).
|
||||
((fboundp 'always) #'always)
|
||||
((lambda (&rest _) t))))
|
||||
((static-if (fboundp 'always)
|
||||
#'always
|
||||
(lambda (&rest _) t)))))
|
||||
|
||||
(defun -iteratefn (fn n)
|
||||
"Return a function FN composed N times with itself.
|
||||
@@ -3925,13 +3955,13 @@ This function satisfies the following laws:
|
||||
`(;; TODO: Do not fontify the following automatic variables
|
||||
;; globally; detect and limit to their local anaphoric scope.
|
||||
(,(rx symbol-start (| "acc" "it" "it-index" "other") symbol-end)
|
||||
0 font-lock-variable-name-face)
|
||||
. 'font-lock-variable-name-face)
|
||||
;; Macros in dev/examples.el. Based on `lisp-mode-symbol-regexp'.
|
||||
(,(rx ?\( (group (| "defexamples" "def-example-group")) symbol-end
|
||||
(+ (in "\t "))
|
||||
(group (* (| (syntax word) (syntax symbol) (: ?\\ nonl)))))
|
||||
(1 font-lock-keyword-face)
|
||||
(2 font-lock-function-name-face))
|
||||
(1 'font-lock-keyword-face)
|
||||
(2 'font-lock-function-name-face))
|
||||
;; Symbols in dev/examples.el.
|
||||
,(rx symbol-start (| "=>" "~>" "!!>") symbol-end)
|
||||
;; Elisp macro fontification was static prior to Emacs 25.
|
||||
@@ -4067,15 +4097,14 @@ See also `dash-fontify-mode-lighter' and
|
||||
(if dash-fontify-mode
|
||||
(font-lock-add-keywords nil dash--keywords t)
|
||||
(font-lock-remove-keywords nil dash--keywords))
|
||||
(cond ((fboundp 'font-lock-flush) ;; Added in Emacs 25.
|
||||
(font-lock-flush))
|
||||
;; `font-lock-fontify-buffer' unconditionally enables
|
||||
;; `font-lock-mode' and is marked `interactive-only' in later
|
||||
;; Emacs versions which have `font-lock-flush', so we guard
|
||||
;; and pacify as needed, respectively.
|
||||
(font-lock-mode
|
||||
(with-no-warnings
|
||||
(font-lock-fontify-buffer)))))
|
||||
(static-if (fboundp 'font-lock-flush)
|
||||
;; Added in Emacs 25.
|
||||
(font-lock-flush)
|
||||
(when font-lock-mode
|
||||
;; Unconditionally enables `font-lock-mode' and is marked
|
||||
;; `interactive-only' in later Emacs versions which have
|
||||
;; `font-lock-flush'.
|
||||
(font-lock-fontify-buffer))))
|
||||
|
||||
(defun dash--turn-on-fontify-mode ()
|
||||
"Enable `dash-fontify-mode' if in an Emacs Lisp buffer."
|
||||
|
||||
Reference in New Issue
Block a user