Imbuing text with meaning
Some of the most important meanings that you can imbue into text, in my opinion, are:
- Symbols to label the intended "thing" that region of text is supposed to represent
- Data structures representing the structured concrete syntax tree of the annotated text, to easily maintain an identity between the two and retrieve it
- Context or related pieces of data, whether textual or structured
- Hypertext links
For a concrete example of the first, the package Marginalia looks for any lines annotated with the file symbol in the minibuffer, and uses those lines as paths to look up file information, which it then adds as further metadata to those lines. This means that anything that provides completions in the minibuffer, independent of Marginalia knowing about the specifics of that code, or that code even needing to know about Marginalia directly, can add useful metadata about the files it is offering to the user to choose from just by encoding the semantics of the text lines it is presenting as suggestions to the user, like so:
(completing-read-default "Note file: "
(let ((files (directory-files-recursively quake-org-home-directory ".*.org")))
(lambda (str pred flag)
(pcase flag
('metadata `(metadata (category . file)))
(_ (all-completions str files pred))))))
Imbuing meaning, especially in the form of hypertext links, is a common pattern in Emacs, from grep-mode to compilation-mode but for a powerful example of the benefit of the latter three points, just look at org-mode, which is able to take plain text and give it all of these extremely highly structured and interactive and automated, almost GUI or structural editing style features for manipulation, while maintaining an identity between what the program is seeing and doing, and plain text notation that can fully allow it to recreate all of the information necessary to manipulate and understand the document, is the fact that org mode is able to maintain a full parse tree of the document with references to certain positions in the text, but also annotate the text itself with references to that parse tree, thus meaning there's two way communication – when the user inspects or edits some part of the plain text, it's easy to get the structural and semantic meaning of that part of the text and manipulate it for them to produce new text.
There's also things like the incredible Hyperbole and Embark packages, which have the ability to read and use text already imbued with meaning, but also use plain-text patterns to imbue text that wasn't intentionally imbued with meaning with new meaning, bringing this whole concept full circle and making the entire Emacs environment just that much more powerful.