Back to the schedule
Previous: Emacs News Highlights
Next: Emacs manuals translation and OmegaT

The True Frownies are the Friends We Made Along the Way: An Anecdote of Emacs's Malleability

Case Duckworth

Q&A: maybe live
Status: Finished
Duration: 19:40

If you have questions and the speaker has not indicated public contact information on this page, please feel free to e-mail us at emacsconf-submit@gnu.org and we'll forward your question to the speaker.

Description

Emacs is well-known for being extremely flexible, programmable, and extensible; in fact, that's probably the biggest reason it's still being used after 40+ years of existence, and even has enough clout to generate an entire conference in its name. In this medium-length presentation, I will add another point to the data set proving Emacs's abilities, by narrating the latest package I made, `frowny.el`, from its conception to its current, nearly-completed state.

I wrote frowny.el to scratch someone else's itch as a joke on IRC, but it has been called "pretty useful, for a joke package." I feel like that encapsulates the spirit of Emacs and that's why I want to present on this topic.

Along the way, I'll discuss just a little of my own history of Emacs, and why I feel it's a great tool for non-technical users to sink their teeth into.

Speaker information

Other notes

  • Compulsively C-q anything electric. Don't need a hook when you've got one in your brain.
  • Does frowny work with ;)
  • TBH you should transform it into a patch for electric-pair-mode
  • So I want to contribute to Emacs, but I don't know enough elisp. Perhaps I could contribute some documentation? But I have no idea what that would be...
  • From the speaker: i'd love ot hear more about licensing, basically i don't care how my stuff is used at all
  • Why host it on GitHub? or codeberg.org, or sr.ht, or (non-)GNU savannah, or your own server
  • do you have a personal site? Feedback:

  • These kinds of talks are real fun, great job!

  • For real though, I love the path you took to get to where you are. It's super relatable and I've loved hearing about it.
  • These ‘how I got suckered into programming emacs by [hilariously trivial thing]’ are always fun.
  • frowny.el shows how writing a package can help learn things---all sorts of things to consider and lots of "aha!" moments

Transcript

Hi everyone! My name is Case Duckworth and I've been using Emacs for about a year and a half. If you do the math, you'll see that was pretty soon after the pandemic hit us in the U.S. While I was busy making bread and walking my dogs, trying not to drive myself crazy in the house, I tried Emacs again. I don't know if I was successful in that, going crazy... I mean, I still use Emacs. But I have been able to enjoy the infinitely-malleable, immensely enjoyable, and sublimely parenthetical world of Emacs the editor, the community, and of course, the Lisp language.

[00:00:39.470] So. And in this I'm going to explore just a little anecdote of that, a little nugget of what I think makes Emacs so great, using the lens of a package that I wrote about a month ago now called frowny.el. So yeah, let's go ahead and jump in.

[00:01:01.570] So, before the beginning, I want to talk about my very beginning with Linux. I first installed Linux for the first time as a freshman in college, way back in 2008. I don't know if you were around, but 2008 was not the year of the Linux desktop. WiFi was weird. Sound was weird. Everything was odd and strange and weird. I mean, it wasn't good. So, at that time, I knew absolutely nothing about anything. I installed this terrible distro called gOS. I always forget what it's called and then I looked it up. And this is what I looked at when I signed in. It wasn't good. I think it was trying to integrate better with Google tools? So I was, like, oh, yeah, you know, Gmail and Google Calendar, so this will have it all there. Anyway, the company's defunct now and it's pretty obvious why. It was really bad. So I thought to myself, I'll delete the partition. Easy peasy. So I did, and I rebooted, and the Master Boot Record was gone, so I couldn't boot Windows, and it was all, bleah, and I was like, oh, shit, I have to do my schoolwork.

[00:02:24.536] So I thought I was terribly hosed so I just installed Linux. I think I installed Crunchbang Linux first. It looked like this. It's not super exciting. It was an Openbox-based, Debian-based distro run by this one guy out in England. It was great. I really enjoyed it. The forums were amazing. It still kind of lives on through a project called BunsenLabs so go check them out if you want. It was a good time. Anyway. I was using that for a long time, and, you know, probably familiar to many of you, I hopped around from distro to distro, from WM to DE, just on and on and on, trying different things.

[00:03:10.270] I'm not a programmer. I actually went to school for English writing, and so I learned programming mostly from configuring different window managers. I learned Lua with AwesomeWM. I learned Haskell with Xmonad. Sort of Haskell. I mean, I liked Haskell. I like Haskell a lot, at least the syntax. It looks like words. You can define functions multiple times for different inputs. It has that really great pattern matching. The thing I really didn't get was monads. What is a monad? Is it a burrito? Is it a box? Is it a burrito inside of a box? Is it a box inside of a burrito? Is there a cat involved, or a superposition of such? I don't know. Anyway, it got confusing. That's really where I lost me. Again, you know, if you like Haskell, if you write Haskell, more power to you. It didn't fit my brain right. So that was that, but it kinda ruined me for a lot of other programming languages, because the functional style I really get. That part I did get. And stuff like Python, really, object orientation... I would always get way too into classes and figuring out this and that. It just didn't work for me. I was kind of floating. Learned Bash, which is, you know, Bash. It's fine, but it's Bash. It wasn't great either. Anyway. That was six years or so, just kind of did that, right.

