There are some text actions that I use so often in emacs that the user-made commands I currently use, invoked with the standard M-x ... RET procedure do not satisfy me. I would like to replace their key bindings with shorter ones, with as few keystrokes as possible (ideally two, as it is in elaborate IDEs). It seems I cannot use keyboard macros here because according to the manual, Keyboard macros are not "powerful enough" to achieve what ordinary Emacs commands do (according to https://www.gnu.org/software/emacs/manual/html_node/emacs/Keyboard-Macros.html).
Perhaps I can override some builtin C- or M- commands ? There are several that I will probably never need anyway. Is there a safe, recommended way to do this ?
(defun wrap-with-italics-phpbb-tag (start end) "Wraps the selected text or the point with a tag" (let (string) (if mark-active (list (setq string (buffer-substring start end)) (delete-region start end))) (yas/expand-snippet (point) (point) (concat "[i]" string "[/i]")))) (global-set-key (kbd "C-i") 'wrap-with-italics-phpbb-tag)
This does not work because
global-set-keys expects an interactive command.