Evil mode bindings for non-English languages - emacs

After years of Vim I discovered Emacs's evil mode and now I am utterly happy. And I'd like to use my native language in Emacs as well. I thought it should be fairly easy and someone probably have done that already and I've tried searching for "russian bindings for evil-mode" but surprisingly I found nothing.
And then I tried this:
(define-key evil-normal-state-map [ш] [i])
and of course that didn't work. Please help me to bind at least some basic motions. Otherwise I need to switch back and forth between languages all the time.

Oh... wow! I don't have to do anything. It's already there. toggle-input-method and I can even use Korean. Yet now I don't know how to get back to default. There's english-dvorak in the list, but I don't want dvorak. I need normal US-keyboard input.

Maybe too late, but you can use bindings from https://github.com/artempyanykh/evil-russian.
For example:
(define-key evil-normal-state-map "ш" 'evil-insert)

Related

Emacs - Clojure function highlighting (i.e. map, reduce, println, get, etc.)

I am currently using emacs24 with clojure-mode as my clojure IDE. I use the zenburn theme.
As far as I can tell, clojure-mode only provides syntax-highlighting for macros. Is there a way to add syntax highlighting for all clojure native functions?
I've googled a bit and it seems like I'm either the only one who wants this, or the only one that doesn't have it for some strange reason. I don't think my .emacs file is a necessary addition to this question but I'll add it if someone wants to take a look.
Thank you.
You need to explicitly enable font locking for these functions with clojure-mode-extra-font-locking. Install this package from MELPA, and add the following to your init.el:
(eval-after-load 'clojure-mode '(require 'clojure-mode-extra-font-locking))

Is there a way to reset the Emacs keymap?

I'm trying to figure out if there's a way to reset the keymap so that I can manually enable features with an appropriate keybinding. I'm trying to do a customized Emacs build and would like full control over the keybindings and features enabled.
Edit: Thanks for the answers, this answered what I was looking for perfectly. I was trying to Google it and I couldn't find much but now I'm starting to understand Emacs more.
Basically I'm trying to learn it and customize the keybindings to my preferences. Though I have had trouble overriding some keybindings but the suggestions of disabling major mode was what I was looking for.
Well, Emacs will give you full control, there are a couple different ways to accomplish what it sounds like you're trying to do. To be successful though, I recommend you read and understand the Keymaps section of the manual. If your customized Emacs build uses any major or minor modes, you'll have to do special work to disable/override any keymaps they set.
Of particular interest are the sections Creating Keymaps, Active Keymaps, Controlling Active Maps, and ... pretty much the whole chapter.
I recommend starting with creating a basic keymap and overriding the global keymap with yours. That'd be a good start. Probably the easiest way would be to do something like:
(setq global-map (make-keymap))
(global-set-key ...)
Though, you're also going to have to disable the major modes from setting up their keys, the easiest way would be to disable automatic choosing of major modes by doing this:
(setq auto-mode-alist nil)
Read the section on How Emacs Chooses a Major Mode.
The question needs more detail to enable writing a more detailed answer...
You may bundle the features into a minor-mode with its own keymap. When the minor-mode is enabled, its keymap will be consulted before the global-map, overriding the latter in effect. When disabled, the default key bindings in the global-map will be visible again.

Do I need to know Emacs Lisp in order to use GNU/Emacs

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.
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.
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.
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).
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).
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
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.
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 :)
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.
Depends what your goals and your interests are. Some people learn Emacs Lisp in order to use Emacs. Some people learn Emacs in order to use Emacs Lisp. ;-)

Emacs shortcuts for IDEA IDE?

I'm just switching from Emacs to IDEA and it would be a great help to me if I could use shortcuts like Ctrl-A for jump-to-line-start. etc.
Is this possible?
Go to Settings -> IDE Settings -> Keymap and you will have all the keymappsing.
One of the Keymaps you can select from is Emacs.
A note from a long time Emacs and IDEA user - Emacs bindings in IDEA are simply mission impossible. Arthur is perfectly correct about how to enable them, but they will seriously tamper with your IDEA workflow since they tend to override a lot of default IDEA keybindings and in the end you have to come up with completely custom keymap. This is not a problem the first time - but when you have to work on some coworkers machines, or on other computers it becomes extremely annoying. I used to hold my keymap in Subversion.
So basically don't use the default Emacs keybinding in IDEA - copy the basic setup and extend it personally. The IDEA server might be helpful to keep several computers in sync with the same keybindings.
Also keep in mind that only basic navigational commands are supported in IDEA and some helpful IDEA actions may wind up without keybindings by default so pay extra attention how you configure your IDEA.
For me there is only like place like Emacs - and that's Emacs. I have yet to see some software that provides sensible settings using Emacs keybindings.
There's a useful article on this topic here.
The gist of what it says is
You can tweak keybindings, but it's a bandaid at best, lost cause really
You can do better by LivePlugin Scripting with Groovy
You can create an escape hatch to emacs using emacsclient

