66 points · by Adrock · 12y ago · 38 comments
The most useful packages for me, things I wish I'd known about from the beginning:
* package, pointing at GNU and Milkbox repos. Any time I edit a new type of file, I look for packages that work well for it.
* helm, much better than flex matching for my purposes. I use helm for all list completion except find-file, for which I use ido-find-file. helm-git-grep completely changed the way I work with mixed-source RoR projects, to the point I've fully abandoned RubyMine.
* projectile, mostly just for finding files across a whole git repo. I use helm to complete the file to find (setq projectile-completion-system 'helm-comp-read).
In addition, it helps enormously to not be afraid of Lisp. Emacs isn't really worth it if you're not interested in tweaking it, IMO. I had to tweak it quite a bit in order for it to play well with rxvt, my preferred terminal; and even further to get it to work well with screen in rxvt, and with mintty on Windows, and screen inside mintty. A familiarity with how termcap works, the esr's showkey utility, and a bunch of time with define-key got it sorted.
Here's a function I use a lot (bk-helm-occur at the end):
(defun get-point-text ()
"Get 'interesting' text at point; either word, or region"
(if mark-active
(buffer-substring (mark) (point))
(thing-at-point 'symbol)))
(defun helm-occur-1 (initial-value)
"Preconfigured helm for Occur with initial input."
(setq helm-multi-occur-buffer-list (list (buffer-name (current-buffer))))
(helm-occur-init-source)
(helm :sources 'helm-source-occur
:buffer "*helm occur*"
:history 'helm-grep-history
:truncate-lines t
:input initial-value))
(defun bk-helm-occur ()
"Invoke helm-occur with initial input configured from text at point"
(interactive)
(helm-occur-1 (get-point-text)))
(global-set-key (kbd "M-o") 'bk-helm-occur)
It lets me press Alt-O on any symbol and see all occurrences of that symbol in the file. I can then jump to uses, then use helm-resume to find the earlier occurrence and jump back. I have a similar function for a pre-initialized helm-git-grep.It's these kinds of customizations that make emacs shine. Any time you find yourself doing anything repetitive or tedious, you can usually hack a function up in a few minutes that improves your workflow. Prototyping Lisp functions is completely trivial owing to the ability to evaluate Lisp in the buffer.
Additionally, 'EmacsLive' [3] focuses on Clojure support.
[1] https://github.com/bbatsov/prelude
My own .emacs is the result of nearly 10 years of tinkering, which I (like subsection1h) enjoy. Actually, I probably enjoy it too much, I've spent quite a lot of time procrastinating by tinkering with emacs … and this is why something like Prelude doesn't make sense to me, why would I let someone else do all the tinkering for me? =P
By the way, in my experience most packages tend to stay out of the way of others (e.g. turning on ido everywhere doesn't stop you from using jedi/midnight/sauron/org/magit/etc.), unless they are specific to a certain mode (jedi and ropemacs and traad all try to solve more or less the same problem, ie. python code assistance, so don't run them at the same time).
https://github.com/search?q=Emacs&type=Repositories&s=stars
I haven't used any of these starter kits because the starter kits that I've used for other platforms/frameworks caused me more trouble than they were worth and I generally need to devote only one weekend per year to Emacs tinkering, which I enjoy.
Interesting.
Obviously, this type of data submission should be tied into something like package.el, though it is fraught with error.
For example, I use pry and associated debugger stuff when working with Ruby. Want to set a breakpoint more precisely than a method? Need line numbers. Why would I not want that inside an emacs buffer? Because pry's symbolic completion is integrated with readline.
Pair programming; I just describe the position in the program. Humans are much smarter than computers. "You see where you're catching FooError in Bar?" You can also use your finger to point.
Anyway, I'm not saying you never need to know the line number, but I'm saying it's not the movement idiom in Emacs. In vi, all the motion commands take line numbers as arguments, so you use line numbers to navigate. In Emacs, the commands don't take line numbers as arguments, except for goto-line. (In this case, a leap of faith is necessary. Something tells you, error on line 42. So you tell Emacs to go to line 42. The line you are on now must be line 42. QED.)
For stuff that is not on-screen, then it's the good old ways.
iswitchb-mode seems to do some of what ido-mode (which I've never tried) does.
Correct.
I have S-delete, C-insert, and M-insert bound to cut, copy and paste respectively; S-insert pastes the system clipboard in the terminals I use. I use these when doing a lot of moving text around.
I do have C-v bound to yank, and M-v bound to yank-pop. C-y is a very awkward keystroke.
But C-w isn't too hard to use for cut, nor M-w for copy, when avoiding the arrow keys / edit block.
I agree that CUA mode without binding the CUA keys is useful.
By the time I learned of CUA mode I a) got used to C-y/M-y/C-w/M-w; and b) already written "free-rectangle-mode" which gave me the same freedom of movement when selecting rectangles. It was one of my first emacs hacks :) Combined with rect-mark mode it would probably look very similarly to CUA rectangular selection, but I didn't feel the need for showing visual rectangle. Also default rectangle handling has a big advantage of starting both line and rectangle selections with the same key.
Anyway, I'm not surprised people don't use CUA very much - I think that by the time they learn about it it's already too late for them :)
(when (fboundp 'cua-selection-mode)
(setq cua-toggle-set-mark nil) ; o/w C-SPC doesn't set the mark if region-active-p
(cua-selection-mode 1))
See
http://trey-jackson.blogspot.no/2008/10/emacs-tip-26-cua-mod... for why cua-selection is awesome.