Emacs 24.4 RC 1
lists.gnu.orgAs someone who uses emacs purely for clojure/lisp and vim for everything else, the biggest feature for me is the fact that this will be the first version of emacs to support menus in terminal mode. So for all the commands you don't remember, a menu is now a click or F10 away. To quote,
"Emacs now supports menus on text-mode terminals. If the terminal supports a mouse, clicking on the menu bar, or on sensitive portions of the mode line or header line, will drop down the menu defined at that position."
More at: http://www.masteringemacs.org/article/whats-new-in-emacs-24-...
Have you tried Helm in Emacs? For me it binds to M-x, and I can find a "lost" command by typing just bits.
For example "M-x tree undo" show me "undo-tree-visualize (C-x u)".
Now I use Helm all over the place: (recent) file opening (within the current project), buffer switching, grepping, etc. It really changed how I interface Emacs.
What's the advantage of Helm to Ido?
Helm by default ands the query terms. Notice how he typed the second word first. Ido searches linearly. Helm is also much more ambitious in general
I prefer smex for M-x command matching (which is self described as Ido-style).
I wrote it in my guide: http://tuhdo.github.io/helm-intro.html#sec-2
Just curious. How did you manage to use both emacs and vim? I've seen that people accustomed to one editor are usually averse to using the other.
> I've seen that people accustomed to one editor are usually averse to using the other.
I think this is more a meme than necessarily a reality - you'll tend to see a lot more comments online from people who think the old joke is funny or who want to validate their own choice than from people who don't care or have tried both without such strong feelings.
In reality, there's really no barrier to 'manage' to use both emacs and vim. If anything, since they're both powerful and configurable programs whose best configuration is personal and some way from the default, it probably is harder to construct your own perfect config in both than for simpler alternatives like web browsers - I guess this may lead to a practical aversion.
Personally, I think vim's modal editing is superb but generally prefer the behaviour of emacs' modes and client model, so I use emacs with evil-mode but have no problem using vim if necessary.
I'd sign that. I never use emacs, because I never trained it, but I sometimes use it at a friends machine.
It's nothing I find bad or not understandable. All errors stem directly from my lack of skill. (and the different key layout of most of my colleagues)
Hehe because I don't subscribe to monotheism? ;) I prefer vim's modal editing mode and have been using it as my primary for as long as I can remember. For clojure/lisp, I found that the vim tooling was just not as elegant/efficient as emacs (fireside et al arent as nice as cider/swank), and decided to learn how to use it. It's not that much of an "antipattern" because the keymaps are very different. I don't like using vim mode within emacs either - for some reason I find myself thinking in emacs mode when editing lisps. I do think that I could be more productive in emacs if I invested more time in the tutorials, but so far it hasn't been an issue. To me, it's more like needing to know how to use Eclipse or IntelliJ to program in Java since their tooling is so great.
You might consider checking out evil mode. It's for real. Does not feel like emulation at all.
Ah, will check. I'm not sure how it will coexist with all the cider key bindings though?
It coexists pretty near perfectly, since vim and emacs keybindings are usually non-overlapping.
Can you tell me more about why cider > fireplace? I'm a clojure developer working in vim, I've considered moving over to emacs a few times, and I'd love to hear what you see as the advantages.
@MBlume - first and foremost, the installation process for me for fireplace was fraught with issues. I installed lein.vim, fireplace, and a bunch of other stuff from all the allied projects : as much as I love vim, it was too much overheard for me to just go through all that! Once I did get it working (and after having worked with emacs/swank/lisp before) - it was just very unintuitive to me. It also feels much slower than cider, and doesn't offer things like the inspector for stack traces and things that cider can. Most importantly, I think the inferior mode in emacs is just a pleasure to use in terms of functionality - I've used it with R, lisp, clojure, and ipython. It's a very neat/clean interface.
There's also the fact that all of these modes are a simple M-x-package-install <package-name> away and they just work. It's kind of like choosing OS X for me after using Linux as my main OS for years and years - I didn't have to worry about the wifi card not being detected or my dual screen display needing a lot of kernel modules : things just work :)
Not really. There are lots of people who get off on imaginary rivalries and enjoy exaggerating the virtues of what they like and the flaws of what they don't like. Some of the more self-aware people know what they're doing and consider it all in good fun, but the dumb ones just go along with it because they actively enjoy engaging in tribalism.
See also casual sports fans who don't understand the game they watch, but understand and enjoy pretending to love one team unconditionally for no particular reason, and hating another team for no reason other than it's fun for them to hate somebody. Ditto for operating system fanboys of all stripes.
I typically use Vim for quick edits on my Mac, and especially on remote boxes.
But for Haskell and Clojure development, it's hard to beat the tight integration features that Emacs provides (e.g. quickly piping your code or a single function to the REPL for testing). Vim is not designed for this; there are plugins available to approximate it, but it’s a bit hacky and nowhere close to Emacs).
Honestly, it's not hard to learn the basics of both. If you're accustomed to Vim commands, Emacs has `evil-mode`. There's also the slick `god-mode`, which is like Vim's Normal mode for Emacs.
Both tools are great in their own ways. Personally, I regularly use and love them both.
How about yi (https://github.com/yi-editor/yi)?
I hope some day an editor, written in Haskell, allowing to emulate Vi and and Emacs behaviour will become more appropriate for Haskell programming than any other editor and offer you to either the Vi or Emacs style.
Personally, I started out using Emacs because I wasn't a big fan of the "modal" style of vi (insert/command mode). Later on, I started pair programming in shared GNU Screen sessions, in which we ran vim; a pile of "how did you make that change so quickly" questions later, and I ended up switching to vim for the speed of basic text editing tasks, which save more time than I lose by not having as many high-level mode-specific commands.
However, I still use Emacs for LaTeX documents via AUCTeX, because I find it far more powerful for basic editing, with commands to insert directives, environments, \item, etc.
' "how did you make that change so quickly" questions later, and I ended up switching to vim"'
Heh... what a perfectly beautiful little invitation to a flame-war. If it was about 5 years ago, I would have fallen for it in a minute ;-)
It didn't sound like an invitation to a flame war to me at all. It sounded like his honest personal experience.
If you are a Unix user, you almost need to know enough vi to edit a simple file. crontab -e is considered a minor sin in the Church of Emacs, but only a minor one.
ESC:q!
export EDITOR=emacs
Then crontab -e will start emacs instead of vi.
Try:
and set up Emacs to run (server-start) on startup.export ALTERNATE_EDITOR=emacs EDITOR=emacsclient VISUAL=emacsclientThis way, crontab -e should open a new Emacs frame (or start Emacs, if it isn't already running). It will speed things up and make the experience better, while giving you access to all the things you're working on in an already running Emacs.
See also: http://www.emacswiki.org/EmacsClient.
If emacs is installed. It often isn't. vi almost always is.
I know enough vi to open a file, move up, down, left, and right, search, delete and insert text. And I often run afoul of my emacs muscle memory just doing that. But you really need to know the vi basics if you admin unix machines.
I’ve learnt enough ed to use that instead of vi. If that isn’t installed, I’ve had to resort to nano, and, in rare cases, sed --in-place. But I never need to know vi.
Of course I realize that this is mostly me being silly, but it’s also rather educational.
You are absolutely right. Especially if we are talking about BSD or Unix proper. But, there is a cognitive load to remembering what machine you are on, or if certain variables have been set and so on.
I have been on machines that fire up nano with crontab -e, in the name of user friendliness. These same machines will not respect EDITOR or VISUAL anyway, so I have no idea what to do about them. I usually just get up and creep away making sure not to turn my back on them.
I used both back in college. I usually used XEmacs for coding and reading mail/usenet and vi for sysadmin stuff. These days I've moved on to IDEs for coding and only break out emacs for editing binaries or large files.
It worked out pretty well as long as I used Emacs in an X window and vi on the command line. But if I ran emacs in a terminal, I automatically started typing vi commands into it.
I use Evil for that: Vim-style editing in Emacs, best of both worlds.
Emacs has had console menus for years. The difference is that they're now clickable, not keyboard-only.
Right - but the fact that they behave more like a window manager menu than ever before - as in, they drop down et al.
As a dev who's always used Sublime/Atom and sometimes Vim, what's the benefit of Emacs for Lisp?
Slime is really amazing. It provides tons of features of which here are a few (these work with Common Lisp, I have no clue if they work with Clojure).
Inspector[0]: You can click on objects to "inspect" their values. This includes hash-tables, arrays, and closures. In addition you can execute arbitrary code on these objects at any time, even while a program is running.
Trace Dialog[1]: Most Lisp implementations already provide a way to trace procedures. Tracing normally consists of printing the input and the output as each traced procedure is called. Slime provides something much more powerful. Slime's Trace Dialog is similar to trace in that it creates a buffer of the input and output, but instead it is provided in a tree menu format. In addition it is possible to inspect all of the values in the Trace Dialog with the inspector.
Debugger[2]: When an error is thrown in a program, a window pops up which provides several things. You can click on a stack frame to see all of the variables in that frame and then inspect those variables with the inspector. You are also provided with a list of restarts[3]. In addition, you can return a value from a given stack frame, or retry a procedure call on the stack frame (you may have modified the definitions of some procedures before you did this), and have the program continue as if nothing had ever happened.
There are also many other features, such as the ability to macroexpand code by clicking on it, to look up every procedure which calls a given procedure, to look up every place in which a given variable is set, and many other awesome features.
[0] http://common-lisp.net/project/slime/doc/html/Inspector.html
[1] http://common-lisp.net/project/slime/doc/html/SLIME-Trace-Di...
[2] http://common-lisp.net/project/slime/doc/html/Debugger.html#...
[3] http://en.wikibooks.org/wiki/Common_Lisp/Advanced_topics/Con...
Restarts are feature of Common Lisp, for which SLIME only draws a powerful interface. Your ability to return a value/retry a call from a given stack frame is just a bunch of default restarts of your CL implementation. What is really awesome is that you can add your own restarts to the interactive debugger. Or have them execute automatically.
I recommend those who are not familiar with conditions/restarts to read up a bit on them. This is something like exception handling, but an order of magnitude more powerful.
> Your ability to return a value/retry a call from a given stack frame is just a bunch of default restarts of your CL implementation.
Almost. Restarts and value/retry on a stack frame are mostly unrelated - Restarts are only the UI for implementation specific features. Common Lisp provides no feature to retry an arbitrary stack frame. This is all implementation specific functionality provided by SOME implementations.
That actually sounds a lot like Smalltalk.
Also the editor does not crash if the (lisp) environment becomes unstable (hangs, crashes, etc.) - Such things rarely happen, but they might - for example in Lispworks (which has emacs-like IDE (very nice) but runs the lisp threads in the same process as the editor).
I can speak about Clojure support for Emacs a bit, but I don't know how much of this Sublime or Atom can do.
I like the cider+nrepl workflow myself. You can edit your code, reevaluate it, and test it without having to restart your JVM. As you can imagine, this really speeds up development.
Also, though I haven't quite grokked all the barfing and slurping yet, paredit has really become a huge part of my code writing and editing in Emacs for Clojure code. I am on the cusp of getting barfing and slurping working for me now ;)
There's quite a lot of technology that allows you to write lisp/clojure very well in emacs. Some that come to mind,
- Swank/Slime (Lisp inferior modes) that allow you to write lisp, evaluate within the editor, see your results in a buffer. Offer auto complete, refactoring, debugging et al.
The more recent nrepl and cider modes for Clojure build on top of slime/swank and offer extremely great tools to write code as well. If you ever wanted to have the REPL running on the side and have great interop between code in a file and the REPL - these modes are great. Imagine their power when you can connect into a running webserver and debug on the fly from within your editor.
- A lot of original emacs plugins like paredit have now been ported to other platforms like Sublime. Also, emacs itself is written in lisp, which makes it a first class language it supports at its very core.
Each lisp varies dramatically in its semantics. Just because emacs is written in e-lisp does not mean it has first class language support for every other lisp. Would you say that vim has first class support for every language with block & statement based languages?
Agree with your high level point. Mine isn't that because it's written in e-lisp, emacs supports every other lisp. The fact that it's written in e-lisp makes it very extensible, and some standard things like C-x C-e to evaluate forms et al, which were originally developed for and are the standard for e-lisp, have been adopted for all other lisp modes as well. The very fact that the editor is written in a lisp makes it expose useful functionality this is useful in other lisp contexts.
Aside from all the other reasons other people already listed, there is a one fundamental benefit. Emacs is not just an editor, it's a Lisp runtime with text-editing functionality bolted on top. Lisp is natural for Emacs at all levels of complexity - from the fact that it's easy to work with Lisp code using Lisp to the Emacs community, composed in a big part of Lispers. Lisp just fits Emacs.
Emacs is pretty much a built in REPL primarily written in Lisp.
Slime
I hope this terminal mouse business is easy to disable. If I wanted mouse clicks to be registered by emacs, I wouldn't insist on installing emacs-nox versions in the first place.
M-x apropos is usually good.
This release has so many incredible new features. Great job Emacs team!
I recently discovered that elisp is dynamically scoped as opposed to lexically scoped. Out of curiosity (as I've never programmed in a dynamically scoped language) hows the experience of working in such language?
Fwiw, you can lexically scope it now if you want. The default is still dynamic scoping to avoid breaking backwards compatibility, but you can enable lexical scoping for your own code: https://www.gnu.org/software/emacs/manual/html_node/elisp/Le...
Having spent a lot of time with Haskell and Scheme, what irks me the most about working in Emacs Lisp is the fact that it usually involves too much rigamarole or just fails to work for me to use a function that takes a function as an argument or returns a function as a result. E.g., in Haskell, I am fond of using `flip` to reverse two actual arguments just because it makes a line or 3 of code look nicer, and I cannot do that in Emacs Lisp -- or I can, but it involves adding additional lambda forms or calls to funcall or symbol-function (i.e., it involves too much rigamorole).
Since I cannot say exactly how far lexical scoping would go in making Emacs Lisp more like Haskell in this regard, this is only a partial answer to your question, but certainly, the lack of lexical scope has something to do with it.
Aside from the deficiencies I just mentioned around higher-order functions, I was surprised by how little the lack of lexical scope got in my way. (My reading of the computer-science literature had given me the impression it would cause more trouble than it actually does.)
Elisp is not Scheme and certainly is not Haskell. You shouldn't - and I'd say it a good general rule - judge Elisp based on what it's not instead of what it is.
Getting back to actual question: Elisp supports "real" lexical scoping since previous major Emacs version, and it has had "lexical-let" and other such forms since forever, but most of the code is still dynamically scoped. In practical terms it's similar to having every variable declared as global - it allows for "out of band" communication (outside of arguments passed/value returned) between routines. This is sometimes handy if you want to change some function behaviour in a way that it didn't think of (ie. it has no argument dedicated for this). As a very contrived example, if you have a routine which beeps furiously every time you invoke it and you find it unbearable (I did) you can instead call it like this:
And it won't beep any more. A real life saver sometimes ;)(letf (((symbol-function 'beep) (lambda ()))) (beeping-function))On the other hand, every out-of-band communication has a set of problems to it: you can forget to check it, or you can accidentally pass something to a called function you didn't want to. In practice this is worked around with using longer, prefixed identifiers and the semantics of `let`. As long as every variable your function uses is let-bound inside it it is essentially safe to call with any kind of environment, as it won't ever look at it. Most functions are like that.
In short, dynamic scoping has it's advantages and drawbacks, and it feels quite well suited to an extension/scripting language of an app. It makes certain patterns easy enough that they don't even need a name ("monkey patching"), and it makes others much harder (like the linked dash-functional library, which would be very hard to write without lexical-scoping: t).
Your code fails to suppress beeping behavior on my Mac for certain values of beeping-function. In particular, when I eval the following, I get a beep.
I tried to repair it: I ran the code in a fresh Emacs session to which my usual customizations in .emacs had not been applied. I set lexical-binding to t. Since beep is an alias for ding, I replaced beep with ding. I rewrote the letf as a cl-flet.(require 'cl) (setq lexical-binding nil) (defun beeping-function () (save-excursion (set-buffer "*Messages*") (goto-char (point-max)) (scroll-up))) (letf (((symbol-function 'beep) (lambda ()))) (beeping-function))I think that the fact that scroll-up is built-in is pertinent: there was another incident in the recent past in which the function whose binding I wanted to override ("shadow"?) is called from a built-in function and in which my attempt to use cl-flet to override the binding failed.
If you have Emacs running on a Windows or Linux machine, I would like to know whether the above code causes a beep on that machine. I would like to know because in the past, code that gets a little tricky about bindings that worked on my friend's Windows box failed to work on my Mac (even with an up-to-date Emacs).
ADDED: Actually, let me show you the code that "worked" (i.e., behaved like someone familiar with Scheme or Haskell would expect modulo the trivial "rigamarole" of needing to use funcall) on my friend's Windows box but not on my Mac. The error is "(void-variable a)".
(funcall (funcall (lambda (a) (lambda (b) a)) 1) 2)As you can easily check with M-x find-function a `scroll-up` function is implemented in C. This is a known problem - I can't find it right now, but I remember I once read a blog post where the author complained about this: in general you're not going to get good results when trying to advise, override or modify C-level functions from Elisp code.
IIRC cl-flet was recently (well, in the current decade I think :)) modified to be lexically scoped, so that won't work (anymore). This is why I had to use `letf` with `(symbol-function 'symbol)` instead of a neater `(flet ((beep ())) ...)`.
Personally I deal with beeping like this:
but this disables any beeping, which may not be what you want. In short, things you `setq` or more generally `setf` tend to be visible from C functions (no guarantees though).(setq ring-bell-function (lambda ()))On the other hand my Emacs (on Linux) refuses to beep in any circumstances even if I run it with `emacs -Q` and do M-: (beep) - I have no idea why, I suspect it's either my sound configuration or has to do with the way I built my emacs from source.
I'd say for this:
raising a (void-variable a) error is correct behaviour under dynamic scoping. On my system (Emacs 25.0.50.2 x86_64-unknown-linux-gnu) it fails with void-variable under normal circumstances, but returns 1 when used with lexical scoping enabled. If your Emacs behaves differently (and remember to always check with emacs -Q just to be sure it's not something in your config) that's probably a bug.(funcall (funcall (lambda (a) (lambda (b) a)) 1) 2)>If your Emacs behaves differently . . . that's probably a bug.
Yes, it behaves differently (with lexical-binding set to t and with the -Q flag).
Very nice! I notice that some bugs have been fixed since I last tried the latest development version(~4 months ago).
I really like the enhancement to C-x TAB to use the arrow keys to adjust the indentation on the selected region.
I'm hoping that the Mac OS X build (http://emacsformacosx.com) will soon link with libxml2 so I can use the eww browser. :)
Is there a reason you don't use the Homebrew version of Cocoa Emacs?
I did not know about Homebrew's Cocoa Emacs. Thanks for the tip. I'm installing it now and will see if I get 24.4 with eww or some previous version (minus the eww). Thanks again!
If you ran the install with --devel you should get 24.4-rc1
Thanks for the advice!
How's this compare with Aquamacs (http://aquamacs.org)?
My feeling is that it's much better than aquamacs. Aquamacs does some things enough differently to regular emacs that I just fine working with homebrew emacs (or emacsforosx) less effort when installing new packages.
I have installed Emacs-2014-10-21_01-40-00-118172-universal.dmg and it has support for libxml2 and eww. I'm very happy.
> "As always, if you encounter problems building or using Emacs, please send a report to address@hidden with full details"
What's up with "address@hidden"?
This is the web representation of a mailing list email, and the software that prepares the message for viewing on the web conceals email addresses like that, to help mitigate people receiving unwanted mail (e.g., and probably especially, spam).
Had you been on the mailing list and received this content via mail, the address would have ostensibly not been concealed.
There's also M-x report-emacs-bug (also accessible from the menu Help -> Send Bug Report... which (somewhat) automates bug reporting.
It also populates all the information useful for devs.
The reporting address seems to be bug-gnu-emacs at gnu.org
The current plan is to release on Monday.
Cool updates! is it bad that I still try my best to avoid emacs ? One of my professors loved it, and it just ruined my ideal text editing environment.