Live data from Hacker News

My Emacs Productivity Tricks/Hacks

mycpu.org

61–70 of 210 posts

Re: My Emacs Productivity Tricks/Hacks

#61
post #47

What is the emacs equivalent of package.json? (whenever I git clone my dotfiles on a new machine I usually have to comment out a bunch of stuff in my ~/.emacs because it's referencing packages which aren't installed, and I forgot where I installed them from, what version, etc...)

Alternatively, if your workstations are all relatively similar, you can sledge hammer it and just commit all of ~/.emacs.d/ into a private repo, including the packages. It saves me the headache of babysitting dependencies (at the cost of probably not being able to move to Linux without some friction? Never tried.) Caveat emptor.

Additionally, I recommend judicious use of (when (boundp 'some-thing) (some-thing)), and (fboundp ..), and (if (require 'foobar nil :noerror) (foobar-mode 1)). This avoids the cascade of errors on installation troubles (at the cost of not being alerted if you're missing them).

Re: My Emacs Productivity Tricks/Hacks

#62
post #47

What is the emacs equivalent of package.json? (whenever I git clone my dotfiles on a new machine I usually have to comment out a bunch of stuff in my ~/.emacs because it's referencing packages which aren't installed, and I forgot where I installed them from, what version, etc...)

I think you're looking for https://github.com/jwiegley/use-package ?

That looks awesome! All of a sudden I feel so primitive with https://gitlab.com/brlewis/brlewis-config/blob/master/emacs/...

Re: My Emacs Productivity Tricks/Hacks

#63
The one thing I consistently do in emacs that shocks my coworkers -- is running this (custom) function, that I call "arrayify":

  (defun arrayify (start end quote)
    "Turn strings on newlines into a QUOTEd, comma-separated one-liner."
    (interactive "r\nMQuote: ")
    (let ((insertion
           (mapconcat
            (lambda (x) (format "%s%s%s" quote x quote))
            (split-string (buffer-substring start end)) ", ")))
      (delete-region start end)
      (insert insertion)))
What it does: Given a list of strings separated by newlines (commonly, something copy-pasted from a table) like:

  josh
  sam
  jed
  C.J.
  toby
You select the text, and run "arrayify". You can optionally provide a quote character and, in about half a second, get to:

  "josh", "jed", "sam", "C.J.", "toby"
  
This is incredibly useful for taking lists of IDs, or email addresses, or whatever, and transforming them for pasting into documents, or emails, or "in" clauses in SQL, etc.

It is unbelievably useful.

Re: My Emacs Productivity Tricks/Hacks

#64
post #34

Another beautifully designed piece of Emacs software is magit, where the defaults are extremely sane. The package is self-documented and you can learn it all by typing ? anytime. Being able to git log the file you are in is also a huge plus.

I'm still not sure there's anything better than magit on the market.

People say org is the killer app, but imo it has nothing on magit. (It's a weird comparison Ill give you that)

I'm thinking of donating again

Re: My Emacs Productivity Tricks/Hacks

#65
> All the packages were installed from Emacs package Manager. By running, `M-x list-packages` This should bring up a list of packages available in MELPA. Now, don’t worry if you don’t know what MELPA is, just think of it as a repository of all packages, as in, analogous to the Debian Package Repo in Debian/Ubuntu distros.

Article seems to confuse MELPA with ELPA. MELPA is something you have to add via your init file. Not terribly hard to do, but just FYI for anyone who is actually using these tips from scratch.

Re: My Emacs Productivity Tricks/Hacks

#66

the others I cannot live without: neo tree winner mode god mode (I use instead of evil mode) avy (visually jump to any char on the screen) undo-tree (really neat, though I don't use it as much any more)

I have tried neo-tree and undo-tree. But never really got around to using them well. Maybe, I need to be patient.

Neo tree was annoying to me (coming from NERDTree). I remapped things to work like NERDTree ('l' for open? should be o!). And then I finally grokked how much simpler it was to navigate directories with hjkl. Plus ? to see how to manipulate files and just keep it there is great. Way more ergonomic than NERDTree or Treemacs imho.

Also since I'm going on here, I've found the key to editor management is to make sure certain basics work across the board (for IntelliJ/, Xcode/Xvim, (space)emacs and even vim - sometimes I use vim for config changes since it's so fast to open, tmux, etc).

  C-o/C-i -> should work for navigation
  ctrl-shift-j -> should select the file you're working on
  ; ->  should map to : (retrain yourself)
  fd -> escape (retrain yourself)
  c-hjkl -> c-w hjkl (faster window/panel navigation)
  gd -> should go to definition
  vim text motion in general should work flawlessly
    e.g., @q - should start to record a macro
I use spacemacs + tmux since I like to customize and it's easiest to customize in elisp I've found than in any other IDE or vim itself. And when things don't work and I can't make it work in the editor itself, I fix it in the terminal app (Kitty) or the OS (BetterTouchTool).

Shameless plug for those curious:

https://github.com/p10q/home/blob/master/.spacemacs#L343 https://github.com/p10q/home/blob/master/kitty.conf#L797

Re: My Emacs Productivity Tricks/Hacks

#67

The one thing I consistently do in emacs that shocks my coworkers -- is running this (custom) function, that I call "arrayify": (defun arrayify (start end quote) "Turn strings on newlines into a QUOTEd, comma-separated one-liner." (interactive "r\nMQuote: ") (let ((insertion (mapconcat (lambda (x) (format "%s%s%s" quote x quote)) (split-string (buffer-substring start end)) ", "))) (delete-region start end) (insert in…

Doesn't sound crazy at all to me! I do this all the time using multiline editing in Sublime Text. It's the one part of a more modern IDE I have a hard time giving up (transitioning to Spacemacs currently). Will have to try out this script and see if it helps bridge the gap!

Re: My Emacs Productivity Tricks/Hacks

#68
post #26

If the author, @mycpuorg, is reading this comment: please, PLEASE, do write about your mu4e configuration.

@rntski, I will be happy to. I feel I get a bigger bang for buck for Work Email on Outlook Exchange since Email on mu4e makes me less distracted.

This sentence is either missing a negation or correlates "bang" with "distraction", which is wrong since "bang" is positive and "distraction" negative.

Re: My Emacs Productivity Tricks/Hacks

#69
This is mostly a listing of packages and very known ones at that.

One of the best features I like is undoing regions. That is, if you know the approximate location of the text that you want to undo, you just select a region that contains that location and call undo. It can be used as a quick git alternative. Say you modify the buffer all over the place. If you want to undo some text that you've modified an hour ago but you did other modifications to the buffer in countless other places, you can undo just that region and you don't have to go back throught the whole undo tree.

Another one that I've currently discoverd and I'm very excited about is yasnippet (the modern variant of abbrev). You can define a string that stands for an abbreviation for an expansion. Everytime you type that string, it is replaced by that expansion. The nice thing about yasnippet compared to abbrev is that, among others, you can specify where to leave the cursor after the expansion. One example: "lt" expands to (let ((_))), where _ is the cursor position after the expansion. This also saves typing of all the parantheses. Or "mcar" expands to (mapcar (lambda (_))). You can expand anything to anything, in short. With time, you can type less and faster.

Re: My Emacs Productivity Tricks/Hacks

#70
post #38

It seems a lot of people have used emacs for years and love it. I never saw the point of learning as it seemed cryptic. In 2020 is it worth putting the effort to learn now? I figure with vim and IDEs I dont really need it.

[deleted]
Post reply on HN