The Emacs Way of understanding Humans and Computers

November 30, 2014 at 10:28 pm | Posted in Patterns | 1 Comment
Tags: , , , ,

I was using gNewSense frow sometime now and one thing about softwares endorsed or created by FSF is that you get to know some amazing ideas or some incredible ways of solving some problems that you never came across before and you yourself never knew those either. For example, take icecat, it comes default with libreJS add-on installed. Generally we think an OS can control your machine and then you. After using libreJS I see how you can use javascript in a web-browser to control the user, without giving any hint at all. User will use his computer for 10 years and for those 10 years he will not have slightest of the idea that he is being controlled. Then I came across duckduckgo search engine and then ThinkPenguin router  with 100% Freedom and then h-node  and now gNewSense.

When I used Emacs first time, in year 2006, after few weeks of usage I came across The GNU Project (open Emacs and press “Control-h g”), that one keystroke (C-h g) changed my life. I got hooked onto Linux forever (or GNU/Linux as RMS calls it). Since last few years, I have never used/installed any proprietary OS on my machine, my machine runs only on Linux, yes, no other OS, only and only Linux (something that majority of Software Engineering students and prfossionals in INDIA are always scared to do). Just few months back I came across gNewSense and from there I came across one gNewSense BlogPost, an introductory book on programming in Emacs Lisp written by Robert J. Chassell. For those who don’t know, Emacs is one of the most (if not the most) advanced text editors available. I am sure if you make a list of top 20 softwares ever created with best design ideas then Emacs will be one of them (and Apache web server will be there too along with several softwares starting with letter “g” 😉 ). Emacs is written using Emacs Lisp (a dialect of Lisp, an amazing language) while some parts are written in C for portability/efficiency reasons. I am using Emacs all the time for writitg code but I do admit I hardly make effective use of it. I think I use may be 10% of its power. I always wanted to learn more and the book written by Robert seemed like a decent start. I am already writing code from few years now and Robert mentioned that it is “not for experienced programmers” but I am reading it anyway because I always wated to understand Emacs and then this book is so interesing and engaging and I can not seem to put it down. It is as much interesting as The Man Who Sold The Moon . Whenever I will come across some idea that I will like then I will post about it here. So, here is the first design idea I really loved (I assume you are familiar with some dialect of Lisp. If not, then just read 17 pages of first chapter of Robert’s book. That will be more than enough. Do not worry, it will not take much time to read those)

  • You want to evaluate something written in Emacs Lisp ? Just open emacs, put cursor at the end of the variable or function name or the closing parenthesis or whatever you want to evaluate and press “C-x C-e” and you got the answer. That’s it, that is how simple it is in Emacs.
  • File and Buffer are two different entities. File is what permamently stored on your computer’s hard disk whereas a buffer is inside emacs which will go away as soon as you exit emacs. A buffer visits the file or is a pointer to the file, not the actual file. You want to save changes into the file then just save the buffer and changes will be written to the file.
  • This one is most interesting. switch-to-buffer is an Emacs Lisp function that helps you in switching to another buffer. Generally when you look at any editor (Notepad, Notepad++ or gedit etc. for example) , you usually look at the file you are editing. If you switch to another file then you will see only and only this another file and previous file will not be visible. Previous file is open but it is not visible and hidden in the editor). What I mean is you can see only one file in front of you, not two (I am not talking about splitting-frames). Within Emacs code, switch-to-buffer is less used than set-buffer. Why ? … Because computer does not need eyes to see while humans do. When a a computer program needs to work on a buffer/file, it does not need to see it, visibility is not needed. switch-to-buffer was designed for humans and it does two things:
    • It switches to the new buffer .
    • It switches the buffer “displayed” in the window with new one.

You can easily guess now that set-buffer only walks the first step, it switches the program to other buffer while buffer on the screen remains unchanged.  Doesn’t this concept feel like one of the rules of the creation of this Universe while still being so simple and straightforward. I salute RMS for creating Emacs and keeping it free


Copyright © 2014 Arnuld Uttre, Hyderabad, Telangana – 500017 (INDIA)

Licensed Under Creative Commons Attribution-NoDerivs 3.0 license (a.k.a. CC BY-ND)

Advertisements

Create a free website or blog at WordPress.com.
Entries and comments feeds.