reddit / emacs

How to paste/yank into minibuffer input prompt?

TooflessSnek · 2022-02-08 02:39
An emacs beginner's tutorial website ([here](https://www.fugue.co/blog/2015-11-11-guide-to-emacs.html)) suggests looking at the value of system-name: > You should replace the system-name values with what you get when you evaluate (system-name) in your copy of Emacs. Whats the best way to do that? Use `C-h v`? Is there another way? Regardless, one thing I'd like to be able to do (just to know if it's possible) is highlight that web text, copy to the MacOS cut-and-past buffer, then in emacs, `C-h v` and it prompts me `Describe Variable:`. Is there a way to just paste/yank the name at that point? **C-y didn't work before, but now it does, so this use-case is solved.** In another use-case, suppose I might have the variable name in my emacs buffer/window, with point on the variable name. Is there a way to "send" what's under the point to `C-h v` for quick inspection? Or another way to "evaluate" the variable so that I can see what it is? I'm currently using Ido, if that matters. I'm also very new to emacs!
Danrobi1 · 2022-02-08 03:23
> C-h v and it prompts me Describe Variable:. Is there a way to just paste/yank the name at that point? Yank = `C-y`. `M-x` and type `yank` and `Tab`. There will be lots of choice with their description. > Is there a way to "send" what's under the point to C-h v for quick inspection? By default `C-h v` does open info for the variable under point. So `C-h v` enter. Im on Linux, noclue for MacOS.
wheel_of_confusion · 2022-02-08 04:43
> Whats the best way to do that? Use C-h v? Is there another way? Emacs has a bunch of defaults that may work for you, they also might not. More often than not I find myself in the second camp. One thing you'll find is that there is _always_ another way to do things with emacs. Luckily this one is pretty simple and should be pretty easy to understand. Okay, onto your question. The other commenter answered part of your question but you may not want to have `C-y` as your yank key. I'm relatively new to elisp so if anyone has a better way of doing this please let us know. If you want `C-v` to "paste" (`yank` in emacs jargon): ``` (global-set-key (kbd "C v") 'yank) ``` Now this is a global key bind, meaning that it will work in the editor (and everywhere else where it's not explicitly re-bound). If you _just_ want it in the mini buffer, you can do this: ``` (define-key minibuffer-local-map (kbd "C-v") 'yank) ``` [This](https://www.masteringemacs.org/article/mastering-key-bindings-emacs) seems to be a good reference for learning more about keybindings in emacs. I'm also a big fan [general.el](https://github.com/noctuid/general.el) which makes it easier to organize key bindings. Hope this helps!
TooflessSnek · 2022-02-08 04:49
C-y didn't work before, but now it does. Thanks!
TooflessSnek · 2022-02-08 05:18
Thanks! I was having trouble with `C-y` not working, but now it (suddenly, magically) does, so I must have been doing something crazy wrong. I'm coming from the MS Windows world, but my philosophy, which I've read in many tutorials, is to stick with the default bindings instead of rebinding to (CUA mode) cut `C-x` copy `C-c` paste `C-v`. The standard keybindings are generally better, and CUA mode conflicts with some other things, perhaps including org mode, which is my reason for learning emacs. One thing I did which is REALLY helpful (very extremely helpful), is to remap my Caps Lock to act like `control`. On MacOS, I used Karabiner-Elements. While it's really each person's individual choice, here's some posts explaining why CUA mode probably isn't good for beginners: 1. https://www.reddit.com/r/emacs/comments/8wvy9u/for_beginners_til_about_cua_mode_to_use_cv_cc_and/ 2. https://www.reddit.com/r/emacs/comments/4hh5kg/learning_emacs_to_cua_or_not_to_cua/