You could use a transient key map to do this:
(defun my-fun ()
(let ((mes "Important data")
(define-key map "j" (lambda () (interactive) (insert mes)))
Here, I define a new keymap map, and give it a single binding for the key j. After I display the ...
There is a common convention that a numeric prefix argument means “do it this many times”. If a command follows this convention, a prefix argument of 0 is useless. However, not all commands follow this convention or the other common convention of having two behaviors, one with no argument and one with a prefix argument other than 1.
For example, save-buffer ...
@gilles and @npostavs have given use cases. To summarize what they said:
When you're already using C- or M- for part of a key sequence, it can be easier to specify a zero prefix arg using C-0 or M-0 than using, say, C-u 0.
A zero numeric prefix arg can have a specific (not necessarily numeric) meaning for a given command. @Gilles mentioned save-buffer, ...
Ctrl+/ has the same effect as BackSpace because your terminal tells Emacs that you pressed Backspace: it sends DEL for Ctrl+/. There's no character for C-/ and most terminals don't have a control sequence for it, so there's no chance that Emacs would see C-/. You need to reconfigure the terminal to either send a different escape sequence that you bind to ...
You can use a transient map for this. A transient map is a keymap that is only active for a single keypress, and lets keys not in the keymap "fall through", and do their normal behavior.
This code inserts "command2" when command2 is run. When command1 is run, it prints a message into the minibuffer. Then, if you press j, it calls command2. If you instead ...
I cannot think any use case...
It just makes entering numeric prefix arguments a little easier. For example, with numeric argument of 0, C-k (kill-line) will delete from point to the beginning of line. You can invoke this with C-0 C-k which is easier than typing C-u 0 C-k.
buffer-invisibility-spec is a buffer local variable.
If you want globally set the key you must add a to the default value of buffer-invisible-spec.
global-set-key is a function therefore the argument (add-text-properties ...) is evaluated before global-set-key. The return value of add-text-properties is undefined in the doc. So you bind your keys to some ...
If an input event is not bound and contains the Shift modifier or is an uppercase character, Emacs converts it to the corresponding unshifted or lowercase event. This is discreetly documented in the Emacs Lisp manual under read-key-sequence. Unlike what the docstring of read-key-sequence says, this isn't limited to the first event in a sequence: if KEY1 is ...
Define a keymap variable as usual, conventionally called NAME-mode-map. To use this keymap, the major mode startup function needs to call use-local-map. If you're making your own call to define-generic-mode, pass a call to use-local-map in the function-list argument of define-generic-mode.
(let ((map (make-sparse-keymap)))
Sounds like you want to define a new prefix key, say C-c z, for cider-mode, binding it to a smart-parens keymap.
Assuming that smart-parens-mode-map is that keymap, and assuming that cider-mode-map is the keymap that defines C-c as a prefix key, you can do this:
(define-key cider-mode-map (kbd "C-c z") smart-parens-mode-map)
One easy solution is to use libraries zones.el and isearch-prop.el.
zones.el is about defining and using sets of zones of contiguous text. In this case, you use only one zone, defined by the region.
isearch-prop.el is about isearching text-property or overlay-property contexts. Visibility is just one kind of property.
(You can do the same thing using just ...
Taken from this emacs wiki page:
Emacs is set up so that the keys, particularly all the control-, meta-, alt- keybindings keep working if you inadvertantly leave the shift-lock key on. So it assumes that you were looking for the unshifted one if this is the only keybinding defined on that key. Hence it sees the shifted function key, checks to see if the ...
That is not so easy, because C-c is a general prefix key in Emacs. Here is a hacky way to achieve that, don't know if there are better options:
(add-hook 'eshell-mode-hook 'my-hacky-C-c-remap)
(defun my-hacky-C-c-remap ()
;; choose any key you dont use for translation
Sounds like Emacs is not seeing those keys at all. Check your window manager or OS, to see if it intercepts them for something else.
And the best syntax to use with kbd is the one you see when you use C-h k. When I try that for such keys I see C-x <C-left>, C-x <C-up>, etc. (But your question says that you already tried C-x <C-left>, so I ...