I would like to set up the mouse in Emacs so that it incrementally adds the text selected with the mouse to the contents of the clipboard.
For example, if the shift key is kept pressed. Is there a way to do this?
By default copying text in Emacs sends it to the kill-ring and clipboard likewise. The latter is a X-windows-thing, not from Emacs.
When appending, rather do that inside Emacs.
With a second step update the first entry of the kill-ring resp. the clipboard.
Related
I am writing my own emacs cheat sheet.
So I want to copy function descriptions from emacs help.
For example, in this screen shot, I want to copy the "org-shifttab" function description:
The "pattern" field filters a list of functions.
Pressing TAB displays the description of the selected function.
But moving the yellow cursor out of the "pattern" field removes the display of the function's description.
How to copy the function's description to the clipboard?
I am running Emacs 25.2.1 on Fedora 25.
You have a *Help* buffer now with the contents that you're looking for. You can either press enter to go to that help buffer, or use C-x b to switch to it.
From there, you can mark and copy the contents of the buffer as usual (C-x h M-w).
In EMACS the default seems to be to 'copy' any text highlighted with the mouse. I'm attempting to replicate the functionality of modern text editors, where I can highlight a section of text and press 'paste' to replace it. I have so far added
(delete-selection-mode 1)
to my init.el
The problem is, if I copy something, then highlight to paste in its place, I end up pasting what I had just highlighted, changing nothing.
What do I need to change to fix that behaviour?
The most powerful element of emacs is its introspection features, lets have a look at how we can use them to try and solve this problem. We must use the power of the source.
One of the most important tools for introspection in emacs is the describe-key command which is bound to C-h k. It brings up the documentation of whatever keystroke is called after it. So in our case if we press C-h k and then click and drag we will see the documentation for <down-mouse-1> and more importantly for <drag-mouse-1>. The documentation states that "<drag-mouse-1> at that spot runs the command mouse-set-region". Below it then gives some documentation for this command. It says
Set the region to the text dragged over, and copy to kill ring.
This should be bound to a mouse drag event.
See the ‘mouse-drag-copy-region’ variable to control whether this
command alters the kill ring or not.
Now we know that somehow mouse-drag-copy-region controls whether or not the highlighted text is copied.
If we follow the link of that variable it tells us the default value and some documentation:
If non-nil, copy to kill-ring upon mouse adjustments of the region.
Now all we have to do is set the variable to be nil to get the effect that you want. Place the following code at the end of your init file and you should be all set
(setq mouse-drag-copy-region nil)
I hope that this helps you with this problem and that more importantly it helps you with further issues.
By default, selecting a region with the mouse does not copy the text to the kill ring. If your Emacs does this, you probably have set the variable mouse-drag-copy-region.
In a fresh Emacs (24.5 started using -Q), you can do the following:
Start delete-selection-mode.
Mark a region using the mouse. Copy it using M-w.
Mark a second region. Replace it with the first using C-y.
I see two alternatives, neither of which does exactly what you request. (For both, yes, turn on delete-selection-mode.)
Use the secondary selection for the text to copy, and use the primary selection (the region) for the text to be replaced.
You copy text into the secondary selection using the Meta key plus the mouse - for example, press and hold Meta (the Alt key, usually) while dragging or double-clicking mouse-1.
You paste the secondary selection using Meta plus mouse-2.
Select text with the mouse, then copy it to the kill-ring using M-w. Then select the text to replace with the mouse and use C-y to paste the copied text to replace it.
I am new emacs user and one of the things that irritates me is that when I want to replace current selected text with the one from clipboard I need to delete it first. Every other application that I know replaces pasted text with the current selection by default.
Here's a little bit more detailed description:
Select some block of text
Paste text from clipboard
Emacs just pastes text where the cursor was and previously selected text it is still there. I want that selected text was deleted first.
As artscan wrote in a comment, you can get this functionaly for the normal yank (paste) operations by adding:
(delete-selection-mode 1)
to your configuration.
If you want yank by mouse to also delete the current selection, you can add:
(put 'mouse-yank-primary 'delete-selection 'yank)
in your configuration as well.
Is there any tricky ways to do this: in my text files I have a list of words, one word a line. I want search the word new-word in the lists with C-s. In order to search it I need to type the word in the minibuffer, if the new-word isn't exist in the lists, I want to insert it in the list. It seems that I have to retype the word in the normal buffer, is there any ways to remember the word that I have just typed in the minibuffer and copy it into the normal buffer?
Pressing RET immediately after C-s allows you to input the string using the normal minibuffer prompt which supports editing and history of past searches. In that mode you can use the regular buffer commands, such as C-SPC, M-w and C-y, to copy contents from the search minibuffer and paste it into a regular buffer, or vice versa.
In Emacs, a user would usually copy/cut text as follows:
Move the cursor to the beginning of the text to be copied/cut with one of the move-cursor commands (e.g. C-p, C-n, C-f, C-b, M-f, M-b, etc.)
Set a mark with C-spacebar (in Emacs this command is also called set-mark)
Move to the end of the text to be copied/cut using move-cursor commands.
Copy M-w or Cut C-w the text from the mark to the current cursor location
Move the cursor to the place where the copied/cut text is to be inserted
Paste the text with C-y
Starting in R2009a, MATLAB supports customizable keyboard shortcuts, including a pre-defined Emacs layout.
My question is: Does MATLAB support a set-mark command such as C-spacebar (step 2. above)?
Thanks
No, MATLAB currently doesn't support set-mark.