[00:04:52.936] And yes, I was using Vim. I mean... Keeps you clean, right? I'm just kidding. I was using Vim, the editor. It was fine. It was great. I mean... Emacs and Vim, they go head to head because they're both 40 years old. They both are super powerful. They both have their own paradigms. If you get into it, then it's like powpowpow, you're doing all this stuff it's great. I wrote some plugins with Vim, a couple of themes, this and that, but you know, VimScript is not great. I think one of the common criticisms of Elisp it's like, oh, it's this weird kind of... It's written for (inaudible)... Tell you, it's way less than VimScript is. Oof. Anyway. That, also, really terminal-first, which I used for a long time and then I only think I started noticing now that I'm using Emacs more, like, that terminal-first workflow, again, for my brain, it doesn't super work for me. I always had this Platonic ideal of what a workflow should look like, and I was always working towards it. I would run into this problem and I wouldn't know how to solve it. so I kind of quit. Do something else. I think that's part of why I had so much churn for such a long time. Because at the end of the day, window managing, you're just moving around little boxes on your screen. So I was spinning wheels for a long time. But yes. And it wasn't like it was all bad. Most of this stuff just came out now that I'm thinking about it, now that I'm kind of going through this in my head, like, that part of it wasn't great. I was having a good time. I was still... Open source, I was getting in the community. I was doing all this stuff. It was all great.

[00:06:51.803] But anyway, the pandemic hit, obviously, really hard, last spring, in the US. And here we are, talking about the pandemic in 2021. Can you imagine? So, I didn't lose my job. Thank goodness. But I did... I work for the government, I was sent home for two months. I had all this free time on my hands. I got into baking, I bought a 50-pound bag of flour. I started a bread-themed tilde server, you know, those shared Unix servers all the cool kids talk about? Yeah, it's breadpunk.club, go check it out! Join if you want. Anyway. Yeah.

[00:07:29.770] So I decided to try Emacs again. Kind of on a whim, I think. I don't super remember, but I think I did. I tried Spacemacs. It didn't stick. Spacemacs was trying to be Vim, but enough things didn't fit in with what I was expecting with my Vim workflow. All sorts of plugins that did certain things and I didn't know to just get into Spacemacs. It just didn't work for me.

[00:08:01.070] I tried Emacs. This time, it stuck. I started out just vanilla, basic no init.el, then I wrote an init.el, and then I rewrote my init.el, and then I took my init.el, crumpled it up, threw it in the trash can, wrote it again from scratch. I'm actually currently in the middle of Bankruptcy #8, which I think I really got this time. It's either that or Number 9. So I have 1700-ish commits. I also have like, 3 or 4 .emacs repositories around my various Git hosting platforms that I use. I was on GitHub, GitLab, ~/git... I don't use Git very well. I'm very much amateur in that entire thing.

[00:08:50.003] Anyway, that is all to say I got into it, right. Like, really into it. I was watching Emacs Conference videos. Live. I was reading /r/emacs. I was reading Planet Emacs. I subscribed to both. I have other blogs that I read. All the greats. Everyone who's presenting here, probably. I started watching people on YouTube like Prot, like David Wilson who does System Crafters. I was already on IRC with the tildeverse, and so I hopped over to #emacs on Freenode (remember Freenode?). Anyway, it was a good time. So I was doing all this stuff. And... oh yeah. Right. Anyway, so that's all to say... Frowns. I was on #systemcrafters channel on libera.chat, the channel for the YouTube channel System Crafters by David Wilson. I think he's on later. I'm sure he'll talk about it. I don't know what he's talking about. Anyway, one day we were chatting and this guy alphapapa, who also has written a lot of these packages, said "electric-pair-mode messes up my frowny faces sometimes." You can see here this frowny, what is this... You can see it there on the screen. What is that, right? It's terrifying. What is this? What is that? I don't know. I don't know what that is. And then I said, you know, "I have a hook that disables electric-pair-mode for chat buffers." Which, actually, fun fact, I was lying. Not that that matters. I have a hook. You could have a hook that just disables electric-pair-mode in chat buffers. To which he replied, "Yeah, but I want electric-pair-mode everywhere, except for when I type a frowny face." And this sandwich face. What is that? He said, "I could stop typing frowny faces." And then I said, "Hmm..." And then I said, "I feel like you're in the best position to write a package, like frowny.el," I said as a joke. And then conversation went on, we talked about... made some jokes about Lisp and all that stuff So anyway, went on, went on, and then apparently, 23 minutes later, I had a frowny.el package just wrote up real quick. And yeah. That was it. I said, you know, buddy, anyway...

