1. 21
    1. 5

      I regularly write Elisp, and a few stylistic points I wanted to comment on:

      • Usage of ido-completing-read instead of completing-read with ido configured to handle it. If you choose to change your completion framework, the “generic” version will make it easier to switch.

      • Binding minor mode commands to C-c [letter]. To quote (elisp) Key Binding Conventions:

        Don’t define ‘C-c LETTER’ as a key in Lisp programs. Sequences consisting of ‘C-c’ and a letter (either upper or lower case) are reserved for users; they are the only sequences reserved for users, so do not block them.

      • Defining anonymous lambda functions to insert text. From (elisp) Key Lookup, if a key is bound to a vector-like type (and a string is one), then it is executed as a macro. Therefore binding a string to a key, will just run the macro that inserts the text verbatim. This should be fine in regular Emacs, might be problematic with Evil or other input changing modes. That being said, since these kinds of macros aren’t pretty either, I’d say the approach is the issue.

      • Writing all the scribe-write-q, scribe-write-c, ... functions. It would either be easier to write a macro that generates these, or a general function that works like self-insert-command. That's the command that is bound to most keys. So pressing awill invokeself-insert-command, that checks last-command-eventto insert whatever key invoked the command. See(elisp) Command Loop Info` for more details. That same mechanism could be used to lookup what expansions a key should have in, eg. an alist. That way the command can be extended more dynamically, and the overall code becomes more maintainable.

      Of course there’s nothing wrong in doing any of this in your personal code. Emacs is about having an environment you can improve and adjust to whatever situation you are in (I correct student submissions at university, and couldn’t imagine doing that without my helpful minor modes), but when writing packages, issues like these should be considered – you never no what customizations you might come in conflict with. Might it be a good example of the “curse of lisp”?

      1. 1

        This is all really great to know, especially since I’m hoping to move from writing this kind of personal-use elisp to more ambitious projects that can be shared with others. Thank you for taking the time to write this.

    2. 3

      Emacs is great at solving niche problems like this, and I feel this power is under-appreciated. Thanks for showing the successive refinements - it’s cool to see how your solution evolved to fit your needs. If you folded in zge’s comments, it would be a great example for people scratching their first itch with emacs.

    3. 1

      Interesting post, but if you’re trying to optimise against RSI, isn’t Emacs… perhaps a strange choice of editor?

      1. 1

        One definitely puts one’s pinky at risk, but at least there’s always evil-mode.