https://github.com/toyboot4e/toy-scheme
Handle custom path schemes (aliases) defined in `schemes.txt`
https://github.com/toyboot4e/toy-scheme
Last synced: 6 months ago
JSON representation
Handle custom path schemes (aliases) defined in `schemes.txt`
- Host: GitHub
- URL: https://github.com/toyboot4e/toy-scheme
- Owner: toyboot4e
- License: mit
- Created: 2021-06-03T09:20:48.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2021-06-05T01:09:33.000Z (about 5 years ago)
- Last Synced: 2025-03-15T23:28:33.399Z (over 1 year ago)
- Language: Emacs Lisp
- Homepage:
- Size: 19.5 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.org
- License: LICENSE
Awesome Lists containing this project
README
* toy-scheme.el
Handle custom local path schemes (aliases) defined in =schemes.txt=
** About
=schemes.txt= is a list of /custom local path schemes/. If you write schemed path in syntax
=:path=, it can be converted to =/path= referring to =schemes.txt=.
** Motivation
=toy-scheme.el= is primary for my game development. While I'm writing files that refer to other
files, I could use relative path, but it was very uncomfortable. So I'm adding /schemed path/ to
my game framework with Emacs editor support.
** Example
Say we have many files in non-flat directories:
#+BEGIN_SRC
assets/
├── map
│ ├── tileset
│ │ └── tileset-1.png
│ ├── tmx
│ │ └── map-data-1.tmx
│ └── tsx
│ └── tileset-1.tsx
└── scripts
└── script1.lisp
#+END_SRC
If we want to refer to =map-data-1.tmx= from =script1.lisp=, we have to write as
=../map/tmx/map-data-1.tmx=. This is not elegant.
Instead, we can write it as =tmx:map-data-1.tmx= if we add =assets/schemes.txt=:
#+BEGIN_SRC
tmx: map/tmx
tsx: map/tsx
tileset: map/tileset
#+END_SRC
Now =tmx:map-data-1.tmx= refers to =assets/map/tmx/map-data-1.tmx=. Much better! Other schemes
(=tsx= and =tileset=) also work.
=toy-scheme.el= adds editor support for this kind of paths; it overrides =find-file-at-point=
with =advice-add=.