Can emacs sessions (open buffers) be restored on a restart [duplicate] - emacs

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Restore Emacs Session/Desktop
I am using emacs for development. And there may be many buffers open. Is there a way that I can save the state when I close emacs. So that when emacs is again opened it restores the different windows?
I am looking at what browsers are able to do for restoring a previous browsing session.

Generally speaking, you don't ever "close" your Emacs. That's not meant to be a joke. The general style of working is to keep an Emacs running all the time and to just open new buffers in there using emacsclient. This is different from the vim style where vim is continuously opened and closed.
However, your question is an old one which has been asked by a lot of people and a lot of solutions have been proposed and coded up. There's a list of them on emacswiki. You can pick one that works for you.

Related

Equivalent of vim mksession on emacs

I started working on vim about a year ago, and decided to try out emacs.
I really like it so far but there is a functionnality I'm missing on emacs : the ability to save your session as it is right now (the different buffers and local commands, aliases, etc) and reopen it later.
In vim, it takes a simple :mksession session.vim and :source session.vim
How can I find the same behaviour in emacs?

Execute PowerShell without leaving gVim [duplicate]

This question already has answers here:
How to execute file I'm editing in Vi(m)
(13 answers)
Closed 8 years ago.
I'm currently using vim to edit several PowerShell files, but I'm finding it to be a real pain to always have to go back to my PowerShell console to run the scripts.
Is there a plugin that would allow me to either a) run the current script and/or b) run selected text. I've seen videos where such thing is done for other languages, but I can't for the life of me find the plugin.
This article gives a pretty straightforward description on how to do this. You are wanting to run Powershell through VIM correct?