How to quickly get started at using and learning Emacs [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
There are all sorts of advantages to using Emacs, but for someone comfortable with the usual Win32 applications it comes with a wall-like learning curve. With most other editors it’s possible to just start using them and then learn about their other features and enhancements as you go along.
How to just get on with using Emacs straight away, with the aim of reaching that point where you actually prefer to use Emacs over other editors or applications?
Edit - To try and clarify the question: I’ve done the tutorial, read some docs, etc. then soon after when I’ve wanted to quickly edit some text it’s been easier to just use another editor, that I already know. What do I need to do so that not only I don’t just go for another easier editor, but that I actually prefer to use Emacs, and how to get here as quickly as possible? What if any are the training wheels for Emacs?
The biggest thing about learning how to use Emacs is ... (drumroll please) learning how to use Emacs.
Okay, okay, okay. It's a silly answer, and it's a tautology, but it's true. If you start up Emacs, and think to yourself "How could I find every instance of the word 'foobar' in my source tree?" the worst thing you could do is hit Alt + Tab and visit Google.
Seriously.
Learning the help system and how it works is the best thing you can do. It's so nice to just hit C-h a find, and suddenly get all the information you need, right at your fingertips.
The next best thing you could do is install a wonderful little package called Icicles which has some seriously groovy completion functions. After you get it installed, just know that anytime the minibuffer is asking for some kind of input, you can now use regular expressions.
How would this apply to finding every file in your source tree? Well, you'd hit M-x, and then type "find". After that, you could hit (for instance) Shift + Tab and Icicles would kick in, finding every command that prefixes with "find". Alternatively, you could do M-x .find. and it would give you any command with find in it.
Build a cheat sheet. Just keep a saved buffer somewhere that has all of the keyboard shortcuts you use frequently in it. Remove the ones that you know off by heart, and pick up new ones. In most cases when you do a M-x command, the message buffer will tell you what the keyboard shortcut was for that command (if there was one).
Learn. Keyboard. Macros.
Learn. Emacs. Lisp.
Steven Huwig's idea of using some killer applications is a good one. Emacs is easier to use when you want to use it. For me, it was Planner Mode. (I've just moved to Org-mode, and it's even better.)
spend 20 minutes running the tutorial
ctrl-h t
That will get you to the point where you can be productive (and that "meta" key that you will read about is probably either Escape or alt).
I think it is easiest to find a "killer app" or two that just works best in Emacs. For me, it was the SQL editing and interaction mode for Oracle. Once you're already using Emacs for this killer app, then it will be more attractive to just open up other documents in Emacs rather than another editor.
Potential killer apps:
SQL editing and interaction modes
nxml-mode
AUCTeX
CPerl mode (best Perl mode there is)
PCL-CVS
SLIME
js2-mode (Javascript)
Learning to use Emacs effectively is inherently a slow process, but it's worth it.
Set up a .emacs file right away. You'll want to customize it quite a bit. It sounds silly, but having some kind of source control on that file will help, too.
To make it easier to find out about Emacs' innards, add to your .emacs:
(defalias 'ap 'apropos)
Then when you want to see if there's a command to do "something", type "[Alt-x] ap [enter] something [enter]". Emacs has its own name for stuff, so it can be hard to find things sometimes ("yank"? Seriously? Call it "cut" like everyone else!)
"[Ctrl-h f] function-name [enter]" looks up the help for that function.
"[Ctrl-h m]" shows you details about the current mode, like the keybindings specific to that mode.
Learn to use Ctrl-s and Ctrl-r for incremental search. All text editors need to come with this feature.
Add keybindings to your .emacs like:
(define-key global-map (kbd "M-z") 'redo)
(define-key global-map (kbd "C-z") 'undo)
Get the redo.el package to make Emacs' redo suck less.
iswitchb-mode is invaluable. It lets you have dozens of buffers open at once and switch between them in a blink of an eye. Set up iswitchb and add to your .emacs:
(iswitchb-mode)
(define-key global-map (kbd "M-RET") 'iswitchb-buffer)
To evaluate an emacs-lisp expression, type the expression into a buffer, put the cursor just after it, and type "[Ctrl-x Ctrl-e]". This lets you experiment with different customizations easily.
Remember, you don't have to let go of ctrl when typing a sequence like that.
See where a string occurs in a buffer with the "occur" function. Here are some handy functions and keybindings for that:
(defun word-at-point ()
(thing-at-point 'word)
)
(defun word-at-point-or-selection ()
(if mark-active
(regexp-quote (buffer-substring (mark) (point)))
(concat "\\")
)
)
(defun find-word-at-point ()
(interactive)
(occur (word-at-point-or-selection))
)
(define-key global-map (kbd "C-o") 'find-word-at-point)
(define-key isearch-mode-map (kbd "C-o")
(lambda ()
(interactive)
(let ((case-fold-search isearch-case-fold-search))
(occur (if isearch-regexp isearch-string
(regexp-quote isearch-string))))))
My ideas on how to come up to speed faster:
Find another Emacs user and watch them a few minutes every day
Have the Emacs user watch you (and provide feedback)
Find more Emacs users and repeat steps 1&2
Subscribe to the planet emacsen feed to see what other Emacs folks are learning
Follow the emacs tip of the day twitter
Try to answer folks Emacs questions on SO
I've been using Emacs for 15+ years and I learn a new thing every day by doing the things above.
Like #Claudiu said, just use it. Just bumble through and let your needs drive your learning curve.
Eventually you will get to a point where you "know enough to be dangerous", while not really mastering the environment. That's OK. Because at this point you'll likely be quite productive. You'll have the basic skills and tools.
In time, you'll run in to things that you do every day that you're simply sick enough of to try and take the time to find a "better way". Normally, your base skill set is enough to get by, enough that the (potentially unknown) time invested in to some alternate path isn't worth the cost, especially for something rare.
But, you may have free time, or the task might be big enough to justify looking deeper.
At these points you'll become more of an expert Emacs person than a journeyman user.
While I personally no longer use Emacs (instead relying on an IDE), I will say that while Emacs is quite complex, you need only know a small subset to make it useful and fun. I will also say that I've never "screamed at Emacs", whereas I scream at my IDE all the time. Yes, Emacs was doing less than what my IDE was doing, but I am seriously getting to the point that it might be worth my time to go back to it, and stop the screaming.
I just get this sense that Emacs is more "deterministic" than my IDE which likes to go traipsing off in to lala land every now and then, or require a restart, or whatever.
I've never personally crashed Emacs (which some will say means I'm not using it hard enough...)
Basic text editing with emacs is no more complicated than doing the same with Notepad. Just use it like it's notepad, but as you explore the menus, take note of the keyboard shortucts. Slowly you'll start to pick up things. When you want to do something and you don't know how, there's help available as a pulldown from menus, just like with other editors.
I guess the only "trick" I'd suggest is that after you open up a file for editing, try ctrl-h m to pull up a list of the keyboard bindings that work in that buffer's mode.
My advice is:
Learn the very basics (how to type, save a document, turn on syntax highlighting, maybe copy and paste). You can look up how to do these online (google "emacs tutorial" maybe)
Start using it.
Whenever you wish you knew how to do something, then look up how to do it. You might have to look the same thing up 3-4 times before you get it, but then you will learn it.
Keep doing this. It'll be annoying at first, but then you'll get used to it, and then you might even enjoy using it!
(DISCLAIMER: Personally I just use another editor).
Turn on icomplete-mode and you will often see functions that look useful when poking around.
(icomplete-mode t)
In your .emacs file.
C-h f will let you look up the docstring for a function, and C-h v will do the same for a variable. With icomplete, this is great for exploring.
As you learn basics like key commands, make your own cheat sheet. Of course find and plunder existing cheat sheets, but be sure to make your own and categorise the shortcuts / key bindings to groups that make sense to you. This will help you learn the basics and retain the memory.
Aim to customize Emacs into the editor you want, this is the single biggest advantage to using Emacs, and it will help you learn about all it's features and how it's extended.
Be glad that, relatively speaking, learning Emacs is much easier thanks to the community here on SO and other places like EmacsWiki. :)
Work from this point onward... a) Key bindings and customize. b) Macros and the macro editor. c) Elisp and your own custom libraries.
It's also worth noting that setting Emacs up to work like a more modern App, can be painful, you will need to do things like run the emacs server, and use the emacs client.
Thankfully (re: 3) there is a lot of help available on the net, but if you have direct access to a seasoned Emacs user, consider yourself lucky.