Using Emacs, Beginner Level

Hello, let’s talk about development environments.

Currently, Emacs is my preferred editor, I’m still a beginner with it but it already helps me a lot on C, and sometimes Python, programming.

emacs

I started using Emacs to work with remote files, making ssh connections and accessing files is very easy with it, and it provides many more features than nano, the editor I was using at the time. When learning the basics, I read much about its power and adaptability  and took as a challenge to turn it into a good Python IDE.

I’m afraid I failed this challenge, since I still prefer Pycharm; mainly because of better autocomplete and documentation access, I couldn’t configure a good documentation search tool with Emacs, maybe a more skilled user is able to. However, I still use Emacs to write small scripts, Pycharm is heavy and hangs too much, so it’s something 🙂

I tried it with C++ and now Emacs is my main C++ IDE, I use it mostly to play with Codeforces problems. It helps to have three windows available in the same screen, one for the main code, another for the custom input and a terminal window.

Anyway, too much was said about why I use it, and that’s not the purpose of this post. I intend to show how Emacs can help you to work with huge codebases, similar to the ones found in Linux Kernel.

Before we begin, be aware, Emacs will mess with indentation, you should be careful when configuring it. The configuration I use seems ok, you can find it at: https://github.com/Elise-Lennion/Emacs. Rename emacs_init to .emacs and place it at ~/, then Emacs should load this configuration at launch.

Now you’re ready to use it on Open Source C projects, but what does it offer? I can show you the features which help me most.

On the following paragraphs, C refers to Ctrl and M (Meta) to Alt. If the command is a function name (e. g. occur), you should type M-x and the command name, you can configure custom key bindings to any command you choose.

Split window: This feature is a built-in of Emacs, you can split a view horizontally, C-x 2, or vertically, C-x 3. It’s the most useful feature mentioned here, you can see multiple files you’re working on at the same time, just beautiful. To navigate between windows, press C-x ‘direction arrow’, the configuration file I use also sets ‘Windows key’-‘direction arrow’ to make navigation faster.

emacs_split_screen
Emacs multiple screens

Highlight 80+ columns: All characters after 79th column are highlighted, so you know when a line won’t be properly displayed in a terminal window, simple and prevents checkpatch warnings.

Interactive completion: To open a file you should type C-x C-f, then a little window at the bottom of the screen will appear, where you type the filename. Using Interactive completion, all files in the current folder are listed, also, it filters the displayed files to match what you’re typing. This speeds codebase navigation a lot, no need to use ls in every folder, also, typing filenames can be frustrating slow when there are many similar names.

String search, occur: Emacs offers a lot of string search methods, search-forward, search-backwardRegexp matching, occur and more. They all have their uses but occur is special. It displays all occurrences of a string in a new interactive window, when you click on an occurrence your screen will be directed to it. That’s a blessing when trying to understand what a specific function does and where it’s called.

emacs_occur
Occur example

Built-in terminal: Emacs isn’t simply a IDE, you can open a terminal window inside it, with M-x shell, no need to mention what this offers. However, the terminal isn’t always 100% functional, e.g. it doesn’t work properly when using ‘man’ or ‘git grep’. Usually I have a dedicated terminal window open.

Some useful commands: C-g cancels your current action, M-w is similar to Ctrl+c, C-w to Ctrl+x and C-y to Ctrl+v, if it pastes the wrong text try to use M-y afterwards.

These features are very helpful, and are only very basic functionalities of Emacs. For further readings, there are many easy to find tutorials about Emacs, it is 40 years old, the community and references are very developed, and there is much to discover.

That’s a beginner view on why it’s good and how to use Emacs on C projects, code navigation will be hard at first but you’ll get used to it. I’ll share more features when I learn them, magit is next  🙂

Outreachy round 13 – Linux Kernel

Hello there!

This blog will be all about my experience on Outreachy round 13. As the tittle suggests, I was accepted at Linux Kernel 🙂

Please allow me to tell a small background story.

This year I started using an OS with Linux kernel as my main; Ubuntu was my choice, I know I shouldn’t talk about it openly, but the large community, it was too appealing – in my defense, I plan on trying Arch Linux during summer vacations, when I’ll have time to fix things I break during the transition. Anyway, the high customizable system I found was a new world I wanted to explore, still do.

This same year I was introduced to Open Source, by programming things I used a lot of open source projects – mostly Python with many of its modules and a lot of useful scripts from kind people around the globe. But using and not contributing feels wrong and scales poorly, so I wanted to give back to the community.

Then I heard about Outreachy, it immediately caught my attention, was the perfect opportunity to dive deeper in and contribute to open source projects. Fedora, Debian and Linux Kernel attracted me the most, and I decided to dedicate my time to Linux Kernel.

Many patches later, followed by their v2, v3, and so on, I was assigned to nftables, won’t extend myself about the project here, a new post is needed for this purpose, but I’m very happy to work on it.

calvin-and-hobbes_new-world

That’s how I feel right now, see you next time!

Elise.