How can change this behaviour:
C-s — start incremental search
type word — misprint the last character
Backspace — Oops! incremental search disappears, and I actually delete 1 character from the buffer.
to that one:
C-s — start incremental search
word — misprint the last character
Backspace — delete the last d character
type k — work — correct, and continue the search
I run Emacs in text terminal via SSH in PuTTY.
Operating system version: 2.6.16.60-0.58.1.1882.3.PTF.638363-smp #1 SMP Wed Dec 2 12:27:56 UTC 2009 x86_64 x86_64 x86_64 GNU/Linux
Emacs version: GNU Emacs 23.2.1 (x86_64-unknown-linux-gnu, GTK+ Version 2.14.6) of 2010-07-16
With the -q option, Backspace sent by PuTTY is just C-h, and it acts like C-h, but in my .emacsfile I it bind to delete-backward-char:
(global-set-key [(control h)] 'delete-backward-char)
Try this:
(define-key isearch-mode-map [(control h)] 'isearch-delete-char)
What you should do is configure PuTTY to send C-? (byte 127) for Backspace instead of C-h (byte 8). This is the setting that works best in most circumstances. See the
PuTTY manual.
If you changed the PuTTY setting to send C-h because some other application didn't work, check that your terminal settings are correct on the server. The setting is often correctly autodetected, but sometimes you may need to add stty erase '^?' to your shell configuration file (.bashrc or similar) on the server.
If you really absolutely have to have Backspace send C-h, then globally rebinding C-h isn't sufficient. Instead, add (normal-erase-is-backspace-mode 1) to your .emacs. See the Emacs manual.
How you should use Emacs:
C-s - start incremental search
type word - misprint the last character
M-e - goes into edit-search-word-thing-mode-in-minibuffer :-)
correct the typo
C-s - continue incremental search
Related
I have run into issues using the emacs server started when I log in and emacsclient. Specifically, I use the same emacs server for different R projects things get ugly and commands from different projects end up going to the same R session.
My work around is to invoke a second server with /usr/bin/emacs --daemon=Rmd-1 when I log in. I have a bash script written such that the first .Rmd file I work with attaches to this daemon and then the command /usr/bin/emacs --daemon=Rmd-2 is issued. If I end up working with a second .Rmd file, then this server is used and a third server is started with /usr/bin/emacs --daemon=Rmd-3 and ready to work with another .Rmd file if needed.
This works pretty well except for one thing. Because after many years I am hard wired to end my emacs session using C-x C-c by the end of the day I have many emacs servers running. I'm looking for a way to trigger save-buffers-kill-emacs when the C-x C-c command is given in an emacsclient running on a daemon matching "Rmd-[0-9]+". I can't see any emacsclient options that would do that and I'm at a loss as to how to edit my custom.el file.
Can some one help me?
(note I'm running GNU Emacs 27.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.30) on Ubuntu 22.04)
Drawing on McNisse's suggestion, adding the following to my personal.el file seems to give me the desired behavior.
;; Remap C-c C-x if daemon name matches "Rmd-[0-9]+"
;;
(cond
((string-prefix-p "Rmd-" (daemonp))
(global-set-key (kbd "C-x C-c") 'save-buffers-kill-emacs)
)
)
Invoking 'shell' by M-x shell,
and plan to start a tmux session
it report errors
$ tmux
open terminal failed: terminal does not support clear
What's the problem?
If invoking `ansi-term', the operations of yanking and pasting are invalid.
So, shell perform better than ansi-term in routines.
How could activate tmux within a shell
tmux needs a real terminal, and shell doesn't provide that (as implied by the error you get). So you need to use term with tmux.
Or you can use built in functionality of Emacs to have features of tmux. E.g. C-x 2 and C-x 3 will split the frame into windows so you can have multiple terminals in a frame (an Emacs frame is what most applications would call a window). Start an emacs server and emacsclient to have sessions that you can connect to and keep running after you close the frame.
Copy (M-w) and paste (S-<insert>) should work by default. If you want to play with bindings, the key map is called term-raw-map and the commands are kill-ring-save and term-paste.
Also learn the difference between term-line-mode (C-c C-j) and term-char-mode (C-c C-k). Briefly, line mode behaves more like shell, and char mode behaves more like a real terminal, with most Emacs keybindings unavailable. I personally keep term buffers in char mode almost always and add some keybindings to term-raw-map so I can run certain Emacs commands.
There's a huge literature on the topic, but, nevertheless, I cannot get this done.
My ultimate goal is to work with fstar on Microsoft Windows.
C-x C-f resolves ~ as C:/Users/myname which is in line with my HOME environment variable in the Environmental variables Windows section.
(expand-file-name user-emacs-directory), as described here yields, C:/Users/myname/.emacs.d/
In C:/Users/myname/.emacs.d/ I have placed .emacs.el and init.el with the suggested script:
(require 'package) (add-to-list 'package-archives '("melpa" .
"http://melpa.org/packages/") t) (package-initialize)
However M-x returns undefined, no matter if I start Emacs with or without the -q flag (see here). My "Messages" buffer is empty".
A couple of things you could try:
Check the value of the variable user-init-file (use C-h v). That should tell you if Emacs loads the file you want it to load. If you started Emacs with the -q option, the value of this variable should be nil.
The error M-x is undefined can be caused by rebinding the Escape key. (That's because pressing a key while holding down the "Meta" key is equivalent to first pressing Escape and then the key in question.) Is there something in the init file that might cause this to happen?
Try starting Emacs with -Q instead of -q. This makes Emacs skip "site-wide" init files. I can't really think of a reason why your system would have any of those, but it might be worth ruling this out.
You could edit your question and include your entire init file (surround it with ``` on a line by itself), so we could have a look.
My environment:
OS: Linux CentOS 7 (x86_64)
PostgreSQL version: 10.5
Emacs 26.1
I use Emacs as the external editor in postgresql (set in my EDITOR environment variable). So whenever I type in psql shell, \e it opens Emacs where I can write/modify queries, views, functions, etc.
If I understand correctly, once Emacs is open, when I enter C-x C-s, that is, I save and then I quit C-x C-c, the content edited in Emacs is transferred to the query buffer to be parsed and executed (assuming it contains semicolon at the end). So basically each time I have to run \e then edit, then save and quit the editor to get the job done.
Now, given that I use Emacs for multiple programming languages, I've rather a big init file. As a result, it takes several seconds to start Emacs (both in -nw and GUI mode). Obviously this is quite annoying given the number of times that I have to open and quit the editor while I'm using \e in psql.
So my question is: Is there any way to let the external editor remain open and continue working with the same editor for further queries and somehow decide to transfer the result to query buffer without needing to quit the editor?
Run emacsclient instead of emacs. I have a script at ~/bin/editor:
#!/bin/sh
exec emacsclient -c -a '' "$#"
And then I set export EDITOR=$HOME/bin/editor in my ~/.bashrc.
The upshot is you only start Emacs once, and every time you run $EDITOR, it just attaches to the same Emacs session.
Also, I do
(global-set-key (kbd "C-x C-c") #'delete-frame)
(global-set-key (kbd "C-x C-S-c") #'save-buffers-kill-emacs)
so C-x C-c just deletes the frame instead of killing Emacs.
Just save the query to a temporary file, for example /tmp/q.sql and run \i /tmp/q.sql from psql multiple times from a second terminal.
For session management with emacs, I appended the following lines to my .emacs file
(load "desktop")
(desktop-load-default)
(desktop-read)
I was able to save the session using M-x desktop-save. But after exiting emacs, I am unable to recover the earlier saved session. I did start emacs in the same directory as that during "desktop-save"
Please let me know if I am missing anything or not correct in my efforts
Thanks
-- Harish
Chapter 51 'Saving Emacs Sessions' of my Emacs manual (using a Emacs 23 snapshot) has this
You can save the desktop manually
with the command M-x desktop-save'.
You can also enable automatic saving
of the desktop when you exit Emacs,
and automatic restoration of the last
saved desktop when Emacs starts: use
the Customization buffer (*note Easy
Customization::) to set
desktop-save-mode' to t' for future
sessions, or add this line in your
~/.emacs' file:
(desktop-save-mode 1)
which is different from what you tried.
The following worked for me (emacs 21.3.1):
(load "desktop")
(setq desktop-save-mode 1)
(desktop-load-default)
(desktop-read)
The desktop-save-mode line is only needed if you want to save desktop automatically on exit (i.e. without bothering to type M-x deskstop-save).
The only difference is that I put those lines at the beginning of the .emacs file but I doubt that's a problem.