tags:

views:

237

answers:

8

Hello,

Recently, I began studying GNU/Emacs. Was very easy to use program. Studied its structure. Tuned nice color for me. Configure it to class on C programming. Everything seemed normal. But now the question arose of GNU/Emacs lisp. Should I really spend time to study Emacs Lisp if I did not develop itself Emacs and will only use it like ide for C/C++ development, mail, jabber and etc...

The fact is that when I edit my .emacs I understand that I write. But I write mostly ready-made scripts or if its something they are very simple.

Thank you.

+1  A: 

I've been using Emacs for a while and can tell that if you're ok with features provided with modes you're using, and hence have no need to improve them, there's no real need to study elisp. A little of elisp is required to write your emacs config, but there's fairly small range of language features you will need.

By the way, if you will want to extend some functionality, there's possibility to script emacs using other languages (like python, perl, don't remember which ones are there), so learning elisp isn't so critical. Probably, you may find out more starting with this emacs wiki page: http://www.emacswiki.org/emacs/CategoryExtensionLanguage

Vadim Fedorov
+1  A: 

A basic amount of Emacs Lisp is really good to know, in my opinion (for example: customizing key bindings, understanding the .emacs file).

If a deeper knowledge of Emacs Lisp is required, depends on whether you're content with emacs as it is or not.

I suppose, that most problems you'll encounter are already solved by someone else. So there's quite a good chance of getting a nice .el file somewhere doing exactly what you want.

However, if there are some exotic features that you want to implement, learning Emacs Lisp might be an option. Another point is that Lisp is an actually used programming language in industry, so it's never bad to know it (ok, it's Emacs Lisp, but it's similar to it).

phimuemue
+7  A: 

No, it's not strictly necessary. You will probably write elisp, but mostly just set variables and insert the necessary snippets for any mode or package you want to use (setq, require etc). Most of that is done by copying and pasting, so no real knowledge of elisp is required.

Having said that, defining small functions can be quite useful, and learning enough Emacs Lisp for that might prove useful. Look at Xah Lee's tutorial, it's quite short and succinct.

mhd
+1  A: 

As you are a beginner, don't worry too much about Emacs Lisp. Become proficient with the editor. Most of the extensions/modes that we normally need are already there. But learning Emacs Lisp is a worthy effort. ELisp is not just for customizing Emacs, it is a full programming language. It can do a lot of stuff like interacting with the file system, networking, GUI etc. Once you get familiar with ELisp, there is a chance that you drop C/C++ and start developing your applications in ELisp itself! Deploying your application will also become easy as Emacs/ELisp has been ported to a lot of architectures and it can act as your deployment platform.

Vijay Mathew
+2  A: 

The short answer in "No", however having some knowledge of Emacs Lisp will empower your productivity greatly in some areas.

If you decide to spend some time studying Emacs Lisp I cannot recommend you a better starting point than the excellent book "Introduction to Emacs Lisp"(it also comes bundled with Emacs in info format - C-h i m Emacs Lisp Intro).

Bozhidar Batsov
Thank you for manual link
shk
A: 

I'm a Vim user myself, but I have played around with GNU/Emacs. Your .emacs file is emacs lisp, so if are writing your own configuration of things, you are already using Emacs Lisp. :) Also, you can eval lisp expressions to perform various operations, but I don't think you need to really worry about that - especially if you are sticking to highly-used/developed modes (C/C++, etc). It's all about if you want to open a single program - Emacs - and have it contain your email, irc, and web browser, or use it as a text editor. But most of those previously mentioned things are already written for you - so... it's a tossup.

BenHayden
+4  A: 

Emacs Lisp is what you turn to if you want to automate some kind of editing in your document where going through the UI is just too tedious or slow.

Here's an example: I had to do some refactoring in my company a while back. It involved moving around a bunch of methods to a bunch of files. To help people who would be merging our code during the transition, we left "headstone" comments in the old location telling them where the new code would be. The headstones involved commenting out the entire function (including the declaration), deleting the body of the function, and putting a comment in the body's place instead.

After a handful of these, and dozens to go, I was ready to tear my hair out from boredom. So I cobbled the following commands together and stuck them in my ~/.emacs file. You may be able to get the gist of what they do, even without much in the way of comments.

(defun reheadstone-region (fname beg end)
  (interactive "sFilename to use: \nr")
  (save-excursion
    (save-restriction
      (narrow-to-region beg end)
      ;; comments around entire thing
      (goto-char (point-min))
      (insert "/*\n")
      (goto-char (point-max))
      (insert "\n*/\n")
      ;; zap the method body
      (goto-char (point-min))
      (search-forward "{")
      (forward-line)
      (push-mark (point))
      (goto-char (point-max))
      (search-backward "}")
      (beginning-of-line)
      (kill-region (region-beginning) (region-end))
      (pop-mark)
      ;; new headstone body
      (headstone-in fname))))

(defun headstone-in (fname)
  (interactive "sFilename to use: ")
  (save-excursion
    (beginning-of-line)
    (insert (format "\tThis method has been moved to %s." fname))))

This was a quick and dirty hack, and far from perfect in its operation no doubt. But after loading it up and binding it to a key, and directing it a bit by selecting the region surrounding the function I wanted to headstone before executing the command, I was doing a whole series of tedious edits with practically no effort at all. Plus, I got the rush of pleasure from the instant gratification that this code afforded me. My coworkers were wondering why I looked so cheerful as I breezed my way home for the day, especially after looking so grumpy at lunchtime.

That's the sort of thing Emacs Lisp can do for you. I suppose you could argue that this is no different from "developing Emacs itself", since these commands hardly look any different from Emacs's built-in commands from the UI point of view, but the psychological effect is very different. I'm extending the editor with very specific commands in very specific ways to achieve tasks for my project that would be difficult or impossible without a full scripting language and editor API at my disposal. From my point of view (and I've come to this view lately), an Emacs user without some basic facility with Emacs Lisp has not yet become a power user.

Owen S.
Thumbs up for the hack. But this seems like a school book example of when TAGS is useful, assuming that your build system is smart (or configurable) enough to produce the tags for you, and that everyone uses Emacs (who wouldn't? :) Plus, it doesn't leave a mess behind...
Staffan
@Staffan: That latter assumption is _far_ from the case, especially when it comes to merge time,since there's a particular non-Emacs merge tool involved. Lots of developers across the world were merging this stuff. Trust me, the extra pain and mess was worth it in this particular case, and they did get cleaned out later.
Owen S.
+1  A: 

It's certainly not necessary to be able to write your own elisp, but it can be very useful. Probably the most useful ability this will give you is the ability to 'fix' things that don't work quite the way you want them to, often by writing your own hooks or advice. So if you enjoy using Emacs, but you find that things aren't always to your liking, then I would definitely recommend that you start to learn elisp.

Don't feel that you have to know it all, but just be willing to pick up bits and pieces over time, and you will undoubtedly find that Emacs becomes better and better as time goes on.

Make sure you search for solutions before you start coding something, though -- in a great many instances, someone has already done the hard work for you :)

phils