IPython 5 has a bunch of neat new editing features, but it seems like cycling the kill ring is MIA.
Cycling the kill ring is done in IPython 4 (and any other readline-based program) by issuing a Alt-y following a yank (Ctrl-y).
Is this functionality not present in IPython 5, or am I just missing it?
Here's a full example, for anyone not familiar:
Push the word "one" onto the kill ring:
one Ctrl-a Ctrl-k
Push the word "two" onto the kill ring:
two Ctrl-a Ctrl-k
After a yank (Ctrl-y, which will insert "two"), you can start cycling the kill ring with Alt-y, to get the "one" back, for example.
The ever-luminous #jonathanslenders (maintainer of the python-prompt-toolkit library, which is where this problem lied) has fixed the issue.
Related
I'm trying to understand some annoying behaviour from ipython. I have vi mode enabled, I can confirm this like so;
[ins] In [1]: from IPython import get_ipython
...: ipython = get_ipython()
...: ipython.editing_mode
Out[1]: 'vi'
Mostly it works, but if I hit esc then two other keys in quick succession, only the first of the two is treated as a "normal" mode command ([nav]), the other one gets treated as an insert mode command ([ins]).
For example, say the cursor is at the end of the line
[nav] In [2]: who = ["some", "person"]
and I hit the b key 4 times quickly, the result is
[ins] In [2]: who = ["some", "personbbb"]
so the first press did what I expected, took the cursor back a word. Pressed 2,3 and 4 all acted in insert mode, resulting in "personbbb".
On the other hand, if I hit esc, wait a second or so, and then hit b 4 times I get exactly what I expect
[nav] In [2]: who = ["some", "person"]
and the cursor is by the 'e' in "some".
Hitting esc multiple times also ensures I stay in normal mode properly, no matter how fast I hit keys.
Is this a setting somewhere?
What I've tried
All the sugestions in How do I use vi keys in ipython under *nix? just in case I wasn't setting 'vi' mode properly.
Also updating my ipython, in case it was a bug in this version.
Searching for questions about 'vi' mode in ipython. The one I've just listed is the main thing that comes up, but I'm pretty surprised that this behaviour hasn't been mentioned before?
What I'm using
My zsh version is 5.8.1 (x86_64-apple-darwin21.0).
My ipython version is 8.6.0
My ~/.inputrc has
set editing-mode vi
set keymap vi
My ~/.ipython/profile_default/ipython_config.py has
c.TerminalInteractiveShell.editing_mode = 'vi'
(excluding comments)
I was torn between asking this here, and asking on the macOS stack exchange, because I don't know if this is an ipython issue, or a mac issue. I've only seen it on my mac using zsh.
I recently felt the need to work with Spacemacs for my erlang/elixir projects.
(was coding Erlang on eclipse).
Now i'm feeling a bit more comfortable with Spacemacs, i have a question regarding how to deal with processes.
I made a mistake on my code and had an infinite loop.
I killed it on console but i was wondering how to do the same thing within spacemacs.
I've found that SPC a p gave me the possibility to list all the running processes.
Can please someone explain me (i'm a complete beginner on spacemacs/emacs) if it is possible to kill a running process within this menu ?
Regards
Pierre
M-x proced
Choose your line and then k
In Spacemacs, SPC a p, which runs the command list-processes, opens a buffer showing only those processes started by Spacemacs.
The list process buffer is evilified, so j and k navigate the list of processes,
d in the list process buffer will immediately delete the process under the cursor (no prompt to confirm is given, so ensure its what you want to do).
q will quit the process list and close the buffer.
Note: SPC a P will list all operating system processes, not just those spawned by Spacemacs.
Reference: https://practicalli.github.io/spacemacs/install-spacemacs/troubleshooting.html
For example, place point at the beginning of a line with the text "foo bar". Then M-d C- C-e M-C-w C-w C-y produces " barfoo". This behaviour causes problems when I try to switch the order of text and when I combine a real kill with save-as-kill. No doubt prepending is often useful, but all the documentation I have found says that append-next-kill appends. How do I control emacs's choice between appending and prepending?
See the Emacs manual, node Appending Kills. It gives explicit examples, in particular an example that shows clearly what C-M-w is for and what it does. Here is part of that text:
If a kill command is separated from the last kill command by other
commands (not just numeric arguments), it starts a new entry on the kill
ring. But you can force it to append by first typing the command
`C-M-w' (`append-next-kill') right before it. The `C-M-w' tells the
following command, if it is a kill command, to append the text it kills
to the last killed text, instead of starting a new entry. With
`C-M-w', you can kill several separated pieces of text and accumulate
them to be yanked back in one place.
For C-M-w to append the next kill, that kill must immediately follow C-M-w. If you do something else in between then there is no appending. The command name might better have been append-next-kill-if-it-follows-immediately. ;-)
I like to open multiple window, each with its own file opened. Sometimes, I want to maximize the one I edited to occupy whole screen, and then to restore it back to its previous size and position..
Is there a way?
According to the emacs menu, I can only figure out enlarge-window, shrink-window.. thats it..
More or less - try using winner-mode. It will remember the last few (ca 200) window configurations, and will let you walk through them with a simple (C-c (right|left)) keystroke. And it's quite easy to turn on, since it's built in:
(when (fboundp 'winner-mode)
(winner-mode 1))
Combine it with windmove and moving between your windows will be even more awesome.
Use the command window-configuration-to-register: M-x window-configuration-to-register, press the Enter key, then some register (character), e.g. a. To maximize current window, use C-x 1. When you want to restore, type C-x r j a.
Workaround.
ESC ESC ESC maximizes the buffer with active cursor.
M-x ` to navigate between other buffers.
Unlike windows style self explanatory copy/cut/paste commands, I could not understand ring concept in emacs.
Since I don't program very often in emacs, I could have not realized the value of ring feature. Can you tell me what is called ring in emacs and how to use it?
Well, let me try in simple words. Each time you copy (M-w) or cut (C-w), the selection is inserted into a top of so called ring (which is just like a closed ended list).
The interesting part comes after. Now, if you paste with C-y then the most recently pasted region (which is now the front element of the ring) is inserted in the buffer. If you continue pressing M-y, then the text is replaced successively with older and older elements from the ring, so to say, the ring is rotated and the older text is designated as front element each time. This gives you an access to older cut/copied text.
The useful part does not end here. If you cut/copy some other text, it will be inserted at the top of the ring, and the ring will be rotated again such that the top is now the front. And you can start the C-y M-y sequence again, with the newly inserted text designated as front.
So, to conclude:
the top of the ring is the place where the newly copied/cut (M-w/C-w) text is inserted. When that happens, the top element becomes the front element.
the front element of the ring is the place on which paste (aka yank) commands C-y and M-y operate, by inserting it into the buffer. M-y also rotates the ring, such that older text in the ring becomes the front.
You can visualize it by imagining the circle with the front fixed at 12 hours position, but not part of the ring. The top is part of the ring instead, so when some command rotates the ring the top is also rotated.
Every time you copy or cut something to the clipboard in windows, you lose whatever was on your clipboard before. (Though some programs will store previous clipboard contents for you) The emacs "ring" will store old clipboard contents even after you copy/yank/cut/kill things. It can be handy if you get used to it because it lets you store more than one thing in the clipboard at once, and reduces the chances of accidentally overwriting something that you cut to the clipboard like you could in Windows.
A ring is a circular buffer. Think of a rolodex.
If you are killing/yanking to a ring, then you can walk forward and backwards in your history.
On Ubuntu, with the emacs-goodies-el package installed:
Press C-( M-x browse-kill-ring RET C-)
This defines a temporary keyboard macro which calls browse-kill-ring
when you press C-x e.
Now you don't have to just read about the kill ring, you can actually see what's in it.
Experiment with C-w (cut), M-w (copy), C-y (yank) and C-y M-y (yank next in ring), and press C-x e to see the effect on the kill ring.
From the Emacs manual: "A ring is a fixed-size data structure that supports insertion, deletion, rotation, and modulo-indexed reference and traversal." In other words, it's a circular queue.