IDE typing mode, emacs or vim [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
First of all, this is not a question on emacs vs vim. I use eclipse IDE for programming and I intend to continue using it. Having read many advantages of emacs and vim, especially the ability to do almost anything without using the mouse, I want to use a similar typing/editing scheme in my eclipse IDE; I'm aware that there are plugins available for eclipse to change the editing style to emacs or vim (emacs+, vrapper to name a few..).
Since I plan to continue using eclipse, the various advantages of vim and emacs like small memory foot print, vim/elisp scripting, availability on different platforms, configurablity etc are all lost. I want to import only the text editing scheme to eclipse and master it while keeping all of eclipse's features.
So, I would like to have an objective comparison of the benefits/disadvantages of only the text editing styles of emacs and vim.
EDIT: the reason I cannot move away from eclipse is because my company uses a customized version of eclipse which has specific plugins and dsls to interact with our product(hardware)
I cannot move away from eclipse because my company uses a customized version of eclipse
Please note that Vim is not an IDE (a search will bring up various discussions of this topic), therefore this dichotomy does not exist. You can very well use both Vim (for text editing) and a real IDE (for debugging, source code browsing, etc.), in parallel. A simple "launch current file in Vim" integration is quickly done, and you've already noted that there are several plugins that bring the basic key bindings (but not the huge customizability) into the IDE.
Also, it strikes me as odd that you have no preconception of Vim vs. Emacs yet. Most people breathe and live their key bindings so much that they desire them in their IDE, too; you just seem to "have heard" about those advantages, but haven't experienced them yet.
My advice: Use your IDE for work (as you have to, anyway), and try out Vim (as well as Emacs) in parallel, maybe for recreational tasks, a little scripting, blogging, whatever. You can then see for yourself whether you'll "get hooked" on one of them, or maybe the IDE will just work out fine for you. Also, time will tell whether a simple integration is sufficient, or whether you want something tight and deep like the Eclim project.
I can only tell something about vim, I have used emacs once in a while, but it doesn't seem to be compatible with me. Although I really like scheme which is a lisp dialect. Vimscript is a horror to program in, but it is possible.
The main feature vim offers is that it adds structure to text beyond the syntax of your language. You can manoeuvre, edit and transform your text with vim's movements. These are at the heart of vim and have to be learned well. This in combination of modes, makes vim a powerful tool for text editing.
On the other hand, for code editing, vim needs some modifications to be useful. You will a considerable amount of configuration. Most people keep their vim configuration in a fire and bullet-proof safe, so they will not lose their painfully built stack of options, plugins and other configurational paraphernalia. That is including me. A vimrc is quite personal. Emacs is easier to configure. I could pick it up much faster.
You have to learn a tremendous amount of knowledge to even be able to use it. Emacs is much easier, you can use it at once. My first encounter with vim was being not be able to leave the damn program, whatever I did. My second encounter, was carefully hitting i and the type some text and quickly hit :wq. But somewhere later I suddenly wanted to tame it.
Vim has macro's, which make a lot of text transforming tasks fun. E.g. this removes al spaces at the end of a line, something I sometimes run to stop the nagging of pylint about spaces:
qs:g/ $/s///g<CR>#sq
You should read this as: record a macro in register s, replace globally all spaces at the end with nothing, apply macro in register s, stop recording. When hitting:
#s
This macro will run endlessly, until you are satisfied. I still want to find one, which stops after he hunted the last space. This makes vim fun, it is a little language with one letter commands. You can combine letters together:
4f,d$
This means find he 4th comma (,) and delete (d) the line from there till the end ($). That makes it quite attractive.
I would personally go for vim, but you have to try the editors out. They have different philosophies and one of those will bite you and the other will seem reasonable. I don't believe you will find many people, who uses both and mastered both. They are both usable as code editor.
I still have emacs on my wishlist, maybe I will swap.
I would suggest reading these answers as they contain a good amount of differences between the two (although a lot of the benefits mentioned don't matter for you). I strongly suggest just trying them out.
A big difference that you will notice is that Vim uses modes, which makes it have a high initial learning curve, while Emacs is modeless, and you can use it like a normal text editor (notepad), but with added functionality. And his is where your style/preference matters. I personally don't like holding control down to move around in Emacs, where in Vim, you escape to normal mode and use hjkl to move around.
This might be of interest:
https://github.com/senny/emacs-eclim
It's a frontend to eclipse, providing Emacs features alongside with Eclipse, not just to mimic Emacs-keys only.
Some screenshots here:
http://www.skybert.net/emacs/java/

What guide should I read to start learning Emacs? [duplicate]

This question already has answers here:
How do you learn proper Emacs? [closed]
(11 answers)
Closed 9 years ago.
I don't really know if this is a decent question or not, but I am fairly new to programming and looking for a good text editor to use. I have read this question on Unix.SE and this question on SO which have convinced me that Emacs is the way to go. But I can't really find any good documentation that is aimed at people who have no idea what "M-x-foobar" means. Once again, this is probably too subjective for SO, but I thought I would try anyway.
If you're just starting programming, you've probably got enough on your plate without dealing with a crazy moon editor! gedit (Linux), Notepad++ (Win) or TextWrangler (OS X) are all free and may be more familiar to you.
Still, Emacs is great if you're game. I learned from a couple of resources:
O'Reilly's Learning GNU Emacs
Emacs' built-in tutorial - press Ctrl-h and then t.
These got me up-and-running quickly.
After you've learned the very basics, you'll want customize Emacs to make it more confortable. Download someone's Emacs configuration off GitHub and tweak that. The Emacs Prelude is very good.
From then on, it's all about building muscle-memory:
Try to use Emacs for all the random mundane typing and editing you normally do
Use the Emacs movement keys wherever you can, such as in your terminal program
If you use OS X, most of the emacs movement keys work in text fields. Use those instead of the arrow keys to move around.
Emacs has a reputation for being hard on your hands - the key combos were designed for older keyboards from a more civilized age. If your pinky starts to hurt while you're learning, it's a good idea to remap your Caps-Lock key as Ctrl.
According to my experience, Emacs is a huge topic to cover. I'd suggest you to start with its tutorial by selecting the first entry in the "Help" menu (or pressing Ctrl+h, then pressing t, which is denoted C-h t in Emacs style).
Then just follow your needs by reading specialized articles or documentation. A bunch of useful information you may find in an Emacs Info, which can be called by C-h i (Ctrl+h, then i).
Knowing at least a bit of Emacs Lisp would be very useful as it's used to configure the editor and sometimes helps understanding how some things work. For that you may find useful An Introduction to Programming in Emacs Lisp (but you may find it in Emacs Info as well).

Emacs keybinding hall of fame/shame [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
What are the best and worst emacs key bindings in development software? Ever since I learned it, I find myself trying to use C-p and C-n to move up and down in everything that has a text box on it.
I'm perpetually annoyed by software that has an emacs mode that's pretty obviously either put together by someone who's never used emacs before or it's done in a crappy manner. So let's recognize the winners and losers in this thread.
A Valiant attempt
Eclipse Emacs bindings are decent when editing. In some dialog boxes, however, they mysteriously break and copy reverts to C-c and paste to C-v. An irritation.
A nice Mac OS Bonus
On Mac OS, all Cocoa applications support basic emacs key bindings. This works out quite well because native Mac apps don't use the control key for anything so there's no chance of conflict. This also means that you can pick up almost any text editor (or word processor) on the Mac and have at least basic Emacs keys.
An unexpected Benefit
This even means that Oxygen (an XML editor using the Swing GUI toolkit) supports Emacs keybindings, but only on the mac. I assume this is the case because Apple is actually using a heavyweight (Cocoa) text widget to implement the Swing text widget in their LAF.
On other platforms, I often use the Eclipse plugin version of Oxygen just to get my keybindings back.
Ugly
G^%$&^% F^%$ StackOverflow for overriding some of the Cocoa Emacs bindings with some Javascript crap on the Mac. Very annoying.
C-k (kill-line) is bound to (insert-this-crap `print("code sample");`)
C-b (backward-char) is bound to (insert-this-crap **strong text**)
C-e, C-a, C-p, C-f, C-n work as expected.
These SO shortcuts are neither documented, nor do they appear to be customizable. They also aren't particularly useful.
Reported as a bug here: http://stackoverflow.uservoice.com/pages/general/suggestions/72686
[This is an example of a bad EMACS binding from an editor that wasn't even trying to be EMACS-like.]
I once found myself moving backwards and forwards between EMACS on Solaris and SOL on PRIMOS.
On Emacs, C-p meant go up one line.
On SOL, C-p was apparently an undocumented command that meant quit the editor without prompting or saving!
I lost a lot of work during that period, let me tell you.
The good
Um... emacs? Haven't found any software other than emacs that does a decent job of making the environment emacs-like enough.
The bad
SQL Developer by Oracle - seriously, does it have to be that difficult to make C-p do something other than print?
Meh
Visual Studio - Overall, the emacs mode is passable, but it's pretty obvious in some places that you're using a Microsoft IDE and not good old emacs.
Firemacs stops me bringing up the "save page" dialog every time I want to search in Firefox. It's a bit flaky but I find it more accessible than Conkeror, even though it looks like that has much more faithful Emacs bindings.
Along the lines of the OP's comments on "C-p to print", I think I've wanted to save maybe one or two web pages in over a decade, so I'm a bit puzzled why Firefox has it on such a common key combination as C-s.
Bash supports some Emacs keys (C-p, C-n, C-f, C-b, C-Space, C-w, C-y, C-a), but when I use screen I find it rather confusing, that I should enter C-a a C-k to kill the line. So it might be a good idea to change screen prefix key to something else.
[This is an example of a bad EMACS
binding from an editor that wasn't
even trying to be EMACS-like.]
I once found myself moving backwards
and forwards between EMACS on Solaris
and SOL on PRIMOS.
On Emacs, C-p meant go up one line.
On SOL, C-p was apparently an
undocumented command that meant quit
the editor without prompting or
saving!
C-p in PRIMOS meant "break" everywhere (like C-c in Unix). I believe it was there before Emacs was ported to PRIMOS, so it was easier to change one program than umpteen-thousand users and customers. I learned Emacs first on PRIMOS and it took me a couple of years to later feel comfortable with C-p :-).