{"id":22859787,"url":"https://github.com/palletops/lein-shorthand","last_synced_at":"2025-12-12T01:19:24.705Z","repository":{"id":20962253,"uuid":"24250977","full_name":"palletops/lein-shorthand","owner":"palletops","description":"Inject clojure vars into namespaces for use in the REPL","archived":false,"fork":false,"pushed_at":"2017-12-02T13:21:10.000Z","size":40,"stargazers_count":42,"open_issues_count":3,"forks_count":3,"subscribers_count":6,"default_branch":"develop","last_synced_at":"2024-11-29T03:42:55.388Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Clojure","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"epl-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/palletops.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-09-20T01:48:53.000Z","updated_at":"2023-12-27T07:45:12.000Z","dependencies_parsed_at":"2022-07-25T08:30:06.655Z","dependency_job_id":null,"html_url":"https://github.com/palletops/lein-shorthand","commit_stats":null,"previous_names":["palletops/lein-inject"],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/palletops%2Flein-shorthand","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/palletops%2Flein-shorthand/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/palletops%2Flein-shorthand/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/palletops%2Flein-shorthand/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/palletops","download_url":"https://codeload.github.com/palletops/lein-shorthand/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":229276935,"owners_count":18048085,"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-12-13T09:08:00.561Z","updated_at":"2025-10-22T02:10:34.977Z","avatar_url":"https://github.com/palletops.png","language":"Clojure","funding_links":[],"categories":["Lein"],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/palletops/lein-shorthand.svg?branch=develop)](https://travis-ci.org/palletops/lein-shorthand)\n\n# lein-shorthand\n\nA leiningen plugin to create clojure namespaces with short names, so\nyou can easily call utility functions in the REPL using fully\nqualified symbols.\n\nIn the repl, there are functions that you always want to have handy,\nno matter which namespace you are in.  One way of achieving this is to\nput these functions into a namespace with a short name, like `.`, so\nyou can refer to them easily.  The original idea came from Gary\nFredericks, who also wrote [dot-slash][dot-slash], which I discovered\nafter writing this.  Many thanks to Gary for suggesting lein-shorthand\nas the name for this plugin.\n\nThe approach has also been generalized to a library at\n[dot-slash-2](https://github.com/gfredericks/dot-slash-2).\n\n## Usage\n\n**Note that the group-id was changed from `com.palletops`\nto `com.gfredericks` at release `0.4.1`.**\n\nAdd `lein-shorthand` to `:plugins` in the `:user` profile of\n`~/.lein/profiles.clj`:\n\n```clj\n{:user\n  {…\n   :plugins [[com.gfredericks/lein-shorthand \"0.4.1\"]]\n   …}}\n```\n\nYou create shorthand namespaces using the `:shorthand` project key\n(again, in the `:user` profile).  For example to define the `.`\nnamespace with clojure's `pprint` and alembic's `still` function and\n`lein` macro:\n\n```clj\n:shorthand {. [clojure.pprint/pprint\n               alembic.still/distill\n               alembic.still/lein]}\n```\n\nIn the repl you will then be able to use `(./distill\n[[clj-http \"1.0.0.\"]])` to add `clj-http` to your classpath.\n\nYou can also rename symbols:\n\n```clj\n:shorthand {. {pp clojure.pprint/pprint}}\n```\n\nThe `:shorthand` value is a map where the keys are namespace symbols,\nand the values are either a sequence of fully qualified symbols for\nvars you want injected into in the namespace, or a map from\nunqualified symbol, for the name of the function in the target\nnamespace, to the fully qualified symbol of the var it should map to.\n\nBy default `:shorthand` namespaces will eagerly load all the\nnamespaces of vars that you specify, which can increase your REPL\nstart-up time, and increase the number of namespaces that are loaded\nin your REPL but not used in your projects.\n\nYou can make the require of the target namespace happen lazily, on\nfirst use, by using the `:shorthand-fns` and `:shorthand-macros` keys\ninstead of the `:shorthand`.  Since the vars will not be required\nuntil first use, you have to explicitly use the `:shorthand-macros`\nkey for macros as `lein-shorthand` has no other way of knowing that it\nshould add `:macro` metadata to these vars.\n\nIf you prefer, you can use `:shorthand` and add metadata to the\nsymbols that you wish to use lazy require with.\n\n```clj\n:shorthand {. [clojure.pprint/pprint\n               ^:lazy alembic.still/distill\n               ^:lazy ^:macro alembic.still/lein]}\n```\n\n## How it works\n\n`:shorthand` defines vars in the target namespace.  The vars values\nare set to the vars resolved by the specified symbols.  The namespace\nof the var is eagerly required when the function is defined.  This\nworks with functions, macros and protocol functions.\n\n`:shorthand-fns`, `:shorthand-macros` and symbols annotated with\n`:lazy` metadata in the `:shorthand` key, define functions and macros\nin the target namespace, that resolve the var to inject, and replaces\nitself with that var.  This means that the injected function isn't\nactually required until it is used.  Since the source var is not\navailable when the function is defined, you have to explicitly specify\nwhich symbols are macros.\n\nThe shothand vars always tracks the target var.\n\n## Differences with dot-slash\n\n`lein-shorthand` does not add anything to your classpath.\n\n`dot-slash` adds a dependency on `potemkin` to your project's\nclasspath in order to propagate var updates to the injected\nvars. `lein-shorthand` achieves the same effect by using the source var\nas the value of the injected var, without `deref`'ing it.\n\n`lein-shorthand` uses the `:injections` key and can be composed using\nmultiple profiles, while `dot-slash` uses `[:repl-options :init]`.\n\n## License\n\nCopyright © 2014 Hugo Duncan\n\nDistributed under the Eclipse Public License either version 1.0 or (at\nyour option) any later version.\n\n[dot-slash]:https://github.com/gfredericks/dot-slash \"Gary Fredericks' dot-slash plugin\"\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpalletops%2Flein-shorthand","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpalletops%2Flein-shorthand","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpalletops%2Flein-shorthand/lists"}