947 lines
33 KiB
Plaintext
947 lines
33 KiB
Plaintext
|
|
Episode: 856
|
||
|
|
Title: HPR0856: GNU Emacs 2
|
||
|
|
Source: https://hub.hackerpublicradio.org/ccdn.php?filename=/eps/hpr0856/hpr0856.mp3
|
||
|
|
Transcribed: 2025-10-08 03:38:38
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
Well everyone, this is Clat 2 and this is Hacker Public Radio.
|
||
|
|
This is episode 2 of my intro to Emacs, a mini miniseries.
|
||
|
|
It's a little tiny series because it's only three episodes and we're not really that long
|
||
|
|
and so it's a miniseries, very small series.
|
||
|
|
Plus I'm not trying to sell you anything.
|
||
|
|
I'm going to tell you about Emacs because it is a pretty cool thing.
|
||
|
|
And hopefully you've been able to play around with it a little bit since the last episode
|
||
|
|
in the last episode if you'll recall.
|
||
|
|
I'm sure you do because you've probably been using it all week long or the past couple of days
|
||
|
|
whenever you're hearing this in relation to the first one.
|
||
|
|
You will recall that you learned about Control-X, Control-F for finding a file
|
||
|
|
whether it's new or already existing. That's how you open up your documents in Emacs.
|
||
|
|
You learned about Control-X, Control-F for save and Control-X, Control-C to close.
|
||
|
|
You learned that Emacs in a GUI is actually a good thing.
|
||
|
|
Control-G is a panic button that bails you out of initiating commands that you didn't mean to initiate.
|
||
|
|
And of course you learned just a little tiny bit about the buffer paradigm that Emacs uses,
|
||
|
|
meaning that even though you only see one window,
|
||
|
|
there are actually multiple documents layered on top of each other
|
||
|
|
that you can switch back and forth between with Control-X, B for buffer.
|
||
|
|
So recall also that the mini buffer is that little thin stripe down at the bottom of Emacs window.
|
||
|
|
That's where the interactive stuff gets entered into.
|
||
|
|
So if you're going to Control-X, Control-F to find a file,
|
||
|
|
it's going to ask you in that little mini buffer where that file exists
|
||
|
|
or alternatively if it doesn't exist yet, where it should be saved to.
|
||
|
|
You can just type in the path there.
|
||
|
|
Or if you like the GUI parts better than typing,
|
||
|
|
you can go to the GUI menu up at the top and do a file open or a file new file, whatever.
|
||
|
|
Okay, so today we're going to talk about customization,
|
||
|
|
because I said last time that it was really, really customizable,
|
||
|
|
and it's true, it is.
|
||
|
|
And honestly, that's one of the most fun parts about it,
|
||
|
|
because not everyone works the same way.
|
||
|
|
Everyone doesn't want to use the exact same commands in Emacs,
|
||
|
|
and everyone's not using Emacs for the same activity.
|
||
|
|
Not everyone writes screenplays or grades screenplays on Emacs.
|
||
|
|
Not everyone does dockbook.
|
||
|
|
Not everyone does HTML.
|
||
|
|
You might be doing completely different set of tasks.
|
||
|
|
Or your hands might just be different than mine.
|
||
|
|
Your motor, your muscle memory is different, whatever.
|
||
|
|
You can customize just about anything you want in Emacs.
|
||
|
|
Most of the customization in Emacs can be done through the .emacs file.
|
||
|
|
The .emacs file is almost as famous as Emacs itself, frankly.
|
||
|
|
A .emacs is a V file that is the configuration file for Emacs.
|
||
|
|
It loses in your home directory for all of your personal customizations.
|
||
|
|
And it's one of those things that people tend to kind of collect over the years,
|
||
|
|
and they keep putting new things into their .emacs file,
|
||
|
|
and it just kind of grows and gets bigger and better,
|
||
|
|
and typically you'll want to save yours somewhere.
|
||
|
|
If you have done that much work into getting Emacs,
|
||
|
|
fitting you just so, then you might as well back that .emacs file up.
|
||
|
|
I actually have it backed up on Gatorius,
|
||
|
|
and that way any computer I sit at, if I decide,
|
||
|
|
this is a good computer to do some Emacs stuff in right now,
|
||
|
|
then I just get clone my Emacs config file
|
||
|
|
and the little applications that I typically, the little plugins that I use with Emacs,
|
||
|
|
and I can just pull all of that down,
|
||
|
|
move my .emacs into that home directory as .emacs,
|
||
|
|
and suddenly Emacs is exactly how I want it to be.
|
||
|
|
It's a very, very nice little feature of Emacs, very easy to configure that way.
|
||
|
|
So it's going to be a .emacs file, meaning it's going to be a period,
|
||
|
|
and then the word Emacs, all lowercase,
|
||
|
|
and it needs to be in your home directory.
|
||
|
|
That's where Emacs is going to look for personalization of your environment.
|
||
|
|
The first thing just to get us started,
|
||
|
|
just to see what exactly we're talking about here.
|
||
|
|
Well, I guess you first need to see what won't happen
|
||
|
|
with a set of customizations before I show you the cool stuff that will happen.
|
||
|
|
So, assuming you don't have a .emacs file yet,
|
||
|
|
I do, so I'm going to move mine to .emacs-stash.
|
||
|
|
Now, I'm going to launch Emacs, and this is the default Emacs now,
|
||
|
|
because I just moved my .emacs out of my home directory.
|
||
|
|
So, if you control X, control F to get a new file,
|
||
|
|
and just do some new file like a temp.emacs or something,
|
||
|
|
and enter some text, enter some text.
|
||
|
|
All right.
|
||
|
|
Now, on your word processor at home,
|
||
|
|
what would you do to select that text?
|
||
|
|
Let's say you wanted to copy it, you wanted to paste it,
|
||
|
|
you wanted to cut it,
|
||
|
|
you wanted to do something with that text that you've just entered.
|
||
|
|
How would you do that?
|
||
|
|
Well, you might do it with a mouse,
|
||
|
|
and actually, if you're doing the GUI version,
|
||
|
|
that actually does work.
|
||
|
|
But let's say you're not using the mouse,
|
||
|
|
you're not using the GUI version,
|
||
|
|
or you just don't want to take your hands off the keyboard yet.
|
||
|
|
So, in a normal word processor that we're used to,
|
||
|
|
we would hit the shift key,
|
||
|
|
and then the arrow key,
|
||
|
|
and that would select that text as we pass over it with our arrow key,
|
||
|
|
the shift arrow, that selects text on the fairly modern
|
||
|
|
by comparison newer text editors,
|
||
|
|
newer than Emacs anyway.
|
||
|
|
So, those are conventions,
|
||
|
|
that's the convention that we've gotten used to in modern text editors.
|
||
|
|
It doesn't exist in Emacs,
|
||
|
|
but it can if you want it to.
|
||
|
|
And I don't actually use this feature,
|
||
|
|
so I'm only doing it because it is something that a lot of people
|
||
|
|
do tend to like, I think,
|
||
|
|
and it's also something that will just introduce you to how easy it is
|
||
|
|
to configure. Emacs through.Emacs.
|
||
|
|
So, right now we're going to go back into Emacs,
|
||
|
|
if you're not in it already.
|
||
|
|
Control X, Control F,
|
||
|
|
and I'm going to do it till they slash.Emacs.
|
||
|
|
So, I'm establishing a new.Emacs file for myself.
|
||
|
|
It should be pretty much empty right now,
|
||
|
|
because it doesn't exist.
|
||
|
|
It might exist for you if you ditched the splash screen last time.
|
||
|
|
There might be a custom set faces addition at the top of your.Emacs file
|
||
|
|
that you probably didn't even know you had.
|
||
|
|
So, that's fine.
|
||
|
|
If that's there, don't get rid of it.
|
||
|
|
That's nice.
|
||
|
|
So, just somewhere in this file,
|
||
|
|
put PC-Selection-Mode
|
||
|
|
close for indices.
|
||
|
|
So, that's parent PC-Selection-Mode-Parent.
|
||
|
|
Control X, Control S to save that.
|
||
|
|
And now we can control X, Control C to get out of Emacs,
|
||
|
|
and then relaunch Emacs.
|
||
|
|
And there's a way to do that from the mini-buffer as well without closing,
|
||
|
|
but let's just keep it simple.
|
||
|
|
So, close Emacs and reopen it.
|
||
|
|
And now it should open with its new configuration,
|
||
|
|
your personalized configuration.
|
||
|
|
Control X, Control F to open back up a temp file.
|
||
|
|
It could be the one that you did earlier,
|
||
|
|
or if you didn't save it, that's fine.
|
||
|
|
Point being, grab some text,
|
||
|
|
put your cursor at the beginning of some text,
|
||
|
|
hit the shift key in the arrow key, and look at that.
|
||
|
|
It's selecting text, just like you would normally select text
|
||
|
|
in a newer, more modern text editor.
|
||
|
|
That's obviously a really simple example.
|
||
|
|
And it was simple because I wanted it to be fast
|
||
|
|
so you could see how quick this sort of thing is.
|
||
|
|
And it really is that simple.
|
||
|
|
Customization to your .emacs file takes place.
|
||
|
|
You put in some text into your .emacs file,
|
||
|
|
and you go back into Emacs and it works.
|
||
|
|
It just suddenly is a completely different style of working.
|
||
|
|
So, let's do something a little bit more drastic,
|
||
|
|
a little bit more daring.
|
||
|
|
And that is, of course,
|
||
|
|
because I haven't told you about this yet,
|
||
|
|
but I'm going to tell you about it right now.
|
||
|
|
So, it turns out in Emacs,
|
||
|
|
the whole control C for copy, control X for cut,
|
||
|
|
control V for paste,
|
||
|
|
that doesn't actually work.
|
||
|
|
Weird, huh?
|
||
|
|
Well, Emacs is old.
|
||
|
|
It wasn't around when Microsoft,
|
||
|
|
and I don't know, word perfect,
|
||
|
|
whoever the, you know, the GUI text editors were back then,
|
||
|
|
they hadn't come up with the idea of control C,
|
||
|
|
control X, control V yet.
|
||
|
|
That was not even around yet.
|
||
|
|
Emacs had their own conventions.
|
||
|
|
So, the conventions in Emacs are actually quite nice.
|
||
|
|
I use them all the time.
|
||
|
|
I don't actually use the,
|
||
|
|
what we'll call the new besettings,
|
||
|
|
but I'll tell it to you,
|
||
|
|
but then we'll change it anyway.
|
||
|
|
We'll keep it or not,
|
||
|
|
depending on how you want.
|
||
|
|
So, for selecting,
|
||
|
|
you can do control shift,
|
||
|
|
the number two.
|
||
|
|
So, the at symbol really control,
|
||
|
|
and then the at symbol,
|
||
|
|
or control shift two.
|
||
|
|
Now you're in selection mode,
|
||
|
|
and you can select text.
|
||
|
|
Once you have everything selected that you want,
|
||
|
|
you can either copy it with Alt W,
|
||
|
|
or you can cut it with control W.
|
||
|
|
And then you navigate to wherever you want to dump that,
|
||
|
|
and hit control Y,
|
||
|
|
and that pastes it,
|
||
|
|
or yanks it out of the kill ring.
|
||
|
|
So, that's the way that Emacs typically copies and pastes.
|
||
|
|
If you're daring,
|
||
|
|
you can try to learn that,
|
||
|
|
and remember that.
|
||
|
|
It took me a while.
|
||
|
|
I'd write it down on a little sheet of paper by my computer.
|
||
|
|
I'm not afraid of cheat sheets,
|
||
|
|
and neither should you be,
|
||
|
|
but hey,
|
||
|
|
maybe you're showing this to someone
|
||
|
|
who just doesn't want to have to learn a new text editor.
|
||
|
|
They want some feature that they saw on Emacs
|
||
|
|
that they thought was really cool,
|
||
|
|
but they're not down with the idea of learning new commands
|
||
|
|
for stuff that they consider just a given.
|
||
|
|
If they're editing text,
|
||
|
|
they want control C,
|
||
|
|
control X, control V.
|
||
|
|
That's fine.
|
||
|
|
We can make that happen for them.
|
||
|
|
As of Emacs 22.1.
|
||
|
|
Yeah.
|
||
|
|
Took them 22 versions to add this feature.
|
||
|
|
But as of Emacs 22.1,
|
||
|
|
and hire,
|
||
|
|
there's a mode built in called CUA.
|
||
|
|
I don't know what that stands for,
|
||
|
|
but there you go.
|
||
|
|
It's CuaMode,
|
||
|
|
and if we add this to our .emacs file in our home folder,
|
||
|
|
then we can activate CuaMode,
|
||
|
|
and we can have our standard copy-paste and cut commands.
|
||
|
|
And it works really, really well.
|
||
|
|
Open .emacs back up,
|
||
|
|
control X, control F,
|
||
|
|
and I'm going to .emacs.
|
||
|
|
Of course, you have tabed completion.
|
||
|
|
If you haven't already figured that out,
|
||
|
|
like if I'm going to tilt this slash,
|
||
|
|
I can put .emacs.
|
||
|
|
Now I've got my .emacs.
|
||
|
|
Now I'm going to enter under the PC selection mode.
|
||
|
|
We want the PC selection mode to stay.
|
||
|
|
So under that,
|
||
|
|
the parent Cua-mode space T,
|
||
|
|
as in true,
|
||
|
|
closed parent.
|
||
|
|
Okay, so that activates the mode,
|
||
|
|
and then we're going to set a variable,
|
||
|
|
and setting a quoted variable in E-list
|
||
|
|
or whatever we're in,
|
||
|
|
is setQ,
|
||
|
|
like set quoted variable.
|
||
|
|
So it's parent setQ,
|
||
|
|
space Cua-auto,
|
||
|
|
dash tabify,
|
||
|
|
TABIFY,
|
||
|
|
dash rectangle,
|
||
|
|
space nil,
|
||
|
|
closed parent.
|
||
|
|
I've never used Cua-mode without that,
|
||
|
|
so I have no idea what we just set.
|
||
|
|
Next line,
|
||
|
|
parent transient dash mark,
|
||
|
|
dash mode space 1,
|
||
|
|
closed parent.
|
||
|
|
This simply says that,
|
||
|
|
if something's not highlighted,
|
||
|
|
don't turn Cua-mode on,
|
||
|
|
essentially.
|
||
|
|
And then the final option here,
|
||
|
|
or the variable that we're going to set,
|
||
|
|
is parent setQ,
|
||
|
|
space Cua,
|
||
|
|
dash keep,
|
||
|
|
dash region,
|
||
|
|
dash after,
|
||
|
|
dash copy,
|
||
|
|
space T,
|
||
|
|
closed parent.
|
||
|
|
And what we said there,
|
||
|
|
is that after we select some text,
|
||
|
|
and after we copy it
|
||
|
|
with our new little control C command,
|
||
|
|
or cut it,
|
||
|
|
we stay in Cua-mode,
|
||
|
|
meaning that it's now waiting
|
||
|
|
for us to paste it somewhere.
|
||
|
|
It's not going to take away
|
||
|
|
those special keyboard bindings.
|
||
|
|
And that's kind of handy.
|
||
|
|
And if you save that,
|
||
|
|
and again just close Emax and reopen it,
|
||
|
|
get a new text file up.
|
||
|
|
Since we're here in .emax,
|
||
|
|
making all these changes anyway,
|
||
|
|
we might as well make,
|
||
|
|
yet one more little modification
|
||
|
|
to make it a little bit more,
|
||
|
|
quote unquote, user-friendly.
|
||
|
|
We might also say new,
|
||
|
|
but friendly.
|
||
|
|
And that is, of course,
|
||
|
|
Control-Z.
|
||
|
|
Control-Z on the keyboard
|
||
|
|
doesn't undo, usually,
|
||
|
|
in lots of different programs.
|
||
|
|
And it doesn't,
|
||
|
|
in the standard Emax setup.
|
||
|
|
In Emax, it's Control-X,
|
||
|
|
and then U.
|
||
|
|
Which, really,
|
||
|
|
if you think about it,
|
||
|
|
it makes sense, right?
|
||
|
|
I mean, you're doing a Control-X
|
||
|
|
to get into your command mode,
|
||
|
|
and then U for undo.
|
||
|
|
It's pretty simple.
|
||
|
|
And yet,
|
||
|
|
because the later text editors
|
||
|
|
that came out after Emax,
|
||
|
|
decided it was going to be Control-Z,
|
||
|
|
that's just what it became.
|
||
|
|
So, if you want to change that,
|
||
|
|
and again, this isn't actually something
|
||
|
|
that I do for myself,
|
||
|
|
but I've got it,
|
||
|
|
as a comment,
|
||
|
|
in my standard.emax file,
|
||
|
|
so that if I'm setting it up for someone,
|
||
|
|
I can activate that.
|
||
|
|
So, that would be,
|
||
|
|
well,
|
||
|
|
Paran-global-set-key-space-paran.
|
||
|
|
Yes, this is actually a nested parent.
|
||
|
|
So, it's Paran-global-set-key-space-open-paran.
|
||
|
|
Again, KBD,
|
||
|
|
like Keyboard, KBD-space-double-quote-capital-c-
|
||
|
|
lowercase-z,
|
||
|
|
double-quote-close-the-first-paran-space-single-quote-undue-close-the-paran.
|
||
|
|
So, we've got global-set-key-as-keyboard-phrase-control-z,
|
||
|
|
meaning to launch the...
|
||
|
|
I don't know what they call it,
|
||
|
|
a macro or a command, I guess,
|
||
|
|
that is called undue.
|
||
|
|
The interesting thing about a lot of this stuff
|
||
|
|
that you can do in .emax,
|
||
|
|
you can actually almost...
|
||
|
|
I think of it as reverse-engineering almost.
|
||
|
|
I mean, it's not really,
|
||
|
|
but that's how it feels to me.
|
||
|
|
Because, like,
|
||
|
|
in order to launch some kind of command within emax,
|
||
|
|
the way that you can do that
|
||
|
|
is hit meta-x,
|
||
|
|
which meta is the alt-key on your keyboard,
|
||
|
|
or if your alt-key isn't working,
|
||
|
|
or, you know, like,
|
||
|
|
if you're SSH through some box,
|
||
|
|
and then SSH into another box,
|
||
|
|
and you're all over the place,
|
||
|
|
and your alt-key signal just isn't getting through,
|
||
|
|
or if you're on a Mac,
|
||
|
|
and they double up,
|
||
|
|
they're alt and they're option-key.
|
||
|
|
So, if you hit meta-x on emax,
|
||
|
|
it doesn't get that meta-x signal.
|
||
|
|
It just...
|
||
|
|
I forget what it does,
|
||
|
|
but it doesn't do what you think it wanted to do.
|
||
|
|
So, the other option,
|
||
|
|
if you don't have an alt-key,
|
||
|
|
or it's not working,
|
||
|
|
the way you think it should be,
|
||
|
|
it would be the escape key,
|
||
|
|
but it's a different kind of hit.
|
||
|
|
So, when you do a normal meta-x,
|
||
|
|
like alt-x, you know,
|
||
|
|
you just hit it like normal,
|
||
|
|
just like you're doing any other keyboard combination.
|
||
|
|
But if you have to use substitute escape for it,
|
||
|
|
then you hit escape,
|
||
|
|
and then you hit x,
|
||
|
|
or whatever key.
|
||
|
|
But in this case, yeah,
|
||
|
|
meta-x, escape-x,
|
||
|
|
or just normal meta-x,
|
||
|
|
and that gets you down to your little mini buffer,
|
||
|
|
a little stripped down at the bottom,
|
||
|
|
and you can type something in.
|
||
|
|
And for instance,
|
||
|
|
you could type in the word undo,
|
||
|
|
and sure enough,
|
||
|
|
it does an undo.
|
||
|
|
It executes an undo.
|
||
|
|
So, a lot of these commands
|
||
|
|
that you can set up in .emax
|
||
|
|
are simply commands that exist in emax.
|
||
|
|
It's almost like setting an alias in bash.
|
||
|
|
So, if I do meta-x again,
|
||
|
|
and let's say that I want to do something really fancy,
|
||
|
|
well, let's just type in CUA actually,
|
||
|
|
and then tab,
|
||
|
|
and then actually how about copy?
|
||
|
|
Copy tab,
|
||
|
|
and then you'll see a little pop-up frame,
|
||
|
|
pop-in frame,
|
||
|
|
and it gives you the possible completions
|
||
|
|
of the word copy,
|
||
|
|
or CUA,
|
||
|
|
or whatever you typed in there.
|
||
|
|
And in this case,
|
||
|
|
there's a copy-file,
|
||
|
|
copy-region,
|
||
|
|
as dash-kill,
|
||
|
|
copy-to-register,
|
||
|
|
copy-rectangle-to-register,
|
||
|
|
copy-to-buffer.
|
||
|
|
Lots of different things that you can do.
|
||
|
|
Let's do the CUA.
|
||
|
|
CUA mode, CUA selection mode.
|
||
|
|
You know, just use your imagination.
|
||
|
|
There's all kinds of different things
|
||
|
|
that you can call in EMAX,
|
||
|
|
and anything that you can call on that little mini-buffer line
|
||
|
|
to execute is something that you can assign very easily.
|
||
|
|
Without writing any new code,
|
||
|
|
you can assign it to any given keyboard combination
|
||
|
|
that you want.
|
||
|
|
So that's pretty powerful,
|
||
|
|
because you can do a lot of customizations just kind of
|
||
|
|
by getting used to the things that you like to have happen,
|
||
|
|
assigned to a quicker keyboard shortcut,
|
||
|
|
and you're done.
|
||
|
|
And you can even string them together and stuff like that,
|
||
|
|
but we're not going to get into that.
|
||
|
|
Just know that that is all very...
|
||
|
|
It's almost like scripting, I guess,
|
||
|
|
or assigning very complex aliases.
|
||
|
|
Okay, so now we've got all that in our .emax file,
|
||
|
|
so let's save it,
|
||
|
|
and try it out.
|
||
|
|
Get a new text file.
|
||
|
|
Open emax, get a blank,
|
||
|
|
or get the old text document up,
|
||
|
|
whatever you're using,
|
||
|
|
and select some stuff with the Shift key,
|
||
|
|
and the arrow keys.
|
||
|
|
That should select everything,
|
||
|
|
like a normal text editor.
|
||
|
|
And then go ahead and try out your new
|
||
|
|
fancy copy paste commands.
|
||
|
|
Control X should cut it,
|
||
|
|
or Control C should copy it,
|
||
|
|
and then you can move around in the document
|
||
|
|
with your arrow keys,
|
||
|
|
Control V to paste,
|
||
|
|
and it works.
|
||
|
|
Exactly as we would have expected.
|
||
|
|
So as you can see,
|
||
|
|
if you're attracted to the power of emax,
|
||
|
|
but you've been put off a little bit by the keyboard shortcuts
|
||
|
|
that are involved,
|
||
|
|
it can all be changed.
|
||
|
|
It's very, very malleable.
|
||
|
|
You can reassign whatever you want.
|
||
|
|
The typical convention in emax is Control X
|
||
|
|
belongs to the emax system.
|
||
|
|
It's the thing that makes all the commands kind of go.
|
||
|
|
It's the major.
|
||
|
|
I think of them as system commands,
|
||
|
|
although they're not system commands,
|
||
|
|
because obviously they're not things that go outside
|
||
|
|
and affect your computer.
|
||
|
|
But they're emax commands.
|
||
|
|
Control H is a reserved key that gives,
|
||
|
|
that brings up the help system.
|
||
|
|
But Control C is reserved as a user-specific key combination.
|
||
|
|
So you as a user will always have every possible combination
|
||
|
|
after Control C for yourself to define.
|
||
|
|
And that's a really, really powerful thing,
|
||
|
|
because that opens up any possible interface that you want.
|
||
|
|
You want something to happen when you hit a key.
|
||
|
|
You can always know that Control C,
|
||
|
|
Foo, will never be interfering with any other emax control,
|
||
|
|
because anyone who writes a major mode,
|
||
|
|
as long as they're following the new emax-lisp reference manuals
|
||
|
|
sort of guidelines,
|
||
|
|
then they will never define Control C as a function in their application.
|
||
|
|
So that's something that only users get to define,
|
||
|
|
and you can do whatever you want with that.
|
||
|
|
I think F5 through F9 keys are also reserved.
|
||
|
|
For user definitions, I took it over anyway myself,
|
||
|
|
but I knew that I was clobbering something,
|
||
|
|
so I don't care.
|
||
|
|
But the safe bets, if you want to make sure
|
||
|
|
that you're not clobbering any existing key binding
|
||
|
|
in any existing plug-in, Control C,
|
||
|
|
and anything from F5 up to F9,
|
||
|
|
they're completely reserved for you.
|
||
|
|
Okay, I've talked a little bit about plug-ins.
|
||
|
|
I've mentioned them.
|
||
|
|
I've danced around this subject.
|
||
|
|
You're probably getting pretty interested
|
||
|
|
in just what kind of plug-ins there are.
|
||
|
|
Well, I'm pretty simple emax user.
|
||
|
|
I use in XML,
|
||
|
|
which is an XML automatic completion validation little mode.
|
||
|
|
I use a lot for dock book and HTML.
|
||
|
|
I use dock book menu,
|
||
|
|
which is actually it's not really a mode.
|
||
|
|
It just adds a menu in my bar
|
||
|
|
to give me some dock book reference help.
|
||
|
|
I use screenwriter.el,
|
||
|
|
and I play around with org mode,
|
||
|
|
and I use W3,
|
||
|
|
or 3WM, or whatever it's called,
|
||
|
|
which is the, no, it would be W3M,
|
||
|
|
which is a web browser for EMAX.
|
||
|
|
And I use Eshell quite a bit as well,
|
||
|
|
because I find myself,
|
||
|
|
I used to find myself always launching a new X term
|
||
|
|
every time I wanted to reference something
|
||
|
|
in a terminal.
|
||
|
|
And now I just leave Eshell open in a frame,
|
||
|
|
and I just switch over there,
|
||
|
|
and there's my terminal.
|
||
|
|
So that's quite nice as well.
|
||
|
|
So these are all plug-ins.
|
||
|
|
A lot of them are so well established
|
||
|
|
that if you install EMAX on any major distribution,
|
||
|
|
part of that big 75 megabyte download
|
||
|
|
that you're getting are those plug-ins.
|
||
|
|
So you're not just getting the EMAX framework,
|
||
|
|
is it were just the text editor?
|
||
|
|
You're getting the whole,
|
||
|
|
the really common plug-ins as well.
|
||
|
|
So common, I think,
|
||
|
|
that people almost don't even think of them as plug-ins,
|
||
|
|
or I don't even know if I'm using the right word,
|
||
|
|
modules, whatever.
|
||
|
|
So you can get plug-ins on your own,
|
||
|
|
you can find them and install them.
|
||
|
|
Some of them are quite complex.
|
||
|
|
org mode is such a vast thing,
|
||
|
|
such a vast application all on its own,
|
||
|
|
that to grab that,
|
||
|
|
you actually make it and make install and stuff like that.
|
||
|
|
So it's a big one,
|
||
|
|
or you can get it from your repository
|
||
|
|
and it does all that work for you,
|
||
|
|
which is kind of nice.
|
||
|
|
But you can get,
|
||
|
|
I mean, if you find something randomly online
|
||
|
|
and want to install it,
|
||
|
|
you can.
|
||
|
|
That's the thing to do.
|
||
|
|
It's a little bit like,
|
||
|
|
almost like Python or something.
|
||
|
|
You know, you can open up the thing,
|
||
|
|
and you can read it.
|
||
|
|
You can read the plug-in that you're about to install
|
||
|
|
because it will usually in the comments.
|
||
|
|
I shouldn't say usually.
|
||
|
|
Often, I have found in the comments,
|
||
|
|
it tells you a lot of stuff.
|
||
|
|
It tells you how to use it,
|
||
|
|
how to install it,
|
||
|
|
different things like that,
|
||
|
|
what your different options might be,
|
||
|
|
different ideas on how you could use it,
|
||
|
|
that sort of thing.
|
||
|
|
So I would read the code myself.
|
||
|
|
And if you're happy with it,
|
||
|
|
if you understand it,
|
||
|
|
it looks like something you're interested in
|
||
|
|
and it's telling you how to install it,
|
||
|
|
then install it the way that it tells you to.
|
||
|
|
I can give you a general idea
|
||
|
|
of how they are typically installed.
|
||
|
|
There are two different ways.
|
||
|
|
There's the system-wide installation,
|
||
|
|
and there's the user installation.
|
||
|
|
So system-wide would be,
|
||
|
|
if you're setting up computers for other people,
|
||
|
|
and it's a, you know,
|
||
|
|
a multi-user kind of situation,
|
||
|
|
so you want everyone to have access to the same modules.
|
||
|
|
You would drop these modules into slash,
|
||
|
|
U.S.R. slash share,
|
||
|
|
slash emacs,
|
||
|
|
slash sites-lisp,
|
||
|
|
and you put the module right in there,
|
||
|
|
and site-lisp.
|
||
|
|
The path might be a little bit different,
|
||
|
|
depending on the system that you're on,
|
||
|
|
whatever,
|
||
|
|
but typically that's,
|
||
|
|
that's roughly it,
|
||
|
|
looking to user-share,
|
||
|
|
because it's something that all the users are going to be able to access.
|
||
|
|
And it'll, it'll,
|
||
|
|
it should probably be in some kind of emacs directory,
|
||
|
|
emacs 22, emacs 23,
|
||
|
|
emacs whatever.
|
||
|
|
And then usually it's in site-lisp,
|
||
|
|
is the, uh,
|
||
|
|
the name of the folder that contains all those different little plugins.
|
||
|
|
And they usually end in a dash,
|
||
|
|
e-l,
|
||
|
|
if it ends in a dash,
|
||
|
|
e-l-c, that means it's been,
|
||
|
|
I guess it's called byte compiled or something like that,
|
||
|
|
where it's been,
|
||
|
|
maybe optimized or processed to some degree.
|
||
|
|
But the dot e-l is the one that,
|
||
|
|
that's the master,
|
||
|
|
that's the one that you really want to have,
|
||
|
|
and kind of if you like it,
|
||
|
|
you want to kind of keep track of it probably.
|
||
|
|
Um,
|
||
|
|
so as long as it's in there,
|
||
|
|
in that folder,
|
||
|
|
emacs always,
|
||
|
|
that's in emacs's path.
|
||
|
|
So it's going to be aware,
|
||
|
|
to some degree of that module.
|
||
|
|
Now, I say to some degree
|
||
|
|
because that module may be very complex.
|
||
|
|
It might require, um,
|
||
|
|
a lot of other submodules
|
||
|
|
or other code to load along with it,
|
||
|
|
in which case you might be instructed, again,
|
||
|
|
by the module itself,
|
||
|
|
by the code,
|
||
|
|
or by their install instructions on their site.
|
||
|
|
You might be told to place some extra lines
|
||
|
|
in your dot emacs mode.
|
||
|
|
And that's not a big deal,
|
||
|
|
you know how to do that now,
|
||
|
|
so it's not your emacs mode,
|
||
|
|
your dot emacs file.
|
||
|
|
It's not a big deal,
|
||
|
|
you know how to do that,
|
||
|
|
we've just done it a couple of times,
|
||
|
|
so just add whatever they tell you to add to your dot emacs file.
|
||
|
|
I usually like to comment it,
|
||
|
|
so that I know what plugin
|
||
|
|
those requirements refer to,
|
||
|
|
and then relaunch emacs,
|
||
|
|
and everything should just kind of work.
|
||
|
|
Now, a lot of times,
|
||
|
|
I mean again, if you read the code,
|
||
|
|
you'll get an idea of this,
|
||
|
|
but if you're not going to do that,
|
||
|
|
then you might have to kind of look around
|
||
|
|
and figure out how to use that mode,
|
||
|
|
how to get into that mode.
|
||
|
|
For instance, in XML mode,
|
||
|
|
that is, I just hit MetaX,
|
||
|
|
and then in XML,
|
||
|
|
and then you could tab to get completion,
|
||
|
|
and it'll tell you,
|
||
|
|
oh, here's the closest match in XML mode,
|
||
|
|
and sure enough,
|
||
|
|
that launches in XML mode,
|
||
|
|
and gives me all kinds of cool little features,
|
||
|
|
like on the fly validation,
|
||
|
|
automatic tag completion,
|
||
|
|
stuff like that.
|
||
|
|
Now, I've got a lot of customizations
|
||
|
|
for in XML mode in my dot emacs file,
|
||
|
|
which gives me even more functionality.
|
||
|
|
Like whenever I open an XML file,
|
||
|
|
it automatically launches in XML mode.
|
||
|
|
So that's really nice.
|
||
|
|
I never actually have to hit MetaX,
|
||
|
|
and type in XML mode.
|
||
|
|
I can just, unless I want to start from scratch,
|
||
|
|
but more often than not,
|
||
|
|
I'm opening up files that already exist,
|
||
|
|
and they end in dot XML,
|
||
|
|
so I go into XML mode automatically.
|
||
|
|
So those are some nice features
|
||
|
|
that you can add for yourself,
|
||
|
|
and the other place to put that,
|
||
|
|
so if you're on a computer
|
||
|
|
where you don't have access to the user,
|
||
|
|
share emacs,
|
||
|
|
e-list site list directory,
|
||
|
|
then you can simply place it
|
||
|
|
in a local directory,
|
||
|
|
and add that to your emacs path.
|
||
|
|
So this is a lot like bash kinds of stuff,
|
||
|
|
like when you're modifying your execution,
|
||
|
|
your environment's path,
|
||
|
|
it's essentially the same idea.
|
||
|
|
I do this for a lot of my modules,
|
||
|
|
my emacs, modes, and plugins,
|
||
|
|
because I don't want to forget,
|
||
|
|
you know, if I'm updating my system,
|
||
|
|
or if I'm, I don't know,
|
||
|
|
if I lose a computer or something,
|
||
|
|
or you know, lose the data on it,
|
||
|
|
or something,
|
||
|
|
I don't want to lose all my emacs stuff,
|
||
|
|
so I prefer not to put it
|
||
|
|
in the slash usr, slash share,
|
||
|
|
slash emacs,
|
||
|
|
but slash site list directory.
|
||
|
|
I actually prefer to place it in my home directory,
|
||
|
|
so till the slash,
|
||
|
|
I just call my folder e-lisp,
|
||
|
|
some people I've seen online call it e-lisp.d,
|
||
|
|
other people might call it emacs,
|
||
|
|
I don't know,
|
||
|
|
whatever you want to call it,
|
||
|
|
I call it e-lisp,
|
||
|
|
I make a directory called e-lisp,
|
||
|
|
and I put all my modules in there that I want,
|
||
|
|
and I do that again,
|
||
|
|
so that it always,
|
||
|
|
it's always backed up with the rest of my data,
|
||
|
|
because I always back up my home directory,
|
||
|
|
and so that if I'm going to go to a different computer somewhere,
|
||
|
|
and I want to make sure that I have my version of emacs with me,
|
||
|
|
all I have to do is grab that e-lisp directory,
|
||
|
|
and put it on a phone drive,
|
||
|
|
and then I use that in tandem with the emacs on whatever computer
|
||
|
|
I'm in front of,
|
||
|
|
and suddenly my emacs was acting exactly how I wanted to act,
|
||
|
|
so that's really, really, really powerful stuff,
|
||
|
|
I don't know if I can emphasize it enough,
|
||
|
|
I mean, honestly, I've gotten to the point where that e-lisp directory,
|
||
|
|
I've got that on me at all times,
|
||
|
|
literally at all times,
|
||
|
|
and if I didn't have it on me all at all times,
|
||
|
|
it's on Gatorius,
|
||
|
|
Gatorius.org slash emacs, actually,
|
||
|
|
if you want a copy of it,
|
||
|
|
and it's got all my favorite stuff in it,
|
||
|
|
it's got all my key bindings in it and everything,
|
||
|
|
and so I mean, at this point,
|
||
|
|
I don't even know what stock emacs looks like or acts like,
|
||
|
|
it's all in my .emacs or my e-lisp directory
|
||
|
|
and my .emacs file,
|
||
|
|
and I've got all my favorite little add-ons right there,
|
||
|
|
always ready to be used.
|
||
|
|
So to do that,
|
||
|
|
you would make a directory,
|
||
|
|
and you could of course do this from within emacs,
|
||
|
|
you could do MetaXeShell,
|
||
|
|
and there it launches a terminal,
|
||
|
|
it drops you into your home directory,
|
||
|
|
so we'll just do a make-der e-lisp,
|
||
|
|
and then we can move into e-lisp,
|
||
|
|
well, actually we won't yet,
|
||
|
|
because we don't have anything to put in there,
|
||
|
|
but go online and find some cool plugin that you want.
|
||
|
|
I might mention non-genew.org slash screenwriter,
|
||
|
|
you know you want it.
|
||
|
|
Grab that, it's one single file,
|
||
|
|
it was not written by me,
|
||
|
|
being maintained by me currently,
|
||
|
|
and drop that into your e-lisp directory.
|
||
|
|
So if you've done that,
|
||
|
|
then we would go into the .emacs file,
|
||
|
|
and again we could do that from within emacs,
|
||
|
|
you'll start to notice how often you don't have to leave emacs.
|
||
|
|
Control X, Control F,
|
||
|
|
and load up your tilde slash .emacs,
|
||
|
|
and then we'll add to your .emacs file.
|
||
|
|
Again, I like to comment this stuff,
|
||
|
|
so my colon is the comment key for .emacs,
|
||
|
|
and so we'll put in here that this is a class 2 config options,
|
||
|
|
stuff, whatever,
|
||
|
|
and then we want to add to list,
|
||
|
|
so this is parent add-2-list space,
|
||
|
|
single quote, load-path,
|
||
|
|
space, double quote,
|
||
|
|
tilde slash e-lisp,
|
||
|
|
double quote, close parent.
|
||
|
|
I think it's almost fairly obvious what we did there.
|
||
|
|
We said add to the list,
|
||
|
|
and the list that we're adding to is load-path this directory,
|
||
|
|
and that is tilde slash e-lisp,
|
||
|
|
so that means that the load-path of emacs
|
||
|
|
has now had appended to it dynamically every time it loads.
|
||
|
|
It's having e-lisp in my home directory added to its little load-path.
|
||
|
|
It's a lot like when you say in your bash rc,
|
||
|
|
or your bash underscore profile,
|
||
|
|
to make the path equal
|
||
|
|
dollar sign path colon slash off to slash local slash bin,
|
||
|
|
or whatever you're doing,
|
||
|
|
you're saying take your current path,
|
||
|
|
and then append this to it,
|
||
|
|
or take the system default path,
|
||
|
|
which comes from slash edc slash dot,
|
||
|
|
or not dot, but just what profile I think,
|
||
|
|
is it just profile?
|
||
|
|
I'm pretty sure it's just profile in edc.
|
||
|
|
Take that entity,
|
||
|
|
and then append colon slash local,
|
||
|
|
slash off slash local slash bin to that.
|
||
|
|
Therefore, you're not writing over the path,
|
||
|
|
you're just taking the variable that exists and adding to it.
|
||
|
|
That's what we're doing here.
|
||
|
|
We're saying add to list,
|
||
|
|
the list being the load-path this directory.
|
||
|
|
Okay, I think you probably get that,
|
||
|
|
and then we'll say,
|
||
|
|
for instance, in this case,
|
||
|
|
we'll say, well,
|
||
|
|
parent require space single-quote screenwriter,
|
||
|
|
close parent.
|
||
|
|
That means that for the next set of options,
|
||
|
|
we're going to require the screenwriting,
|
||
|
|
the screenwriter mode,
|
||
|
|
and for those modes,
|
||
|
|
we will have global set,
|
||
|
|
parent global set key space,
|
||
|
|
parent kbd,
|
||
|
|
double-quote c-c-s,
|
||
|
|
double-quote parent,
|
||
|
|
space single-quote screenplay-slugline,
|
||
|
|
close parent,
|
||
|
|
and a whole bunch of other options.
|
||
|
|
You can see them all in gotorious.org slash emax.
|
||
|
|
My .emax file is there.
|
||
|
|
You can check it out,
|
||
|
|
clone it,
|
||
|
|
rather pull it, whatever.
|
||
|
|
So now, if we were to launch emax,
|
||
|
|
and we were to type in meta-x screenwriter dash mode,
|
||
|
|
we would be in screenwriter mode,
|
||
|
|
and then if we typed in control c-s,
|
||
|
|
we would be in slugline entry mode,
|
||
|
|
and it would execute a series of commands
|
||
|
|
that is written in the screenwriter.el,
|
||
|
|
and it would proceed from there.
|
||
|
|
So what we've just done is,
|
||
|
|
we've moved screenwriter.el to our e-lisp directory.
|
||
|
|
We've added our e-lisp directory
|
||
|
|
to the load path of emax,
|
||
|
|
so that it can detect that screenwriter.el,
|
||
|
|
and we even went so far as to say,
|
||
|
|
okay, for the screenwriter mode,
|
||
|
|
require quote screenwriter,
|
||
|
|
let's set some global key bindings,
|
||
|
|
and you can kind of go crazy with that.
|
||
|
|
I mean, once you get the load path added,
|
||
|
|
it'll just see every module you put into that e-lisp directory,
|
||
|
|
and you're pretty much good to go.
|
||
|
|
With the exception, like I say,
|
||
|
|
with the exception stuff that it's really complex,
|
||
|
|
and it needs more code,
|
||
|
|
so it will tell you,
|
||
|
|
well, in addition to placing this into your e-lisp directory,
|
||
|
|
add such and such to your load path,
|
||
|
|
or require some other function to be loaded,
|
||
|
|
or whatever.
|
||
|
|
So sometimes there are additional things
|
||
|
|
that you'll want to put in your .emax.
|
||
|
|
It's not a big deal, though.
|
||
|
|
It's just, like I say,
|
||
|
|
read either their install instructions
|
||
|
|
or the code itself in the comments,
|
||
|
|
and you'll see what you have to do.
|
||
|
|
Hopefully, they'll be very explicit about it.
|
||
|
|
I had really good luck with it, honestly.
|
||
|
|
I haven't found a plug-in so far that's really overly complex
|
||
|
|
to install.
|
||
|
|
With the exception of W3M,
|
||
|
|
that was pretty complex,
|
||
|
|
but there was an installer for it,
|
||
|
|
so I installed that,
|
||
|
|
and then added some cool features into the .emax,
|
||
|
|
and I get the same results,
|
||
|
|
so no worries.
|
||
|
|
So to see what plug-ins you have installed,
|
||
|
|
well, actually, and I should mention,
|
||
|
|
that in your repository,
|
||
|
|
you might find a package called, like,
|
||
|
|
emax-extras,
|
||
|
|
or you might find just the modes themselves
|
||
|
|
packaged individually.
|
||
|
|
Like I found the W3M mode packaged up as a Slack build,
|
||
|
|
and it was really easy to install.
|
||
|
|
Alternatively, I think on either
|
||
|
|
Red Hatter for Door or Both,
|
||
|
|
or neither.
|
||
|
|
I found, like, a sort of a package,
|
||
|
|
a power pack of a bunch of emax modes.
|
||
|
|
But regardless of how you get them,
|
||
|
|
you can always find them, obviously,
|
||
|
|
in the user slash usr slash share slash emax slash
|
||
|
|
slash site list.
|
||
|
|
You can see what's already on your system.
|
||
|
|
You can look at the emax wiki website
|
||
|
|
to learn about new ones,
|
||
|
|
and you can look in your repository.
|
||
|
|
So those are where you can find plug-ins.
|
||
|
|
Now you know how to install them,
|
||
|
|
either from your repository,
|
||
|
|
or just dropping them in your home directory
|
||
|
|
in an e-lisp directory,
|
||
|
|
which, necessarily, you'll have to add to your dot emax file
|
||
|
|
so that it knows to look in your e-lisp folder.
|
||
|
|
And if you look in slash usr slash share slash emax slash
|
||
|
|
site list, try some of those out.
|
||
|
|
Try, try hitting MetaX type in something,
|
||
|
|
like ERC, and suddenly you find yourself on IRC
|
||
|
|
in free node, chatting with people.
|
||
|
|
So try, try the little plug-ins out.
|
||
|
|
You've got more than you think you do, probably,
|
||
|
|
and you never know what you might find,
|
||
|
|
and you also never know how you might cut down on your clicking
|
||
|
|
and opening of windows and stuff like that.
|
||
|
|
Like I say, I used to always find myself
|
||
|
|
obsessively opening up X terms for some stupid reason.
|
||
|
|
I mean, I had it bound to a global key shortcut
|
||
|
|
in KDE and Fluxbox, both,
|
||
|
|
so it's really quick for me,
|
||
|
|
but it's still kind of annoying,
|
||
|
|
because that stupid window always pops up,
|
||
|
|
and then you have to tab alt and alt tab and stuff.
|
||
|
|
Just MetaX e-shell and bang, you're there,
|
||
|
|
or just assign it to F5 or something, or F6,
|
||
|
|
whatever you want to do it, or control CX,
|
||
|
|
whatever, you can make stuff pop up all over the screen.
|
||
|
|
And in fact, next episode, the final episode,
|
||
|
|
the big finale episode of this emax tour,
|
||
|
|
we're going to talk about frames and buffers
|
||
|
|
splitting the screen, doing all kinds of cool things like that.
|
||
|
|
So tune in next time.
|
||
|
|
You have been listening to Hacker Public Radio
|
||
|
|
or takeerpublicradio.org.
|
||
|
|
We are a community podcast network
|
||
|
|
that releases shows every weekday and Monday through Friday.
|
||
|
|
Today's show, like all our shows,
|
||
|
|
was contributed by an HPR listener by yourself.
|
||
|
|
If you ever consider recording a podcast,
|
||
|
|
then visit our website to find out how easy it really is.
|
||
|
|
Hacker Public Radio was founded by the digital dot-pound
|
||
|
|
and near-phonomical and computer cloud.
|
||
|
|
HPR is funded by the binary revolution at binref.com.
|
||
|
|
All binref projects are crowd-sponsored by linear pages.
|
||
|
|
From shared hosting to custom-private clouds,
|
||
|
|
go to lunarpages.com for all your hosting needs.
|
||
|
|
Unless otherwise stasis,
|
||
|
|
today's show is released under creative comments,
|
||
|
|
attribution, share a like,
|
||
|
|
free those own license.
|