In emacs, query-replace-regexp keyboard shortcut doesn't work in the terminal (e.g., emacs -nw) - emacs

Is it expected that C-M-% and ESC C-% do not run the command query-replace-regexp when running emacs in a terminal window (for example, emacs -nw)?
According to describe-function the binding exists, but emacs runs query-replace instead (which has the binding M-%). This has happened on several machines I've tried it on, and does not happen when I run emacs in a window.

The problem is that C-% simply can't be typed in a terminal. The only control sequences available are those that corresponds to ascii-code 0-31, mainly C-letter.

I have created a new shortcut in my .emacs file.
(global-set-key "\M-q" 'query-replace-regexp)

Control-Alt-Shift-% all together works on Windows and Fedora Linux. Does your keyboard have all those keys?

Related

How do I exit Emacs from the terminal?

I just installed Emacs 26.3 on Ubuntu 20.04. I opened a buffer in the terminal, and I cannot close it. C-x C-c does nothing. f10 to activate the menu does not activate the menu.
I'm using a .emacs file that maps cut/copy/paste commands to the normal C-x/C-c/C-v. I don't think that this can affect the issue, however, because I have the exact same setup (including the same .emacs file) on by Emacs 24.5/Ubuntu 16.04 laptop, and it has no problem exiting with C-x C-c. Also, I had the exact same problem before I installed the .emacs file on the new system.
How do I kill Emacs?
This question exists, but it has no useful answers.
ESC x save-buffers-kill-terminal
OFC binding C-x will affect C-x C-c. You don't need to know anything about Emacs to realize the problem. Just think twice.

How to configure simpleclip in emacs terminal mode to copy-paste interchangeably with OS?

I'm using emacs -nw (Emacs 24.5, Ubuntu 16.04). And I found that the default emacs M-w C-y keys don't work interchangeably with the operating system.
After some research, it seems that the most comprehensive solution is to use simpleclip. EmacsWiki says that
simpleclip
You can use https://github.com/rolandwalker/simpleclip which ALWAYS
works.
But looking into its usage guide above, simpleclip makes use of a set of keys that are completely different from the default M-w C-y or the OS Ctrl-Shift-c, Ctrl-Shift-v for copy-paste
;; Press super-c to copy without affecting the kill ring.
;; Press super-x or super-v to cut or paste.
I don't really want to use super key a lot with my PC keyboards, and don't want to remember (or persuade others to remember) yet another set of copy-paste keys.
For the GUI emacs, I can copy something in emacs and paste it into another terminal without any configuration. Mostly, I don't feel that Emacs is any different from gedit except that the emacs copy-paste keys M-w C-y can be used in addition.
In the terminal mode, most of it breaks down. If I use OS copy (Ctrl-Shift-c), one line in emacs can be copied into two or more lines in a target terminal because the line is too long. contents copied using M-w simply do not paste into other programs, even though I tried to set certain variables following other SO questions, e.g.:
(setq x-select-enable-clipboard t)
I'm not very familiar with elisp. My question:
How can I customize or configure simpleclip so that copy-paste in emacs -nw is exactly the same as copy-paste in the OS?
Other related SO questions:
How to copy text from Emacs to another application on Linux
emacs terminal mode: how to copy and paste efficiently
I recommend you use the xclip package, which you can install from GNU ELPA (i.e. via M-x package-list-packages). It requires installation of the xclip utility under X11 (e.g. via aptitude install xclip) and uses the pbcopy/pbpaste under macOS.

Use repl for Hy in Emacs

I have successfully installed hy-mode from https://github.com/hylang/hy-mode. I now can open a .hy file in emacs and have syntax highlighting, and editing with paredit is a joy.
I however, don't know how to start a REPL. At the bottom of the github readme, it says:
When in hy-mode, you can launch a Hy REPL by launching a Lisp inferior
process
M-x lisp-inferior-process
That function, however, is not defined for me. What else do I need to install or check to be able to use the repl for Hy?
I am currently using:
GNU Emacs 24.3.1.
Have you tried to set inferior-lisp-program to "hy" and then doing M-x run-lisp?
This is the standard way (or maybe just the "way I know about") of having an inferior lisp process.
As of version 1.0.4 of hy-mode, you can start a hy repl buffer in Emacs using M-x run-hy or use the default key binding of C-c C-z.
In any Emacs mode, including hy-mode, you can use M-x describe-mode or the default key binding of C-h m to show key bindings for the current mode.

Emacs and chord translation

I'm having some issues with emacs, in particular when using SLIME. It's not reading the slime-eval-defun command (bound to C-M-x) but will read C-M-S-x... same issue with the indent function C-X-q, I have to add a shift to make it work.
When looking into the key bindings I get this
C-M-x (translated from C-M-S-x) runs the command slime-eval-defun,
which is an interactive Lisp function in `slime.el'.
So it picks up C-M-S-x and assumes that I want C-M-x, which is true, but I'm not getting why it's not picking up C-M-x in the first place!
I'm running emacs on Arch as a guest OS, host OS is OS X.
So I found out that the KDE default shortcut for activating clipboard actions is C-M-x. I removed that and the SLIME shortcut works now.

REPL for Emacs Lisp

What are some REPLs for Emacs Lisp?
Is there only one that is within Emacs?
Are there some that run inside terminal outside Emacs?
Based on this question: REPL on console emacs, you can use M-x ielm (inferior emacs lisp mode).
There is a (work in progress) REPL for Emacs for use from the command line. It currently supports basic command line editing and history.
The code is hosted on Github.
There is this project on Gitlab. The REPL can run on a termninal or on Emacs' minibuffer. Even if you run it in "no-window-system" mode (with -nw).