Can't rebind key C-z in xemacs - xemacs

For some reason, "C-z" is mapped to suspend-or-iconify-emacs and I can't seem to get it to rebind to something less annoying. (I like using ctrl-z for undo, but doing nothing would at least be better than suspending every time I accidentally hit the key)
I've tried doing it interactively:
M-x global-set-key, then Set key C-z to command: undo.
M-x describe-key-briefly gives me C-z runs the command suspend-or-iconify-emacs
I've tried going to the scratch buffer and evaluating:
(global-set-key (kbd "C-z") 'undo) and (global-set-key "\C-z" 'undo), and it is of course in my .xemacs/init.el file.
Nothing seems to actually rebind the key.
This is happening on XEmacs 21.5, in Fundamental mode. Any ideas on how to troubleshoot this?
edit: Ok here is a hack that gets around the problem by redefining the suspend function to undo:
(defun suspend-or-iconify-emacs () (interactive) (undo))
I can't actually suspend emacs anymore, but that's actually ok with me.

Try evaluating this:
(define-key global-window-system-map [(control z)] 'undo)
(assuming that you aren't running XEmacs in tty-mode, but I guess you are not, if you want to iconify :-))
I used C-h b to find out what *-map to modify.

I have the following code in my .emacs:
(global-set-key (kbd "C-z") 'eshell)
It will start an eshell, and it works.
The C-z combination is pretty standard on Unix/Linux, if you're working in a terminal with e.g. vi, lynx or mutt and presses C-z the program will suspend and you will be back in the shell. Issuing the 'fg' command will pop the program back again. As Emacs has its own shell, I like spawning that when pressing C-z in Emacs.
You can also add the following hook, that will remap C-z in the eshell. That way pressing C-z in the eshell with get you back to the buffer you were editing.
(add-hook 'eshell-mode-hook
(lambda ()
(local-set-key (kbd "C-z") 'bury-buffer)))

Put that at the end of your .xemacs/init.el :
(global-set-key (kbd "C-z") 'undo)
Or maybe you have a misconfigured keyboard or operating system.
Do C-h k C-z to see if xemacs really receives a C-z key.

I had the same problem with C-f. I wanted it to map to isearch-forward, but instead it kept moving one character forward.
I finally solved my problem by adding
(global-unset-key [?\C-f])
(global-set-key [?\C-f] 'isearch-forward)
Apparently the issue is that C-f (and C-z) is a "real" key, that is, it's something that a terminal recognizes (it's ASCII 0x06, 0x1a for C-z), so you need the "?\" in front of "C-f".
This is the only thing I got to work.
HTH
(EDIT: I should note that I use emacs, not xemacs)

Related

How to efficiently yank to system clipboard in WSL2 neovim?

I've installed win32yank through chocolatey and changed clipboard setting in init.vim:
set clipboard=unnamedplus
Everything works however I notice that copy and paste operations now have very slight but noticeable delay. Is there any alternative way to copy to system clipboard? (I'm using neovim in WSL2 Ubuntu)
Just remove clipboard option. It's harmful and useless.
What it essentially does, it prepends "quote-plus" to all yank/delete/put commands automatically. Instead of this, manually type "+ when you want to access system clipboard and don't when you don't.
I've expanded on Matt's feedback and put this in my vimrc:
let mapleader=" "
noremap <Leader>y "+y
noremap <Leader>p "+p
noremap <Leader>d "+d
Select a block of text, press and then either y/p/d for yanking, pasting and deleting lines into the system buffer. It automagically seems to work with win32yank.exe (which is in my PATH in WSL2).

How to have special/accented characters support in IntelliJ terminal

I use the IntelliJ IDEA's Embedded Local Terminal quite a lot, but there is one thing that is driving me nuts : special and accented characters do not work.
This is what should but is not working :
HOME key to go to the beginning of the line : does nothing
END key to go to the end of the line : does nothing
[CTRL + left arrow] to go to previous word : prints D
[CTRL + right arrow] to go to next word : prints C
all accented characters : prints nothing at first, then ? when I hit another key
There are probably other combinations that should but do not work ... but these are the most annoying ones.
I'm using :
Ubuntu 16.04 virtual box guest running on a Windows 10 host
IntelliJ IDEA 2016.2.4
zsh
oh-my-zsh
Important notes :
in a GNU Terminal (outside of IntelliJ then) everything works perfectly, so I don't think that the "running inside a VM" thing is the source of the problem.
if I run bash instead of zsh the special characters are working (home, end, next work, etc...) but I still don't have propre support of accented characters (prints �), and I'd really prefer using zsh.
showkey --scancodes prints Couldn't get a file descriptor referring to the console
if I start od -c I get ^[[H for the HOME key and ^[[F for the END key
showkey --ascii works and prints ^[[H too for the HOME key
What I did already :
checked that the TERM variable is not overridden in .zshrc
add bindkey "${terminfo[khome]}" beginning-of-line and end of line equivalent in .zshrc
add lines (that seemd appropriate) in .inputrc for readline (OK I see now that this was useless as Zsh does not use readline)
edit : I could make the home/end keys work (see accepted answer below), but not the CTRL+LEFT and CTRL+RIGHT key (for forward-word and backward-word). After some more digging this seems to be an issue with IntelliJ not 100% properly emulating the terminal. 4
There is an issue here, with interesting input from an oh-my-zsh contributor : https://youtrack.jetbrains.com/issue/IDEA-118848#comment=27-1292473
They consider ditching smkx (which appears to be the root of the problem) from oh-my-zsh soon. I've checked out this PR and now my keys work fine (still need the bindings, but CTRL+LEFT and CTRL+RIGHT are ok now)
edit: accented/special characters are now properly supported in IntelliJ (yeehaa !), be sure to have at least the following version : IntelliJ IDEA 2016.3.1, Build #IC-163.9166.29, built on December 9, 2016
I can appreciate that zsh works fine outside IntelliJ.
Step 1
Find the correct key codes being used by the terminal inside Intellij. This will depend on the OS you are using. For OSX and Linux od -c followed by pressing the keys will result in the key code being emitted.
Step 2
Once you have the keycodes, modify your ~/.zshrc :
bindkey "$HOME_KEY_CODE_FROM_STEP_1" beginning-of-line
bindkey "$END_KEY_CODE_FROM_STEP_1" end-of-line
for example (as was the case for the OP):
bindkey "^[[H" beginning-of-line
bindkey "^[[F" end-of-line
and restart the terminal.

Setting ft=vb causing vim's parenthesis matching to stop working

I'm having a weird issue in which I can't get parentheses to match in VB files in vim or gvim.
For example, if I start vim and insert Iif(test, 0, 1), I can use % to jump between the two parentheses like normal. Then if I run :set ft=vb, it stops working. Actually, I get one more jump, then it stops working.
I have tested this on two different machines running Windows and Linux and I get the same results.
Does anyone know why this might be?
You're using the matchit plugin that comes with Vim. In $VIMRUNTIME/ftplugin/vb.vim, it defines custom pairs (e.g. If...End If) which override the default pairs. To re-enable those (in addition), put the following into ~/.vim/after/ftplugin/vb.vim:
let b:match_words .= ',(:)'
Cp. :help b:match_words.

elisp: generate LaTeX PDF document

I trying to completely automatize sending job applications. First step, to put the name of the company in a letter. It almost works, but it is stuck because it asks what command to use. Reading the documentation, I thought it could be disabled by a prefix argument, but I got something wrong. Also, it doesn't need to flash by visually, it could be done completely as a background process. I'll paste the code and you'll understand immediately:
(Oh, I'm using LaTeX/P mode in emacs - the goal is to not only update the .tex but also the .pdf file)
(defun edit-letter (comp-name)
(let ((path "~/work/letter/comp"))
(edit-letter-file-path comp-name (concat path "/eng/letter.tex"))
(edit-letter-file-path comp-name (concat path "/swe/brev.tex")) ))
(defun edit-letter-file-path (company-name file-path)
(find-file file-path)
(goto-line 14)
(kill-line)
(insert (format "\\textbf{To %s}\n" company-name))
(setq current-prefix-arg nil)
(call-interactively 'TeX-command-master) ; asks what command
(kill-buffer) ) ; doesn't work
(edit-letter "Digital Power Now")
It's not entirely clear from your question what you're after, but if you want to use AucTeX to call a LaTeX/PDFTex/BibTex process without getting prompted for the command name, you can use this:
(TeX-command "LaTeX" 'TeX-master-file)
Try this in place of (call-interactively 'TeX-command-master) above. When you're using LaTeX/P "LaTeX" really means pdflatex.

How do you quit the Vi editor with single keypress?

Because honestly
:wq!
is just too much to type.
Please note that the question is about original Vi (say Vi which comes with FreeBSD) not Vim.
Hold down the shift key and bang on Z twice.
ZZ is (mostly) equivalent to :wq!.
If you really want a single-keystroke solution, FreeBSD comes with the source so, in a pinch, you could modify that and re-compile. It's a bit of an overkill but it'll solve your problem.
What about "ZZ"? It has slightly different semantics to ":wq!", but is also slightly shorter.
This seems to work on solaris' old version of vi:
Version SVR4.0, Solaris 2.5.0
$ vi -c "map g ZZ" test
edit: Also, this seems to work:
$ vi -c 'map g :q!^M' test
Where ^M is actually, ^V (ctl-v) then ^M (ctl-m)
Map your favourite key to the :wq! command.
e.g. put this in your .vimrc:
map <F8> :wq!<CR>
Et voilá.
Edit:
Sorry, vim only, missed that.
Does :x work on Vi? Although for your case I guess it might be :x!
If you're using gvim you can close it with ALT+F4. Two keys, but one keypress.
If you're using vi in its own xterm, ALT+F4 should close the xterm, killing vi as well.
What's wrong with the tried and true?
:x
It's not one key press, but it's much less than :wq! which is what your question appears to truly seek.
Or is this a ViM only feature? My apologies if so.