An open API service indexing awesome lists of open source software.

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`

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=.