Pasting with mouse-select in GNU Emacs - emacs

There is an functionality in XEmacs that if the user selects a region with the mouse while holding Ctrl, the selected region will be automatically pasted at the current cursor position.
In other words, if you need to quickly copy a short block of text from some open buffer to a new spot, you put the cursor there, and then do Ctrl-mouse-select and it works.
Unfortunately, I recently had to switch from XEmacs to GNU Emacs, and I'm looking to see if there is similar functionality there, or perhaps I could provide it with a custom module (I am very bad at Lisp, unfortunately).

You sure can, the functionality is bound to mouse button 3 if I'm not mistaken.
I assume so, because clicking my mousewheel yanks what I've copied at the cursor.
And Mousewheel == mouse button 3 in most cases.
Select using your mouse
With your mouse button down, hit control
Release your mouse button
Hit mouse button 3
Profit - selection yanked at your cursor
edit:
I found this on http://www.gnu.org/software/emacs/manual/html_node/emacs/Mouse-Commands.html
Mouse-1
Move point to where you click (mouse-set-point).
Drag-Mouse-1
Activate the region around the text selected by dragging, and copy it
to the kill ring (mouse-set-region).
Mouse-2
Yank the last killed text at the click position (mouse-yank-at-click).
Mouse-3
If the region is active, move the nearer end of the region to the click position; otherwise, set mark at the current value of point and point at the click position. Save the resulting region in the kill ring; on a second click, kill it (mouse-save-then-kill).

Put the following in your init file (.emacs):
(require 'mouse-copy)
(global-set-key [C-down-mouse-1] 'mouse-drag-secondary-pasting)
Once you restart Emacs, it should work just like you're used to in XEmacs--hold down Ctrl and the left mouse button, select your text, and when you release the mouse the text will be inserted at your current cursor position.

You might want to use mouse-copy.el which comes with Emacs.

Related

In VSCode, after I search (cmd+f), how do I make the escape key (2x) not jump back to where I started?

In VSCode, my cursor is at point P1 initially. If I search for some other text using Cmd+f, then hit escape, it will focus the text editor, but not clear the selections.
If I press escape a second time, it will clear the selections and move my cursor back to P1.
How do I change this behavior? I'd like to deselect the findings, but keep my cursor where it is.

Access mouse over hover in VSCode

Is there a way to access the mouse over popup in VSCode via Keyboard and navigate in it?
I often use the mouse over to get the namespace of function or variable ...
So I want to place the cursor on "bar", popup the hover (Show Hover Ctrl+k Ctrl+i), focus it, mark some text (eg. namespace::functioname), copy and close the hover.
namespace foo{
void bar();
}
First problem, the hover doesn't get the focus and I don't know how to focus it. But there is another feature "Show defintion preview hover", which actually gets focused. So far so good. But I still cannot mark or copy text inside the hover via keyboard.
Show hover (not focused):
Show definition preview hover (focused):
But I still cannot mark or copy text inside the hover via keyboard.
That should change with VSCode 1.68 (May 2022):
Lock hovers to more easily mouse over them
Some custom hovers cannot be moused over and others are tricky to mouse over without hiding it because of other things in the way (eg. like a scroll bar).
Holding alt while a hover is active will now "lock" it, giving it a wider border and preventing moving the mouse outside of the hover widget or whatever triggered it from hiding it.
This is primarily an accessibility feature to make hovers play nice with screen magnifiers but it is also useful for copying text from certain hovers.
Note that this feature only applies outside of the editor because editor hovers can always be moused over unless specified otherwise via a setting.
This will be helpful for other views (debug, terminal, ...) where variables with their popup can appear as well.
In the editor, see microsoft/vscode issue 63296
ctrl+K ctrl+I to show the hover and focus it
ctrl+A to select all the hover content
ctrl+C to copy to clipboard
It does indeed work for me (on windows) for the first two steps, however ctrl+C does not copy the text selected with ctrl+A.
It seems like there are two different selections possible in the hover:
ctrl+Aselects everything with a dark blue.
When selecting some text in the hover with the mouse (i.e. press the left mouse button while near/over a char, move mouse, release left mouse button) the selected text is shown in a lighter and brighter blue.
The two selections can coexist.
ctrl+C always copies the text selected with the mouse, or nothing if there's no such selection, no matter whether a ctrl+A selection also has been done.
If there's only a ctrl+A selection, ctrl+C doesn't copy anything.
The two selections can be selected in any order. The order doesn't change the behavior.
Think I found out what you were after.
The shortcut is: Ctrl+K Ctrl+I
See: Trigger advanced hover information with keyboard
please try control + mouse click
it may be help you

When using emacs org mode. Pressing backspace in a head jumps to the top of the page

Lets assume that I have something like the following
* Project Outline
** Foobat
And the cursor is on the t of foobat I want to delete the t by pressing backspace. When I press backspace, the cursor will jump to the first astrix at the top of the page. This is the astrix right before Project Outline. Why is this happening?

Change mousewheel scroll rate in emacs console mode

Currently, when I use the mousewheel in emacs -nw mode, it skips two lines and then jumps to put the current line in the middle of the screen when the cursor gets to the bottom of the window.
What I want is for the cursor to jump one line at a time with mousewheel scrolling (so I can visit every line just with mouse scrolling), and only move the buffer down a single line when I scroll to the bottom of the screen.
I've gone in the Mouse options of emacs and set the "Mouse wheel scroll amount" to 1, along with "Mouse Wheel Progressive Speed" to 'off', but to no avail.
Is the "three line jump" behavior even contained in Emacs when I'm running in console mode? I set my local machine's "scroll by" option to 1 line, but no help. I don't see an option in the konsole (I'm using kubuntu) to change the mouse scrolling rate . . .

How can I configure emacs to switch to a particular buffer when I click the mouse in it?

I'm using iTerm2 on my mac to ssh into a Linux box and run emacs in the terminal. On a big monitor, I like to split the window to see multiple buffers side-by-side. I'd like to be able to switch to a particular buffer by clicking the mouse in it (rather than doing C-x o).
What seems to be happening is that if I click the mouse anywhere outside the currently active buffer e.g. in the next buffer, on the mode line etc., the click is being interpreted as which is bound to (tmm-menubar-mouse EVENT).
I have disabled the menubar by doing the following in my .emacs_d/init.el:
(menu-bar-mode -1)
This seems to disable the visible display of the menu bar at the top of the window, but the mouse click behavior I described is still happening.
I think what I need is to have the click interpreted as something other than and then bind that to some function that detects which buffer the click happened in and switch to it. But, I don't know how to do that and the searching I've done hasn't yielded any clear answer. Can anyone help?
Alternatively, I looked into using windmove to enable switching between buffers with SHIFT and the arrow keys. I did (windmove-default-keybindings) but emacs then seems to respond to SHIFT left-arrow by inserting "2C" into the buffer and SHIFT-right-arrow by inserting "2D". If anyone has any tips on making this work too, I'd love to hear them.
Thanks
I ran into this problem a while ago, where clicking on column > 95 was interpreted as <menu-bar> <mouse-1>, which invokes tmm-menubar-mouse. It turned out to be a bug:
http://debbugs.gnu.org/cgi/bugreport.cgi?bug=6594
There hasn't been a formal release since this bug was fixed, but you can get the patch here:
http://bzr.savannah.gnu.org/lh/emacs/emacs-23/revision/100618
If I recall correctly, you should be able to just drop the modified file into your existing emacs installation and byte-compile it (assuming you're running the 23.3.1, the latest release).