Live data from Hacker News

My Emacs Productivity Tricks/Hacks

mycpu.org

81–90 of 210 posts

Re: My Emacs Productivity Tricks/Hacks

#81
post #71
post #55

Earlier quoted context omitted.

A cluster of Emacs keybindings that share a common prefix, implemented using the hydra library: https://github.com/abo-abo/hydra

So it's sort of like a mode switch? You give the prefix, and then you can give it a whole series of commands, based on a crib sheet that it shows you, that have that common prefix - without having to retype the prefix - before passing a different key to drop out of the mode again? That does sound potentially handy, if I have it right.

Yes, though I'd describe it more as a fully-customizable popup menu that appears when you type a certain keystroke. Once the menu appears you can type more keystrokes to perform an action or bring up another custom menu.

Also, it's possible to configure it so that there's a delay between the time you type a keystroke and the menu appears, so that if you remember the key-sequence you need to type to perform a certain action and you type it fast enough, then the menu won't pop-up, but if you forget the full sequence then you can type just the first keystroke and then wait a bit and the menu will pop up and remind you of what needs to be typed to execute the action you want.

It's super handy, and is one of my all-time-favorite emacs packages.

Re: My Emacs Productivity Tricks/Hacks

#82

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!

I tend to do it in sublime with a regex:

Find/replace all:

  ^(.*)$\n
with

  "$1",

Re: My Emacs Productivity Tricks/Hacks

#83

I used to think that Emacs is some weird editor with absurd keybindings, until I learned lisp and understood what makes it so special. Now Emacs (Spacemacs[0]) is my main driver. [0] https://www.spacemacs.org

How did learning lisp help you understand the power of Emacs? Just starting down the Spacemacs road myself (from Sublime Text), and curious to hear more about your experience!

In short, you can add new functionality to Emacs yourself.

And just like in the world of Lisp, after you add a new functionality, it becomes indistinguishable from what you already have. That is, it looks like it has been there all along, from the start. It doesn't look like a 3rd party plugin that you need to take special precautions to install. It just blends in nicely, and naturally.

Or, to put it another way, if you learn (Emacs) Lisp and you start to tweak Emacs to your own liking, you can transform Emacs into your own personal tool, adjusted exactly the way you like it, no questions asked.

Re: My Emacs Productivity Tricks/Hacks

#85
post #62

Earlier quoted context omitted.

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/...

It's really handy if you don't use spacemacs / doom-emacs.

My (old) config used it heavily. It also defined everything inside a single org file which also serves as a README on github: https://github.com/kwrooijen/.emacs.d

However these days I'm using Spacemacs, currently looking at Doom.

Re: My Emacs Productivity Tricks/Hacks

#86
post #74

Earlier quoted context omitted.

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!

If emacs keyboard macros haven't bridged the gap for you, try https://github.com/magnars/multiple-cursors.el Keyboard macros: https://www.emacswiki.org/emacs/KeyboardMacros

multiple-cursors is AMAZING and i use it all the time, but it does NOT work well for more than a few hundred lines of text. It gets incredibly slow.

Re: My Emacs Productivity Tricks/Hacks

#87

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…

Yes, indeed. You can also do that, and other small variations on it depending on the context, with a macro. You go to the end of "josh", press F3, add a comma and a space and you delete the rest of the line, until "sam" is now the next symbol after your cursor. Then you go to the end of the line (C-e) and press F4. Your macro is now recorded. To call it, press F4 repeatedly until everything is on one line. As a bonus…

Works well for a few dozen entries...less so for a few hundred or a few thousand :)

Re: My Emacs Productivity Tricks/Hacks

#88

Earlier quoted context omitted.

How did learning lisp help you understand the power of Emacs? Just starting down the Spacemacs road myself (from Sublime Text), and curious to hear more about your experience!

In short, you can add new functionality to Emacs yourself. And just like in the world of Lisp, after you add a new functionality, it becomes indistinguishable from what you already have. That is, it looks like it has been there all along, from the start. It doesn't look like a 3rd party plugin that you need to take special precautions to install. It just blends in nicely, and naturally. Or, to put it another way, if…

Thank you molteanu for chiming in. I would also add, that everything has the exact same interface, meaning I can access every tool in the same way, the consistency is unparalleled. For example: In VSC when I want to use the shell, I suddenly lose my vim bindings and thus drop down to the casual user mode. In Emacs I can treat the shell like any other buffer, apply all my tools and knowledge, so it's nothing foreign or something that wants to be treated differently. For instance similar point in VSC regarding the file explorer, it forces you to abandon the keyboard homerow, I can't use my vim bindings from the plugin, because the plugin is something 'foreign'. Sure you can memorise shortcuts, but it's not the same as using your vim bindings for everything, always.

Re: My Emacs Productivity Tricks/Hacks

#89
Whenever I hear about or see the .vimrc and .emacs files people create, maintain and constantly modify to me this just looks like the perfect example of a sunk cost fallacy.

IDEs are usually dismissed by many such people since you can (allegedly) do the same in vim/emacs but to me this seemed crazy as I'd see people spend hours configuring plugins, writing Lisp and whatever to save them on some task they'd get for free with a right click in IntelliJ.

I really do think people completely underestimate how much time they have and will invest in such endeavours. I mean if this makes you happy or you like this tinkering, by all means be my guest, but I'll take a hard pass.

Re: My Emacs Productivity Tricks/Hacks

#90

Earlier quoted context omitted.

In short, you can add new functionality to Emacs yourself. And just like in the world of Lisp, after you add a new functionality, it becomes indistinguishable from what you already have. That is, it looks like it has been there all along, from the start. It doesn't look like a 3rd party plugin that you need to take special precautions to install. It just blends in nicely, and naturally. Or, to put it another way, if…

Thank you molteanu for chiming in. I would also add, that everything has the exact same interface, meaning I can access every tool in the same way, the consistency is unparalleled. For example: In VSC when I want to use the shell, I suddenly lose my vim bindings and thus drop down to the casual user mode. In Emacs I can treat the shell like any other buffer, apply all my tools and knowledge, so it's nothing foreign o…

Yes, indeed. All the tools, all the time, always available. Something like writing a macro in Lisp. All the language is there at your disposal and it's nothing compared with C macros where you have huge limitations, it being actually a different language than C. I feel your pain with the VSC example.

"Consistency" is a good word. The result, for me at least, is that I can actually think about what I want to do with the tool and not how to use it. It gets out of the way, it does not try to fight me.

I think maybe that's one interpretation of the saying "Emacs is an operating system".

Post reply on HN