[00:11:33.070] So now we're going to look at the package that I wrote. frowny.el. It was actually pretty easy. Let's see here. This is it now. I kind of want to go back into... Let's go back to the very beginning. We'll see what we have here. Here's our very first, my very first commit. I already had all of this crap. Oh, I already did have a... I had a defgroup, I had frowny-eyes... This is basically the way I thought it was. You want to insert a frowny face. You type in the colon, or the equal sign, or whatever. for the eyes, and then you type the open parenthesis for the frown. And the problem is that the parenthesis then triggers electric-pair-mode. It's like, oh, no, I got a close parenthesis. So we just short-circuit that whenever there's a thing, a colon or equals sign before, and just insert the thing. Where did it go? That's kind of what I did. So I wrote out... This is it.

[00:12:45.370] This is the whole package. It's one function, one minor mode, one defcustom, and one group. That's it. Super simple. Basically, all it does is it inserts a frowny if it looks back and sees frowny eyes which are up here. The eyes are up here. Colon, equals sign... and then it inserts it or it does a self insert command. That simple. self-insert-command is what electric-pair-mode hooks into. So that's it. And then the minor mode just makes it a minor mode. So that was that. And you know, that worked just fine. That's the thing. It works just fine.

[00:13:35.670] Of course, after that, I had it do a couple of different things. I added a mascot. I had to add a README. I added a global-frowny-mode which was kind of interesting because I had to figure out turn on the frowny mode, I wrote this define-globalized-minor-mode which... is that the one No, that one's not super new. There was another one. Something else that was actually for 28 or 27, and I tried using it at work, where I have Windows and it was 27, so it must have been for 28. Anyway, something didn't work and I had to do all this stuff. Oops, sorry. I added some customization options, made package-lint happy... So yeah, let's see. That's 0.1. This version 0.1 was basically basic information.

[00:14:36.770] So then somebody... I put it on GitHub, good to go. It actually got some traction on Reddit. alphapapa, shout out to you who posted it there. But then I got an issue. Somebody said, hey, could you add smiley support? I was, like, well, I don't really understand why that's important. Well, you know, why not? They had a use case for it, I forget, but they had a use case for it. So, okay, fine. So I added smiley support right here. Oh, and I added some more eyes at some point. Now you have... you can do a tear. You can do a nose. Let's see... I had to change frowny-self-insert to frowny-insert-character, I added frowny-self-insert-frowny right here. I added... I had an obsolete function alias. That was super fun. That was a cool thing to do. I have insert-smiley as well. They're both very similar. They're all still there. I added a keymap. That was pretty much it. And you know, again, super simple, very small. Let me try this again. I added comments and docstrings.

[00:15:58.336] At some point, I decided let me try to make a frowny prog mode that only works in programming modes, that only works in strings and in comments, but... There's still a branch for it, if you want to go check it out. It wasn't super useful, and I think, actually, electric-pair-mode already does that. I'm not a hundred percent sure. I got a pull request from alphapapa, adding HISTORY.org. So you can go read the IRC logs about it. There's... Let's see...

[00:16:29.703] And then just recently, I actually had to add frowny-inhibit-modes because with dired, I kept getting this... I would try to hit open parenthesis which is my dired-hide-details-mode, but it kept saying, hey, it's a read-only buffer. I'm, like, what? Oh yeah! Right! It's Emacs. I can C-h k and then (, and oh, frowny-self-insert. Oh, duh. So I had to add this little frowny-inhibit-modes bit. So now there's a little custom in here. Right now, it just defaults to special-mode. I added dired myself on my config. I might add that as a default as well. I'm going to think about it.

[00:17:15.270] And then, yeah. So now we're at version 0.3, that's where we're at now. I just updated the README with the last one. Basically, lots of functionality, plus this frowny-inhibit-mode, and yeah, now it is just... This is it. This is the whole thing right here. It's pretty short. I think it's a total of 113 lines. But you know what, it's got... It's useful for people, and it's something where I never thought I would write software that people would use. As I said, I'm not a programmer. I'm just this guy. I like using Emacs because I'm kind of a nerd. I like tinkering around and doing things the hard way. I don't... I could use Microsoft Word. I should. I was trying to write this presentation up and my wife said, "Why don't you just write it in Google Docs?" And I said, "I don't want to." I mean, that's really it. Isn't that why we're all here? So yeah, you know, so anyway, that's the story about frowny That's the story about me, my journey to Emacs, my journey to this conference, and the journey of this package. I think it's about done. I'm not sure what else needs to go in there.

[00:18:36.136] If you have any suggestions, pull requests, comments, there's a GitHub right here, frowny.el. Let's see if I can pull it up. frowny.el. I'll put it on (inaudible). That's something I still don't understand. Packages, the whole keywords thing... I'm still confused on that. But yeah. Just requires Emacs 24. That's it. So anyway, I'm not sure if I'm going to be live for questions. I'm recording this, obviously, a bit before, and I will be travelling that weekend, this weekend, when you're watching this, so I'm going to... But right now, I'm recording it, I'm not 100% sure. I will know obviously by then. So maybe I'll talk to you in a moment, maybe not. Otherwise, have a great conference, everybody. I'm really excited to see everyone's talks.

Back to the schedule
Previous: Emacs News Highlights
Next: Emacs manuals translation and OmegaT