OK, I'll try an expanded answer. The thing is, Emacs Lisp is single-threaded. You can spin more processes, but not inside the Emacs Lisp interpreter. However, the keyboard input that you need to read from user to interrupt your function needs to be processed by the same Emacs Lisp interpreter. This means that if your interpreter is stuck interpreting some ...
I would go with input-pending-t. From the docs:
(input-pending-p &optional CHECK-TIMERS)
Return t if command input is currently available with no wait.
Actually, the value is nil only if we can be sure that no input is
available; if there is a doubt, the value is t.
A quick example:
;; I put this into a progn call so you can call ...
Unless you spend your days exporting org documents I'd stick to the export interface because it's mature and takes care of the little details.
If you still want something to bind to a single key, a very minimal implementation of it could be:
(org-export-to-file 'latex (read-from-minibuffer "Filename for latex ...
I experienced the same problem, this is what helped me make it work (although I could not find out why):
Generate zh_TW.UTF-8 locale (uncomment in /etc/locale.gen and run locale-gen)
Run emacs with LC_CTYPE set to this locale (env LC_CTYPE=zh_TW.UTF-8 emacs)
Problem solved (or at least "workarounded"). One way to input a Unicode character on GNU Linux systems is for user to press Ctrl+Shift+U followed by the character-specific code and finally by space to terminate the character entry. This key sequence was sent from keyboard. However, for GNU Emacs this key sequence, C-u (translated from C-S-u), runs the ...
Based on hyour description, this keyboard sends events which neither the Linux kernel nor the X11-layer understand as "single-key press" and it's instead some higher layer in some toolkit(s) and/or applications which decodes it. I'd consider this as a shortcoming that should probably be best solved by some kernel-level driver.
But as for a workaround in ...
Probably depends on your keyboard. I have a typical US PC keyboard. I don't know whether I have a <menu> key (for C-<menu>). But the <next> key is the key labeled Page Down.
To see how Emacs calls any given keyboard key, use C-h k. For example, if I use C-h k and hit the key labeled Page Down, Emacs describes what it calls key <next>....
If your purpose is to input Chinese, you could use https://github.com/tumashu/pyim
A native Emacs input method written in pure Emacs Lisp. I just add a new backend pyim-dregcache to pyim. So it requires much less resource and is still fast enough.
The setup is minimum,
(setq pyim-dcache-backend 'pyim-dregcache) ; ...
I don't have access to a Brezilian keyboard. For swapping an ordinary US Qwerty keyboard you can use the following. You can adapt it for any keyboard. (This is essentially the answer https://emacs.stackexchange.com/a/3882/ duo to @abo-abo).
(add-hook 'LaTeX-mode-hook 'my-latex-hook)
(defun my-latex-hook ()
(define-key LaTeX-mode-map "...
The following code works for me:
(bind-key "M-a" (lambda ()
"Move point to the first non-whitespace character on this line. If point was already at that position, move point to beginning of line."
(let ((oldpos (point))) (back-to-indentation) (and (= oldpos (point)) (beginning-of-line)))...
I am not aware of any hook before/after new key-bindings but you can add advices to define-key. define-key is the low-level function called by other functions like global-set-key, local-set-key, or substitute-key-definition-key.
In your case a :filter-args advice seems to be the most appropriate one.
An example code that swaps x and z in newly defined key-...