{"id":13894840,"url":"https://github.com/colonelpanic8/emit","last_synced_at":"2026-03-16T22:03:57.243Z","repository":{"id":142768874,"uuid":"65590778","full_name":"colonelpanic8/emit","owner":"colonelpanic8","description":null,"archived":false,"fork":false,"pushed_at":"2023-08-14T17:40:10.000Z","size":23,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-19T13:45:36.114Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Emacs Lisp","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/colonelpanic8.png","metadata":{"files":{"readme":"README.org","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2016-08-13T00:19:00.000Z","updated_at":"2023-07-28T23:08:44.000Z","dependencies_parsed_at":"2023-08-09T23:43:38.099Z","dependency_job_id":"a0ecec0e-4415-4a2f-b8fd-c24b9c829a64","html_url":"https://github.com/colonelpanic8/emit","commit_stats":null,"previous_names":["colonelpanic8/emit"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/colonelpanic8%2Femit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/colonelpanic8%2Femit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/colonelpanic8%2Femit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/colonelpanic8%2Femit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/colonelpanic8","download_url":"https://codeload.github.com/colonelpanic8/emit/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243293795,"owners_count":20268142,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-06T18:01:48.099Z","updated_at":"2025-12-28T22:27:43.123Z","avatar_url":"https://github.com/colonelpanic8.png","language":"Emacs Lisp","funding_links":[],"categories":["Emacs Lisp"],"sub_categories":[],"readme":"* emit\nemit (*EM* acs *I* nit *T* ools) is a collection of functions and macros that are generally useful for the configuration of emacs.\n* Installation\n\nInstall from MELPA (coming soon) with ~M-x package-install emit~. See the [[https://github.com/milkypostman/melpa][melpa repository]] for details about how to set up MELPA if you have not already done so.\n* Explanation/Examples\n** Prefix Selector\n~emit-prefix-selector~ produces an interactive function which will dispatch calls to other interactive functions based on the value of the prefix argument. Invoked normally the function built by ~emit-prefix-selector~ will call the first function that was provided, with one ~universal-argument~ keypress it will call the second function, with two the third, and so on.\n*** Example\n#+BEGIN_SRC emacs-lisp\n(emit-prefix-selector imalison:multi-line\n  multi-line\n  multi-line-single-line\n  imalison:multi-line-skip-fill\n  imalison:multi-line-fill\n  imalison:multi-line-fill-column)\n#+END_SRC\nexpands to:\n#+BEGIN_SRC emacs-lisp\n(defalias 'imalison:multi-line\n  (lambda\n    (arg)\n    \"Call one of `multi-line', `multi-line-single-line', `imalison:multi-line-skip-fill', `imalison:multi-line-fill', `imalison:multi-line-fill-column' depending the prefix argument.\nCall `multi-line' by default.\"\n    (interactive \"P\")\n    (setq arg\n          (emit-interpret-prefix-as-number arg))\n    (let\n        ((selection\n          (pcase arg\n            (0 multi-line)\n            (1 multi-line-single-line)\n            (2 imalison:multi-line-skip-fill)\n            (3 imalison:multi-line-fill)\n            (4 imalison:multi-line-fill-column)\n            (_ 'multi-line))))\n      (setq current-prefix-arg nil)\n      (call-interactively selection))))\n#+END_SRC\n** Named Builder\n~emit-named-builder-builder~ is a macro that operates on existing macros that produce anonymous lambda functions. It produces a new macro whose name is given by the first argument to ~emit-named-builder-builder~ which has identical behavior to the macro passed as its second argument, except that the new macro takes an additional argument before all the other arguments that will be the alias for the new function it produces.\n\n~emit-named-builder~ is a convenience macro that only takes the name of the new macro, with the assumption that the anonymous function from which to build the naming macro has the same name with the suffix in ~emit-named-builder-suffix~.\n*** Example\nThis call\n#+BEGIN_SRC emacs-lisp\n(emit-named-builder emit-prefix-selector)\n#+END_SRC\n\nexpands to:\n#+BEGIN_SRC emacs-lisp\n(progn\n  (defalias 'emit-prefix-selector\n    (cons 'macro\n          (function\n           (lambda\n             (function-name \u0026rest args)\n             (cons 'emit-named-build\n                   (cons function-name\n                         (cons 'emit-prefix-selector-fn args)))))))\n  (put 'emit-prefix-selector-fn 'lisp-indent-function 1))\n#+END_SRC\n\nwhich is also the expansion of:\n\n#+BEGIN_SRC emacs-lisp\n(progn\n  (defmacro emit-prefix-selector (function-name \u0026rest args)\n    `(emit-named-build ,function-name emit-prefix-selector-fn ,@args))\n  (put 'emit-prefix-selector-fn 'lisp-indent-function 1))\n#+END_SRC\n** Compose\n\n~emit-compose~ (and its anonymous form ~emit-compose-fn~) compose functions OR macros in the most syntactically simple way possible. In most cases this results in very obvious expantions.\n\nThe following compose invocation:\n\n#+BEGIN_SRC emacs-lisp\n(emit-compose-fn intern car car)\n#+END_SRC\n\nexpands much as you would expect:\n\n#+BEGIN_SRC emacs-lisp\n(function\n (lambda\n   (arg1)\n   \"The composition of (intern car car)\"\n   (intern\n    (car\n     (car arg1)))))\n#+END_SRC\n\nthe newly produced lambda will usually directly inherit the signature of the function deepest in the composition. As an example:\n\n#+BEGIN_SRC emacs-lisp\n(defun add-one (an-arg \u0026optional unused-arg)\n  (+ 1 an-arg))\n\n(emit-compose-fn - add-one)\n#+END_SRC\n\nexpands to:\n\n#+BEGIN_SRC emacs-lisp\n(function\n (lambda\n   (an-arg \u0026optional unused-arg)\n   \"The composition of (- add-one)\"\n   (-\n    (add-one an-arg unused-arg))))\n#+END_SRC\n\nWhen the last function in the composition takes variadic arguments, this DOES NOT happen:\n\n#+BEGIN_SRC emacs-lisp\n(emit-compose add-and-make-negative - +)\n#+END_SRC\n\nexpands to:\n\n#+BEGIN_SRC emacs-lisp\n(defalias 'add-and-make-negative\n  (function\n   (lambda\n     (\u0026rest args)\n     \"The composition of (- +)\"\n     (-\n      (#[128 \"\\302\\300\\303\\301\u0004\\\"\\\"\\207\"\n             [apply\n              (+)\n              apply append]\n             6 \"\n\n(fn \u0026rest ARGS2)\"]\n       args)))))\n#+END_SRC\n\nThe hideous mess that you see after the call to ~-~ is a partial application of apply to ~+~ which allows the argument list that comes in as args to be interpreted appropriately as an argument list.\n\n~emit-compose~ will inherit the interactive form of the first function called in the composition. See that:\n#+BEGIN_SRC emacs-lisp\n(emit-compose version-as-list list version)\n#+END_SRC\nexpands to:\n#+BEGIN_SRC emacs-lisp\n(defalias 'version-as-list\n  (function\n   (lambda\n     (\u0026optional here)\n     \"The composition of (list version)\"\n     (interactive \"P\")\n     (list\n      (version here)))))\n#+END_SRC\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcolonelpanic8%2Femit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcolonelpanic8%2Femit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcolonelpanic8%2Femit/lists"}