From d3a5ddb4189ef7c04df0cc47a0f9642b23292d2d Mon Sep 17 00:00:00 2001 From: thing1 Date: Tue, 1 Apr 2025 20:27:39 +0100 Subject: added magit and other general configs --- elpa/llama-0.6.2/Makefile | 70 +++++ elpa/llama-0.6.2/README-elpa | 71 +++++ elpa/llama-0.6.2/README.org | 68 +++++ elpa/llama-0.6.2/llama-autoloads.el | 117 ++++++++ elpa/llama-0.6.2/llama-pkg.el | 2 + elpa/llama-0.6.2/llama-test.el | 525 +++++++++++++++++++++++++++++++++ elpa/llama-0.6.2/llama-test.elc | Bin 0 -> 75240 bytes elpa/llama-0.6.2/llama.el | 572 ++++++++++++++++++++++++++++++++++++ elpa/llama-0.6.2/llama.elc | Bin 0 -> 17250 bytes 9 files changed, 1425 insertions(+) create mode 100644 elpa/llama-0.6.2/Makefile create mode 100644 elpa/llama-0.6.2/README-elpa create mode 100644 elpa/llama-0.6.2/README.org create mode 100644 elpa/llama-0.6.2/llama-autoloads.el create mode 100644 elpa/llama-0.6.2/llama-pkg.el create mode 100644 elpa/llama-0.6.2/llama-test.el create mode 100644 elpa/llama-0.6.2/llama-test.elc create mode 100644 elpa/llama-0.6.2/llama.el create mode 100644 elpa/llama-0.6.2/llama.elc (limited to 'elpa/llama-0.6.2') diff --git a/elpa/llama-0.6.2/Makefile b/elpa/llama-0.6.2/Makefile new file mode 100644 index 0000000..aab6b57 --- /dev/null +++ b/elpa/llama-0.6.2/Makefile @@ -0,0 +1,70 @@ +-include .config.mk + +PKG = llama + +ELS = $(PKG).el +ELS += $(PKG)-test.el +ELCS = $(ELS:.el=.elc) + +$(PKG).elc: +$(PKG)-test.elc: $(PKG).elc + +DEPS = compat + +EMACS ?= emacs +EMACS_ARGS ?= --eval "(progn \ + (put 'if-let 'byte-obsolete-info nil) \ + (put 'when-let 'byte-obsolete-info nil))" + +LOAD_PATH ?= $(addprefix -L ../,$(DEPS)) +LOAD_PATH += -L . + +all: lisp + +help: + $(info make all - generate byte-code and autoloads) + $(info make lisp - generate byte-code and autoloads) + $(info make redo - re-generate byte-code and autoloads) + $(info make test - run tests) + $(info make clean - remove generated files) + @printf "\n" + +redo: clean lisp + +lisp: $(ELCS) loaddefs check-declare + +loaddefs: $(PKG)-autoloads.el + +%.elc: %.el + @printf "Compiling $<\n" + @$(EMACS) -Q --batch $(EMACS_ARGS) $(LOAD_PATH) -f batch-byte-compile $< + +check-declare: + @printf " Checking function declarations\n" + @$(EMACS) -Q --batch $(EMACS_ARGS) $(LOAD_PATH) \ + --eval "(check-declare-directory default-directory)" + +test: lisp + @$(EMACS) -Q --batch $(EMACS_ARGS) $(LOAD_PATH) \ + -l ert -l $(PKG)-test.el -f ert-run-tests-batch-and-exit + +CLEAN = $(ELCS) $(PKG)-autoloads.el + +clean: + @printf " Cleaning...\n" + @rm -rf $(CLEAN) + +$(PKG)-autoloads.el: $(ELS) + @printf " Creating $@\n" + @$(EMACS) -Q --batch -l autoload -l cl-lib --eval "\ +(let ((file (expand-file-name \"$@\"))\ + (autoload-timestamps nil) \ + (backup-inhibited t)\ + (version-control 'never)\ + (coding-system-for-write 'utf-8-emacs-unix))\ + (write-region (autoload-rubric file \"package\" nil) nil file nil 'silent)\ + (cl-letf (((symbol-function 'progress-reporter-do-update) (lambda (&rest _)))\ + ((symbol-function 'progress-reporter-done) (lambda (_))))\ + (let ((generated-autoload-file file))\ + (update-directory-autoloads default-directory))))" \ + 2>&1 | sed "/^Package autoload is deprecated$$/d" diff --git a/elpa/llama-0.6.2/README-elpa b/elpa/llama-0.6.2/README-elpa new file mode 100644 index 0000000..809f657 --- /dev/null +++ b/elpa/llama-0.6.2/README-elpa @@ -0,0 +1,71 @@ +1 Llama — Compact syntax for short lambda +═════════════════════════════════════════ + + This package implements a macro named `##', which provides a compact + way to write short `lambda' expressions. + + The signature of the macro is `(## FN &rest BODY)' and it expands to a + `lambda' expression, which calls the function `FN' with the arguments + `BODY' and returns the value of that. The arguments of the `lambda' + expression are derived from symbols found in `BODY'. + + Each symbol from `%1' through `%9', which appears in an unquoted part + of `BODY', specifies a mandatory argument. Each symbol from `&1' + through `&9', which appears in an unquoted part of `BODY', specifies + an optional argument. The symbol `&*' specifies extra (`&rest') + arguments. + + The shorter symbol `%' can be used instead of `%1', but using both in + the same expression is not allowed. Likewise `&' can be used instead + of `&1'. These shorthands are not recognized in function position. + + To support binding forms that use a vector as `VARLIST' (such as + `-let' from the `dash' package), argument symbols are also detected + inside of vectors. + + The space between `##' and `FN' can be omitted because `##' is + read-syntax for the symbol whose name is the empty string. If you + prefer you can place a space there anyway, and if you prefer to not + use this somewhat magical symbol at all, you can instead use the + alternative name `llama'. + + Instead of: + + ┌──── + │ (lambda (a &optional _ c &rest d) + │ (foo a (bar c) d)) + └──── + + you can use this macro and write: + + ┌──── + │ (##foo %1 (bar &3) &*) + └──── + + which expands to: + + ┌──── + │ (lambda (%1 &optional _&2 &3 &rest &*) + │ (foo %1 (bar &3) &*)) + └──── + + Unused trailing arguments and mandatory unused arguments at the border + between mandatory and optional arguments are also supported: + + ┌──── + │ (##list %1 _%3 &5 _&6) + └──── + + becomes: + + ┌──── + │ (lambda (%1 _%2 _%3 &optional _&4 &5 _&6) + │ (list %1 &5)) + └──── + + Note how `_%3' and `_&6' are removed from the body, because their + names begin with an underscore. Also note that `_&4' is optional, + unlike the explicitly specified `_%3'. + + Consider enabling `llama-fontify-mode' to highlight `##' and its + special arguments. diff --git a/elpa/llama-0.6.2/README.org b/elpa/llama-0.6.2/README.org new file mode 100644 index 0000000..42134f2 --- /dev/null +++ b/elpa/llama-0.6.2/README.org @@ -0,0 +1,68 @@ +* Llama — Compact syntax for short lambda + +This package implements a macro named ~##~, which provides a compact way +to write short ~lambda~ expressions. + +The signature of the macro is ~(## FN &rest BODY)~ and it expands to a +~lambda~ expression, which calls the function ~FN~ with the arguments ~BODY~ +and returns the value of that. The arguments of the ~lambda~ expression +are derived from symbols found in ~BODY~. + +Each symbol from ~%1~ through ~%9~, which appears in an unquoted part +of ~BODY~, specifies a mandatory argument. Each symbol from ~&1~ through +~&9~, which appears in an unquoted part of ~BODY~, specifies an optional +argument. The symbol ~&*~ specifies extra (~&rest~) arguments. + +The shorter symbol ~%~ can be used instead of ~%1~, but using both in +the same expression is not allowed. Likewise ~&~ can be used instead +of ~&1~. These shorthands are not recognized in function position. + +To support binding forms that use a vector as ~VARLIST~ (such as ~-let~ +from the ~dash~ package), argument symbols are also detected inside of +vectors. + +The space between ~##~ and ~FN~ can be omitted because ~##~ is read-syntax +for the symbol whose name is the empty string. If you prefer you can +place a space there anyway, and if you prefer to not use this somewhat +magical symbol at all, you can instead use the alternative name ~llama~. + +Instead of: + +#+begin_src emacs-lisp + (lambda (a &optional _ c &rest d) + (foo a (bar c) d)) +#+end_src + +you can use this macro and write: + +#+begin_src emacs-lisp + (##foo %1 (bar &3) &*) +#+end_src + +which expands to: + +#+begin_src emacs-lisp + (lambda (%1 &optional _&2 &3 &rest &*) + (foo %1 (bar &3) &*)) +#+end_src + +Unused trailing arguments and mandatory unused arguments at the border +between mandatory and optional arguments are also supported: + +#+begin_src emacs-lisp + (##list %1 _%3 &5 _&6) +#+end_src + +becomes: + +#+begin_src emacs-lisp + (lambda (%1 _%2 _%3 &optional _&4 &5 _&6) + (list %1 &5)) +#+end_src + +Note how ~_%3~ and ~_&6~ are removed from the body, because their names +begin with an underscore. Also note that ~_&4~ is optional, unlike the +explicitly specified ~_%3~. + +Consider enabling ~llama-fontify-mode~ to highlight ~##~ and its special +arguments. diff --git a/elpa/llama-0.6.2/llama-autoloads.el b/elpa/llama-0.6.2/llama-autoloads.el new file mode 100644 index 0000000..155fd93 --- /dev/null +++ b/elpa/llama-0.6.2/llama-autoloads.el @@ -0,0 +1,117 @@ +;;; llama-autoloads.el --- automatically extracted autoloads (do not edit) -*- lexical-binding: t -*- +;; Generated by the `loaddefs-generate' function. + +;; This file is part of GNU Emacs. + +;;; Code: + +(add-to-list 'load-path (or (and load-file-name (directory-file-name (file-name-directory load-file-name))) (car load-path))) + + + +;;; Generated autoloads from llama.el + +(autoload 'llama "llama" "\ +Expand to a `lambda' expression that wraps around FN and BODY. + +This macro provides a compact way to write short `lambda' expressions. +It expands to a `lambda' expression, which calls the function FN with +arguments BODY and returns its value. The arguments of the `lambda' +expression are derived from symbols found in BODY. + +Each symbol from `%1' through `%9', which appears in an unquoted part +of BODY, specifies a mandatory argument. Each symbol from `&1' through +`&9', which appears in an unquoted part of BODY, specifies an optional +argument. The symbol `&*' specifies extra (`&rest') arguments. + +The shorter symbol `%' can be used instead of `%1', but using both in +the same expression is not allowed. Likewise `&' can be used instead +of `&1'. These shorthands are not recognized in function position. + +To support binding forms that use a vector as VARLIST (such as `-let' +from the `dash' package), argument symbols are also detected inside of +vectors. + +The space between `##' and FN can be omitted because `##' is read-syntax +for the symbol whose name is the empty string. If you prefer you can +place a space there anyway, and if you prefer to not use this somewhat +magical symbol at all, you can instead use the alternative name `llama'. + +Instead of: + + (lambda (a &optional _ c &rest d) + (foo a (bar c) d)) + +you can use this macro and write: + + (##foo %1 (bar &3) &*) + +which expands to: + + (lambda (%1 &optional _&2 &3 &rest &*) + (foo %1 (bar &3) &*)) + +Unused trailing arguments and mandatory unused arguments at the border +between mandatory and optional arguments are also supported: + + (##list %1 _%3 &5 _&6) + +becomes: + + (lambda (%1 _%2 _%3 &optional _&4 &5 _&6) + (list %1 &5)) + +Note how `_%3' and `_&6' are removed from the body, because their names +begin with an underscore. Also note that `_&4' is optional, unlike the +explicitly specified `_%3'. + +Consider enabling `llama-fontify-mode' to highlight `##' and its +special arguments. + +(fn FN &rest BODY)" nil t) +(defvar llama-fontify-mode nil "\ +Non-nil if Llama-Fontify mode is enabled. +See the `llama-fontify-mode' command +for a description of this minor mode. +Setting this variable directly does not take effect; +either customize it (see the info node `Easy Customization') +or call the function `llama-fontify-mode'.") +(custom-autoload 'llama-fontify-mode "llama" nil) +(autoload 'llama-fontify-mode "llama" "\ +In Emacs Lisp mode, highlight the `##' macro and its special arguments. + +This is a global minor mode. If called interactively, toggle the +`Llama-Fontify mode' mode. If the prefix argument is positive, enable +the mode, and if it is zero or negative, disable the mode. + +If called from Lisp, toggle the mode if ARG is `toggle'. Enable the +mode if ARG is nil, omitted, or is a positive number. Disable the mode +if ARG is a negative number. + +To check whether the minor mode is enabled in the current buffer, +evaluate `(default-value \\='llama-fontify-mode)'. + +The mode's hook is called both when the mode is enabled and when it is +disabled. + +(fn &optional ARG)" t) +(register-definition-prefixes "llama" '("##" "all-completions" "elisp-" "intern" "lisp--el-match-keyword@llama" "llama-")) + + +;;; Generated autoloads from llama-test.el + +(register-definition-prefixes "llama-test" '("llama-test--flatten")) + +;;; End of scraped data + +(provide 'llama-autoloads) + +;; Local Variables: +;; version-control: never +;; no-byte-compile: t +;; no-update-autoloads: t +;; no-native-compile: t +;; coding: utf-8-emacs-unix +;; End: + +;;; llama-autoloads.el ends here diff --git a/elpa/llama-0.6.2/llama-pkg.el b/elpa/llama-0.6.2/llama-pkg.el new file mode 100644 index 0000000..d9fd935 --- /dev/null +++ b/elpa/llama-0.6.2/llama-pkg.el @@ -0,0 +1,2 @@ +;; Generated package description from llama.el -*- mode: lisp-data; no-byte-compile: t -*- +(define-package "llama" "0.6.2" "Compact syntax for short lambda" '((emacs "26.1") (compat "30.0.2.0")) :commit "48e5bc4919a4a29665362832d59ade8e248b0c3e" :keywords '("extensions") :url "https://github.com/tarsius/llama") diff --git a/elpa/llama-0.6.2/llama-test.el b/elpa/llama-0.6.2/llama-test.el new file mode 100644 index 0000000..1d2f46f --- /dev/null +++ b/elpa/llama-0.6.2/llama-test.el @@ -0,0 +1,525 @@ +;;; llama-tests.el --- Tests for Llama -*- lexical-binding:t -*- + +;; Copyright (C) 2020-2025 Jonas Bernoulli + +;; Authors: Jonas Bernoulli +;; Homepage: https://github.com/tarsius/llama +;; Keywords: extensions + +;; SPDX-License-Identifier: GPL-3.0-or-later + +;; This file is free software: you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published +;; by the Free Software Foundation, either version 3 of the License, +;; or (at your option) any later version. +;; +;; This file is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. +;; +;; You should have received a copy of the GNU General Public License +;; along with this file. If not, see . + +;;; Code: + +(require 'llama) + +(ert-deftest llama-test-101-basic nil + + (should (equal (##list %1) + (lambda (%1) + (list %1)))) + + (should (equal (##list %1 %1) + (lambda (%1) + (list %1 %1)))) + + (should (equal (##list %1 %2) + (lambda (%1 %2) + (list %1 %2)))) + + (should (equal (##list %2 %1) + (lambda (%1 %2) + (list %2 %1)))) + + (should (equal (##list 'const %1) + (lambda ( %1) + (list 'const %1)))) + + (should (equal (##list %1 'const) + (lambda (%1) + (list %1 'const)))) + + (should (equal (##list %1 'const %2) + (lambda (%1 %2) + (list %1 'const %2)))) + + (should (equal (##list %2 'const %1) + (lambda (%1 %2) + (list %2 'const %1)))) + + (should (equal (##list %1 %2 %3 %4 %5 %6 %7 %8 %9) + (lambda (%1 %2 %3 %4 %5 %6 %7 %8 %9) + (list %1 %2 %3 %4 %5 %6 %7 %8 %9)))) + + (should (equal (##list %1 %2 %1 %3 %5 %4 %6 %7 %9 %8) + (lambda (%1 %2 %3 %4 %5 %6 %7 %8 %9) + (list %1 %2 %1 %3 %5 %4 %6 %7 %9 %8)))) + ) + +(ert-deftest llama-test-102-basic-optional nil + + (should (equal (##list &1) + (lambda (&optional &1) + (list &1)))) + + (should (equal (##list %1 &2) + (lambda (%1 &optional &2) + (list %1 &2)))) + + (should (equal (##list %2 %1 &4 &3) + (lambda ( %1 %2 &optional &3 &4) + (list %2 %1 &4 &3)))) + ) + +(ert-deftest llama-test-103-basic-rest nil + + (should (equal (##list &*) + (lambda (&rest &*) + (list &*)))) + + (should (equal (##list %1 &*) + (lambda (%1 &rest &*) + (list %1 &*)))) + + (should (equal (##list %1 &2 &*) + (lambda (%1 &optional &2 &rest &*) + (list %1 &2 &*)))) + ) + +(ert-deftest llama-test-104-basic-nested nil + + (should (equal (##list (##list %) %1) + (lambda (%1) + (list (lambda (%) (list %)) + %1)))) + ) + +(ert-deftest llama-test-105-basic-nil nil + + (should (equal (##list (##list %) %1) + (lambda (%1) + (list (lambda (%) (list %)) + %1)))) + ) + +(ert-deftest llama-test-201-unused-implicit-mandatory nil + + (should (equal (##list %2) + (lambda (_%1 %2) + (list %2)))) + + (should (equal (##list %2 %3) + (lambda (_%1 %2 %3) + (list %2 %3)))) + + (should (equal (##list %3) + (lambda (_%1 _%2 %3) + (list %3)))) + + (should (equal (##list %1 %3) + (lambda (%1 _%2 %3) + (list %1 %3)))) + + (should (equal (##list %3 %6) + (lambda (_%1 _%2 %3 _%4 _%5 %6) + (list %3 %6)))) + ) + +(ert-deftest llama-test-202-unused-implicit-optional nil + + (should (equal (##list &2) + (lambda (&optional _&1 &2) + (list &2)))) + + (should (equal (##list &2 &3) + (lambda (&optional _&1 &2 &3) + (list &2 &3)))) + + (should (equal (##list &3) + (lambda (&optional _&1 _&2 &3) + (list &3)))) + + (should (equal (##list &1 &3) + (lambda (&optional &1 _&2 &3) + (list &1 &3)))) + + (should (equal (##list &3 &6) + (lambda (&optional _&1 _&2 &3 _&4 _&5 &6) + (list &3 &6)))) + ) + +(ert-deftest llama-test-203-unused-implicit-mixed nil + + (should (equal (##list %1 &3) + (lambda (%1 &optional _&2 &3) + (list %1 &3)))) + + (should (equal (##list %1 &4) + (lambda (%1 &optional _&2 _&3 &4) + (list %1 &4)))) + + (should (equal (##list %1 %2 &4) + (lambda (%1 %2 &optional _&3 &4) + (list %1 %2 &4)))) + + + (should (equal (##list %2 &4 &6) + (lambda (_%1 %2 &optional _&3 &4 _&5 &6) + (list %2 &4 &6)))) + ) + +(ert-deftest llama-test-301-unused-explicit-trailing nil + + (should (equal (##list _%1) + (lambda (_%1) + (list)))) + + (should (equal (##list _%2) + (lambda (_%1 _%2) + (list)))) + + (should (equal (##list %1 _%2) + (lambda (%1 _%2) + (list %1)))) + + (should (equal (##list %1 _%3) + (lambda (%1 _%2 _%3) + (list %1)))) + ) + +(ert-deftest llama-test-302-unused-explicit-border nil + + (should (equal (##list _%1 &2) + (lambda (_%1 &optional &2) + (list &2)))) + + (should (equal (##list _%2 &3) + (lambda (_%1 _%2 &optional &3) + (list &3)))) + + (should (equal (##list %1 _%2 &3) + (lambda (%1 _%2 &optional &3) + (list %1 &3)))) + + (should (equal (##list %1 _%2 &4) + (lambda (%1 _%2 &optional _&3 &4) + (list %1 &4)))) + + (should (equal (##list %1 _%3 &6) + (lambda (%1 _%2 _%3 &optional _&4 _&5 &6) + (list %1 &6)))) + ) + +(ert-deftest llama-test-303-unused-redundant nil + + (should (equal (##list _%1 %2) + (lambda (_%1 %2) + (list %2)))) + + (should (equal (##list _&1 &2) + (lambda (&optional _&1 &2) + (list &2)))) + ) + +(ert-deftest llama-test-401-abbrev nil + ;; llama-test-101-basic(s/%1/%/) + + (should (equal (##list %) + (lambda (%) + (list %)))) + + (should (equal (##list % %) + (lambda (%) + (list % %)))) + + (should (equal (##list % %2) + (lambda (% %2) + (list % %2)))) + + (should (equal (##list %2 %) + (lambda (% %2) + (list %2 %)))) + + (should (equal (##list 'const %) + (lambda ( %) + (list 'const %)))) + + (should (equal (##list % 'const) + (lambda (%) + (list % 'const)))) + + (should (equal (##list % 'const %2) + (lambda (% %2) + (list % 'const %2)))) + + (should (equal (##list %2 'const %) + (lambda (% %2) + (list %2 'const %)))) + + (should (equal (##list % %2 %3 %4 %5 %6 %7 %8 %9) + (lambda (% %2 %3 %4 %5 %6 %7 %8 %9) + (list % %2 %3 %4 %5 %6 %7 %8 %9)))) + + (should (equal (##list % %2 % %3 %5 %4 %6 %7 %9 %8) + (lambda (% %2 %3 %4 %5 %6 %7 %8 %9) + (list % %2 % %3 %5 %4 %6 %7 %9 %8)))) + ) + +(ert-deftest llama-test-402-abbrev-optional nil + ;; llama-test-102-basic-optional(s/&1/&/) + + (should (equal (##list &1) + (lambda (&optional &1) + (list &1)))) + + (should (equal (##list % &2) + (lambda (% &optional &2) + (list % &2)))) + + (should (equal (##list %2 % &4 &3) + (lambda ( % %2 &optional &3 &4) + (list %2 % &4 &3)))) + ) + +(ert-deftest llama-test-501-function-position nil + + (should (equal (##+ (% %2 2) %1) + (lambda (%1 %2) + (+ (% %2 2) %1)))) + + (should (equal (##+ (* %2 2) %) + (lambda (% %2) + (+ (* %2 2) %)))) + + (should (equal (##% %2 2) + (lambda (_%1 %2) + (% %2 2)))) + + (should (equal (##* %1 2) + (lambda (%1) + (* %1 2)))) + + (should (equal (##% %2 %1) + (lambda (%1 %2) + (% %2 %1)))) + ) + +(defmacro llama-test--flatten (expr) + (when (vectorp expr) + (setq expr (mapcan (lambda (e) + (if (vectorp e) (append e ()) (list e))) + (append expr ())))) + (let ((body ())) + (while expr + (if (listp expr) (push (pop expr) body) (push expr body) (setq expr nil))) + (cons 'list (nreverse body)))) + +(ert-deftest llama-test-502-vector nil + + ;; Real world example: (##-let [val %1] ...). + + (should (equal (##llama-test--flatten [[1 %1]]) + (lambda (%1) + (llama-test--flatten [[1 %1]])))) + + (should (equal (##llama-test--flatten [%2 [%1]]) + (lambda (%1 %2) + (llama-test--flatten [%2 [%1]])))) + + (should (equal (##llama-test--flatten [%1 _%2 %3]) + (lambda (%1 _%2 %3) + (llama-test--flatten [%1 %3])))) + ) + +(ert-deftest llama-test-502-dotted nil + + ;; Real world example: ???. + + (should (equal (##llama-test--flatten (%1 . %2)) + (lambda (%1 %2) + (llama-test--flatten (%1 . %2))))) + + (should (equal (##llama-test--flatten (%1 %2 . %3)) + (lambda (%1 %2 %3) + (llama-test--flatten (%1 %2 . %3))))) + + (should (equal (##llama-test--flatten (%1 _%2 . %3)) + (lambda (%1 _%2 %3) + (llama-test--flatten (%1 . %3))))) + + (should (equal (##llama-test--flatten (%1 _%2 %3 . %4)) + (lambda (%1 _%2 %3 %4) + (llama-test--flatten (%1 %3 . %4))))) + ) + +(ert-deftest llama-test-503-quoted nil + + (should (equal (##cons %1 '(%2)) + (lambda (%1) + (cons %1 '(%2))))) + ) + +(ert-deftest llama-test-504-backquoted nil + + (should (equal (##list `(,%1 %2 ,%3)) + (lambda (%1 _%2 %3) + (list `(,%1 %2 ,%3))))) + + (should (equal (##list `(,%1 %2 (,%3) ,%4 . ,%5)) + (lambda (%1 _%2 %3 %4 %5) + (list `(,%1 %2 (,%3) ,%4 . ,%5))))) + + (should (equal (##`(,%1 %2 ,%3)) + (lambda (%1 _%2 %3) + `(,%1 %2 ,%3)))) + + (should (equal (##`(,%1 %2 (,%3) ,%4 . ,%5)) + (lambda (%1 _%2 %3 %4 %5) + `(,%1 %2 (,%3) ,%4 . ,%5)))) + + (should (equal (##list `(,% ,@% %)) + (lambda (%) + (list `(,% ,@% %))))) + + (should (equal (##list `(% ,%2)) + (lambda (_%1 %2) + (list `(% ,%2))))) + + (should (equal (##list `(,@%1 %2 ,%3 (,@%3 ,%1))) + (lambda (%1 _%2 %3) + (list `(,@%1 %2 ,%3 (,@%3 ,%1)))))) + ) + +(ert-deftest llama-test-701-llama nil + + (should (equal (llama list %1) + (lambda (%1) + (list %1)))) + + (should (equal (llama list %1 %1) + (lambda (%1) + (list %1 %1)))) + + (should (equal (llama list %1 %2) + (lambda (%1 %2) + (list %1 %2)))) + + (should (equal (llama list %1 (llama list %)) + (lambda (%1) + (list %1 (lambda (%) (list %)))))) + ) + +(ert-deftest llama-test-901-errors-first nil + (should-error (##list %1 &1)) + (should-error (##list &1 %1)) + (should-error (##list %1 _%1)) + (should-error (##list _%1 %1)) + (should-error (##list %1 _&1)) + (should-error (##list _&1 %1)) + (should-error (##list %1 %1 &1)) + ) + +(ert-deftest llama-test-801-ambiguity nil + + ;; We cannot know how every special form and macro uses its arguments, + ;; and can therefore not always do the right thing™. However, whatever + ;; we end up doing, font-lock should agree. Here are some noteworthy + ;; examples where our macro expansion and our font-lock agree, but the + ;; author might have intended something else. + + (static-if (>= emacs-major-version 28) ; prevent compiler warnings + (with-no-warnings ; unused arguments + ;; A good example of what we might not want and theoretically could + ;; prevent. However, this can also be prevented by just not going + ;; out of our way to wander into ambiguous territory. While not + ;; impossible, it is unlikely that someone does this accidentally. + (should (equal (##setq % 1) + (lambda (%) + (setq % 1)))) + + ;; We have to fake `-setq' because we don't want to depend on `dash' + ;; and because (equal (lambda () (-setq a 1)) (lambda () (-setq a 1))) + ;; is never true because `-setq' uses `make-symbol'. Mocking that + ;; macro does *not* affect the expansion of `##' into a `lambda'. + (cl-macrolet ((-setq (&rest args) `'(,@args))) + (should (equal (##-setq % 1) + (lambda (%) + (-setq % 1)))) + (should (equal (##-setq (%) '(1)) + (lambda () + (-setq (%) '(1))))) + (should (equal (##-setq [(%)] [(1)]) + (lambda () + (-setq [(%)] [(1)])))) + (should (equal (##-setq [(% %)] [(1 2)]) + (lambda (%) + (-setq [(% %)] [(1 2)])))) + (should (equal (##-setq [(%1)] [(1)]) + (lambda (%1) + (-setq [(%1)] [(1)])))))) + )) + +(ert-deftest llama-test-902-errors-second nil + (should-error (##list %2 &2)) + (should-error (##list &2 %2)) + (should-error (##list %2 _%2)) + (should-error (##list _%2 %2)) + (should-error (##list %2 _&2)) + (should-error (##list _&2 %2)) + (should-error (##list %2 %2 &2)) + ) + +(ert-deftest llama-test-903-errors-abbrev nil + (should-error (##list % &)) + (should-error (##list & %)) + (should-error (##list % _%)) + (should-error (##list _% %)) + (should-error (##list % _&)) + (should-error (##list _& %)) + (should-error (##list % % &)) + (should-error (##list % %1)) + (should-error (##list % _%1)) + (should-error (##list % &1)) + (should-error (##list % _&1)) + (should-error (##list %1 %)) + ) + +(ert-deftest llama-test-904-errors-syntax nil + + ;; ((lambda (%) (+ 1 %)) 2) + ;; results in + ;; Warning: Use of deprecated ((lambda (%) ...) ...) form + ;; but works. + + ;; ((##+ 1 %) 2) + ;; results at compile-time in + ;; Warning: Malformed function ‘(## + 1 %)’ + ;; results at run-time in + ;; Error: invalid-function ((## + 1 %)) + ;; and cannot possibly work. + + ;; Delay macro-expansion for demonstration purposes. + (should-error (eval '((##+ 1 %) 2))) + + ;; This is what one should be doing instead. + (should (equal (funcall (lambda (%) (+ 1 %)) 2) 3)) + (should (equal (funcall (## + 1 %) 2) 3)) + ) + +;; Local Variables: +;; eval: (prettify-symbols-mode -1) +;; indent-tabs-mode: nil +;; End: +;;; llama-tests.el ends here diff --git a/elpa/llama-0.6.2/llama-test.elc b/elpa/llama-0.6.2/llama-test.elc new file mode 100644 index 0000000..06e2298 Binary files /dev/null and b/elpa/llama-0.6.2/llama-test.elc differ diff --git a/elpa/llama-0.6.2/llama.el b/elpa/llama-0.6.2/llama.el new file mode 100644 index 0000000..e42080a --- /dev/null +++ b/elpa/llama-0.6.2/llama.el @@ -0,0 +1,572 @@ +;;; llama.el --- Compact syntax for short lambda -*- lexical-binding:t -*- + +;; Copyright (C) 2020-2025 Jonas Bernoulli + +;; Authors: Jonas Bernoulli +;; Homepage: https://github.com/tarsius/llama +;; Keywords: extensions + +;; Package-Version: 0.6.2 +;; Package-Requires: ((emacs "26.1") (compat "30.0.2.0")) + +;; SPDX-License-Identifier: GPL-3.0-or-later + +;; This file is free software: you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published +;; by the Free Software Foundation, either version 3 of the License, +;; or (at your option) any later version. +;; +;; This file is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. +;; +;; You should have received a copy of the GNU General Public License +;; along with this file. If not, see . + +;;; Commentary: + +;; This package implements a macro named `##', which provides a compact way +;; to write short `lambda' expressions. + +;; The signature of the macro is (## FN &rest BODY) and it expands to a +;; `lambda' expression, which calls the function FN with the arguments BODY +;; and returns the value of that. The arguments of the `lambda' expression +;; are derived from symbols found in BODY. + +;; Each symbol from `%1' through `%9', which appears in an unquoted part +;; of BODY, specifies a mandatory argument. Each symbol from `&1' through +;; `&9', which appears in an unquoted part of BODY, specifies an optional +;; argument. The symbol `&*' specifies extra (`&rest') arguments. + +;; The shorter symbol `%' can be used instead of `%1', but using both in +;; the same expression is not allowed. Likewise `&' can be used instead +;; of `&1'. These shorthands are not recognized in function position. + +;; To support binding forms that use a vector as VARLIST (such as `-let' +;; from the `dash' package), argument symbols are also detected inside of +;; vectors. + +;; The space between `##' and FN can be omitted because `##' is read-syntax +;; for the symbol whose name is the empty string. If you prefer you can +;; place a space there anyway, and if you prefer to not use this somewhat +;; magical symbol at all, you can instead use the alternative name `llama'. + +;; Instead of: +;; +;; (lambda (a &optional _ c &rest d) +;; (foo a (bar c) d)) +;; +;; you can use this macro and write: +;; +;; (##foo %1 (bar &3) &*) +;; +;; which expands to: +;; +;; (lambda (%1 &optional _&2 &3 &rest &*) +;; (foo %1 (bar &3) &*)) + +;; Unused trailing arguments and mandatory unused arguments at the border +;; between mandatory and optional arguments are also supported: +;; +;; (##list %1 _%3 &5 _&6) +;; +;; becomes: +;; +;; (lambda (%1 _%2 _%3 &optional _&4 &5 _&6) +;; (list %1 &5)) +;; +;; Note how `_%3' and `_&6' are removed from the body, because their names +;; begin with an underscore. Also note that `_&4' is optional, unlike the +;; explicitly specified `_%3'. + +;; Consider enabling `llama-fontify-mode' to highlight `##' and its +;; special arguments. + +;;; Code: + +(require 'compat) + +;;;###autoload +(defmacro llama (fn &rest body) + "Expand to a `lambda' expression that wraps around FN and BODY. + +This macro provides a compact way to write short `lambda' expressions. +It expands to a `lambda' expression, which calls the function FN with +arguments BODY and returns its value. The arguments of the `lambda' +expression are derived from symbols found in BODY. + +Each symbol from `%1' through `%9', which appears in an unquoted part +of BODY, specifies a mandatory argument. Each symbol from `&1' through +`&9', which appears in an unquoted part of BODY, specifies an optional +argument. The symbol `&*' specifies extra (`&rest') arguments. + +The shorter symbol `%' can be used instead of `%1', but using both in +the same expression is not allowed. Likewise `&' can be used instead +of `&1'. These shorthands are not recognized in function position. + +To support binding forms that use a vector as VARLIST (such as `-let' +from the `dash' package), argument symbols are also detected inside of +vectors. + +The space between `##' and FN can be omitted because `##' is read-syntax +for the symbol whose name is the empty string. If you prefer you can +place a space there anyway, and if you prefer to not use this somewhat +magical symbol at all, you can instead use the alternative name `llama'. + +Instead of: + + (lambda (a &optional _ c &rest d) + (foo a (bar c) d)) + +you can use this macro and write: + + (##foo %1 (bar &3) &*) + +which expands to: + + (lambda (%1 &optional _&2 &3 &rest &*) + (foo %1 (bar &3) &*)) + +Unused trailing arguments and mandatory unused arguments at the border +between mandatory and optional arguments are also supported: + + (##list %1 _%3 &5 _&6) + +becomes: + + (lambda (%1 _%2 _%3 &optional _&4 &5 _&6) + (list %1 &5)) + +Note how `_%3' and `_&6' are removed from the body, because their names +begin with an underscore. Also note that `_&4' is optional, unlike the +explicitly specified `_%3'. + +Consider enabling `llama-fontify-mode' to highlight `##' and its +special arguments." + (cond ((symbolp fn)) + ((and (eq (car-safe fn) backquote-backquote-symbol) + (not body)) + (setq body (cdr fn)) + (setq fn backquote-backquote-symbol)) + ((signal 'wrong-type-argument + (list 'symbolp backquote-backquote-symbol fn)))) + (let* ((args (make-vector 10 nil)) + (body (cdr (llama--collect (cons fn body) args))) + (rest (aref args 0)) + (args (nreverse (cdr (append args nil)))) + (args (progn (while (and args (null (car args))) + (setq args (cdr args))) + args)) + (pos (length args)) + (opt nil) + (args (mapcar + (lambda (arg) + (if arg + (setq opt (string-match-p "\\`_?&" (symbol-name arg))) + (setq arg (intern (format "_%c%s" (if opt ?& ?%) pos)))) + (setq pos (1- pos)) + arg) + args)) + (opt nil) + (args (mapcar + (lambda (symbol) + (cond + ((string-match-p "\\`_?%" (symbol-name symbol)) + (when opt + (error "`%s' cannot follow optional arguments" symbol)) + (list symbol)) + (opt + (list symbol)) + ((setq opt t) + (list '&optional symbol)))) + (nreverse args)))) + `(lambda + (,@(apply #'nconc args) + ,@(and rest (list '&rest rest))) + (,fn ,@body)))) + +(defalias (intern "") 'llama) +(defalias '\#\# 'llama) + +(defconst llama--unused-argument (make-symbol "llama--unused-argument")) + +(defun llama--collect (expr args &optional fnpos backquoted unquote) + (cond + ((memq (car-safe expr) (list (intern "") 'llama 'quote)) expr) + ((and backquoted (symbolp expr)) expr) + ((and backquoted + (memq (car-safe expr) + (list backquote-unquote-symbol + backquote-splice-symbol))) + (list (car expr) + (llama--collect (cadr expr) args nil nil t))) + ((memq (car-safe expr) + (list backquote-backquote-symbol + backquote-splice-symbol)) + (list (car expr) + (llama--collect (cadr expr) args nil t))) + ((symbolp expr) + (let ((name (symbol-name expr))) + (save-match-data + (cond + ((string-match "\\`\\(_\\)?[%&]\\([1-9*]\\)?\\'" name) + (let* ((pos (match-string 2 name)) + (pos (cond ((equal pos "*") 0) + ((not pos) 1) + ((string-to-number pos)))) + (sym (aref args pos))) + (unless (and fnpos (not unquote) (memq expr '(% &))) + (when (and sym (not (equal expr sym))) + (error "`%s' and `%s' are mutually exclusive" sym expr)) + (aset args pos expr))) + (if (match-string 1 name) + llama--unused-argument + expr)) + (expr))))) + ((or (listp expr) + (vectorp expr)) + (let* ((vectorp (vectorp expr)) + (expr (if vectorp (append expr ()) expr)) + (fnpos (and (not vectorp) + (not backquoted) + (ignore-errors (length expr)))) ;proper-list-p + (ret ())) + (catch t + (while t + (let ((elt (llama--collect (car expr) args fnpos backquoted))) + (unless (eq elt llama--unused-argument) + (push elt ret))) + (setq fnpos nil) + (setq expr (cdr expr)) + (unless (and expr + (listp expr) + (not (eq (car expr) backquote-unquote-symbol))) + (throw t nil)))) + (setq ret (nreverse ret)) + (when expr + (setcdr (last ret) (llama--collect expr args nil backquoted))) + (if vectorp (vconcat ret) ret))) + (expr))) + +;;; Completion + +(define-advice elisp--expect-function-p (:around (fn pos) llama) + "Support function completion directly following `##'." + (or (and (eq (char-before pos) ?#) + (eq (char-before (- pos 1)) ?#)) + (and (eq (char-before pos) ?\s) + (eq (char-before (- pos 1)) ?#) + (eq (char-before (- pos 2)) ?#)) + (funcall fn pos))) + +(define-advice all-completions (:around (fn str table &rest rest) llama) + "Remove empty symbol from completion results if originating from `llama'. + +`##' is the notation for the symbol whose name is the empty string. + (intern \"\") => ## + (symbol-name \\='##) => \"\" + +The `llama' package uses `##' as the name of a macro, which allows +it to be used akin to syntax, without actually being new syntax. +\(`describe-function' won't let you select `##', but because that is an +alias for `llama', you can access the documentation under that name.) + +This advice prevents the empty string from being offered as a completion +candidate when `obarray' or a completion table that internally uses +that is used as TABLE." + (let ((result (apply fn str table rest))) + (if (and (eq obarray table) (equal str "")) + (delete "" result) + result))) + +;;; Fontification + +(defgroup llama () + "Compact syntax for short lambda." + :group 'extensions + :group 'faces + :group 'lisp) + +(defface llama-\#\#-macro '((t :inherit font-lock-function-call-face)) + "Face used for the name of the `##' macro.") + +(defface llama-llama-macro '((t :inherit font-lock-keyword-face)) + "Face used for the name of the `llama' macro.") + +(defface llama-mandatory-argument '((t :inherit font-lock-variable-use-face)) + "Face used for mandatory arguments `%1' through `%9' and `%'.") + +(defface llama-optional-argument '((t :inherit font-lock-type-face)) + "Face used for optional arguments `&1' through `&9', `&' and `&*'.") + +(defface llama-deleted-argument + `((((supports :box t)) + :box ( :line-width ,(if (>= emacs-major-version 28) (cons -1 -1) -1) + :color "red" + :style nil)) + (((supports :underline t)) + :underline "red") + (t + :inherit font-lock-warning-face)) + "Face used for deleted arguments `_%1'...`_%9', `_&1'...`_&9' and `_&*'. +This face is used in addition to one of llama's other argument faces. +Unlike implicit unused arguments (which do not appear in the function +body), these arguments are deleted from the function body during macro +expansion, and the looks of this face should hint at that.") + +(defconst llama-font-lock-keywords-28 + '(("(\\(##\\)" 1 'llama-\#\#-macro) + ("(\\(llama\\)\\_>" 1 'llama-llama-macro) + ("\\_<\\(?:_?%[1-9]?\\)\\_>" + 0 (llama--maybe-face 'llama-mandatory-argument)) + ("\\_<\\(?:_?&[1-9*]?\\)\\_>" + 0 (llama--maybe-face 'llama-optional-argument)) + ("\\_<\\(?:_\\(?:%[1-9]?\\|&[1-9*]?\\)\\)\\_>" + 0 'llama-deleted-argument prepend))) + +(defconst llama-font-lock-keywords-29 + `(("\\_<\\(&[1-9*]?\\)\\_>" 1 'default) + (,(apply-partially #'llama--match-and-fontify "(\\(##\\)") + 1 'llama-\#\#-macro) + (,(apply-partially #'llama--match-and-fontify "(\\(llama\\_>\\)") + 1 'llama-llama-macro))) + +(defvar llama-font-lock-keywords + (if (fboundp 'read-positioning-symbols) + llama-font-lock-keywords-29 + llama-font-lock-keywords-28)) + +(defun llama--maybe-face (face) + (and (not (and (member (match-string 0) '("%" "&")) + (and-let* ((beg (ignore-errors + (scan-lists (match-beginning 0) -1 1)))) + (string-match-p "\\`\\(##\\|llama\\_>\\)?[\s\t\n\r]*\\'" + (buffer-substring-no-properties + (1+ beg) (match-beginning 0)))))) + face)) + +(defun llama--match-and-fontify (re end) + (static-if (fboundp 'bare-symbol) + (and (re-search-forward re end t) + (prog1 t + (save-excursion + (goto-char (match-beginning 0)) + (when-let (((save-match-data (not (nth 8 (syntax-ppss))))) + (expr (ignore-errors + (read-positioning-symbols (current-buffer))))) + (put-text-property (match-beginning 0) (point) + 'font-lock-multiline t) + (llama--fontify (cdr expr) nil nil t))))) + (list re end))) ; Silence compiler. + +(defun llama--fontify (expr &optional fnpos backquoted top) + (static-if (fboundp 'bare-symbol) + (cond + ((null expr) expr) + ((eq (car-safe expr) 'quote)) + ((eq (ignore-errors (bare-symbol (car-safe expr))) 'quote)) + ((and (memq (ignore-errors (bare-symbol (car-safe expr))) + (list (intern "") 'llama)) + (not top))) + ((and backquoted (symbol-with-pos-p expr))) + ((and backquoted + (memq (car-safe expr) + (list backquote-unquote-symbol + backquote-splice-symbol))) + (llama--fontify expr)) + ((symbol-with-pos-p expr) + (save-match-data + (when-let* + ((name (symbol-name (bare-symbol expr))) + (face (cond + ((and (string-match + "\\_<\\(?:\\(_\\)?%\\([1-9]\\)?\\)\\_>" name) + (or (not fnpos) (match-end 2))) + 'llama-mandatory-argument) + ((and (string-match + "\\_<\\(?:\\(_\\)?&\\([1-9*]\\)?\\)\\_>" name) + (or (not fnpos) (match-end 2))) + 'llama-optional-argument)))) + (when (match-end 1) + (setq face (list 'llama-deleted-argument face))) + (let ((beg (symbol-with-pos-pos expr))) + (put-text-property + beg (save-excursion (goto-char beg) (forward-symbol 1)) + 'face face))))) + ((or (listp expr) + (vectorp expr)) + (let* ((vectorp (vectorp expr)) + (expr (if vectorp (append expr ()) expr)) + (fnpos (and (not vectorp) + (not backquoted) + (ignore-errors (length expr))))) + (catch t + (while t + (cond ((eq (car expr) backquote-backquote-symbol) + (setq expr (cdr expr)) + (llama--fontify (car expr) t t)) + ((llama--fontify (car expr) fnpos backquoted))) + (setq fnpos nil) + (setq expr (cdr expr)) + (unless (and expr + (listp expr) + (not (eq (car expr) backquote-unquote-symbol))) + (throw t nil)))) + (when expr + (llama--fontify expr fnpos)))))) + (list expr fnpos backquoted top)) ; Silence compiler. + +(defvar llama-fontify-mode-lighter nil) + +;;;###autoload +(define-minor-mode llama-fontify-mode + "In Emacs Lisp mode, highlight the `##' macro and its special arguments." + :lighter llama-fontify-mode-lighter + :global t + (cond + (llama-fontify-mode + (advice-add 'lisp--el-match-keyword :override + #'lisp--el-match-keyword@llama '((depth . -80))) + (advice-add 'elisp-mode-syntax-propertize :override + #'elisp-mode-syntax-propertize@llama) + (add-hook 'emacs-lisp-mode-hook #'llama--add-font-lock-keywords)) + (t + (advice-remove 'lisp--el-match-keyword + #'lisp--el-match-keyword@llama) + (advice-remove 'elisp-mode-syntax-propertize + #'elisp-mode-syntax-propertize@llama) + (remove-hook 'emacs-lisp-mode-hook #'llama--add-font-lock-keywords))) + (dolist (buffer (buffer-list)) + (with-current-buffer buffer + (when (derived-mode-p 'emacs-lisp-mode) + (if llama-fontify-mode + (font-lock-add-keywords nil llama-font-lock-keywords) + (font-lock-remove-keywords nil llama-font-lock-keywords)) + (font-lock-flush))))) + +(defun llama--add-font-lock-keywords () + (font-lock-add-keywords nil llama-font-lock-keywords)) + +(define-obsolete-function-alias 'global-llama-fontify-mode + #'llama-fontify-mode "Llama 0.6.2") + +(defun lisp--el-match-keyword@llama (limit) + "Highlight symbols following \"(##\" the same as if they followed \"(\"." + (catch 'found + (while (re-search-forward + (concat "(\\(?:## ?\\)?\\(" + (static-if (get 'lisp-mode-symbol 'rx-definition) ;>= 29.1 + (rx lisp-mode-symbol) + lisp-mode-symbol-regexp) + "\\)\\_>") + limit t) + (let ((sym (intern-soft (match-string 1)))) + (when (and (or (special-form-p sym) + (macrop sym) + (and (bound-and-true-p morlock-mode) + ;; Same as in advice of `morlock' package. + (get sym 'morlock-font-lock-keyword))) + (not (get sym 'no-font-lock-keyword)) + (static-if (fboundp 'lisp--el-funcall-position-p) ;>= 28.1 + (lisp--el-funcall-position-p (match-beginning 0)) + (not (lisp--el-non-funcall-position-p + (match-beginning 0))))) + (throw 'found t)))))) + +(defun elisp-mode-syntax-propertize@llama (start end) + ;; Synced with Emacs up to 6b9510d94f814cacf43793dce76250b5f7e6f64a. + "Highlight `##' as the symbol which it is." + (goto-char start) + (let ((case-fold-search nil)) + (funcall + (syntax-propertize-rules + ;; Empty symbol. + ;; {{ Comment out to prevent the `##' from becoming part of + ;; the following symbol when there is no space in between. + ;; ("##" (0 (unless (nth 8 (syntax-ppss)) + ;; (string-to-syntax "_")))) + ;; }} + ;; {{ As for other symbols, use `font-lock-constant-face' in + ;; docstrings and comments. + ("##" (0 (when (nth 8 (syntax-ppss)) + (string-to-syntax "_")))) + ;; }} + ;; {{ Preserve this part, even though it is absent from + ;; this function in 29.1; backporting it by association. + ;; Prevent the @ from becoming part of a following symbol. + (",@" (0 (unless (nth 8 (syntax-ppss)) + (string-to-syntax "'")))) + ;; }} + ;; Unicode character names. (The longest name is 88 characters + ;; long.) + ("\\?\\\\N{[-A-Za-z0-9 ]\\{,100\\}}" + (0 (unless (nth 8 (syntax-ppss)) + (string-to-syntax "_")))) + ((rx "#" (or (seq (group-n 1 "&" (+ digit)) ?\") ; Bool-vector. + (seq (group-n 1 "s") "(") ; Record. + (seq (group-n 1 (+ "^")) "["))) ; Char-table. + (1 (unless (save-excursion (nth 8 (syntax-ppss (match-beginning 0)))) + (string-to-syntax "'"))))) + start end))) + +;;; Partial applications + +(defun llama--left-apply-partially (fn &rest args) + "Return a function that is a partial application of FN to ARGS. + +ARGS is a list of the first N arguments to pass to FN. The result +is a new function which does the same as FN, except that the first N +arguments are fixed at the values with which this function was called. + +See also `llama--right-apply-partially', which instead fixes the last +N arguments. + +These functions are intended to be used using the names `partial' and +`rpartial'. To be able to use these shorthands in a file, you must set +the file-local value of `read-symbols-shorthands', which was added in +Emacs 28.1. For an example see the end of file \"llama.el\". + +This is an alternative to `apply-partially', whose name is too long." + (declare (pure t) (side-effect-free error-free)) + (lambda (&rest args2) + (apply fn (append args args2)))) + +(defun llama--right-apply-partially (fn &rest args) + "Return a function that is a right partial application of FN to ARGS. + +ARGS is a list of the last N arguments to pass to FN. The result +is a new function which does the same as FN, except that the last N +arguments are fixed at the values with which this function was called. + +See also `llama--left-apply-partially', which instead fixes the first +N arguments. + +These functions are intended to be used using the names `rpartial' and +`partial'. To be able to use these shorthands in a file, you must set +the file-local value of `read-symbols-shorthands', which was added in +Emacs 28.1. For an example see the end of file \"llama.el\"." + (declare (pure t) (side-effect-free error-free)) + (lambda (&rest args2) + (apply fn (append args2 args)))) + +;; An example of how one would use these functions: +;; +;; (list (funcall (partial (lambda (a b) (list a b)) 'fixed) 'after) +;; (funcall (rpartial (lambda (a b) (list a b)) 'fixed) 'before)) + +;; An example of the configuration that is necessary to enable this: +;; +;; Local Variables: +;; indent-tabs-mode: nil +;; read-symbol-shorthands: ( +;; ("partial" . "llama--left-apply-partially") +;; ("rpartial" . "llama--right-apply-partially")) +;; End: +;; +;; Do not set `read-symbol-shorthands' in the ".dir-locals.el" +;; file, because that does not work for uncompiled libraries. + +(provide 'llama) + +;;; llama.el ends here diff --git a/elpa/llama-0.6.2/llama.elc b/elpa/llama-0.6.2/llama.elc new file mode 100644 index 0000000..04abe5b Binary files /dev/null and b/elpa/llama-0.6.2/llama.elc differ -- cgit v1.2.3