elisp - emacs call-interactively and key simulation -
i want write small function saves cursor's current position, mark whole buffer, indents , goes previous cursor position. understand there might easier way achieve same result i'd understand how these principles work in elisp.
here's tried :
(defun indent-whole-buffer () (interactive) (call-interactively 'point-to-register) (call-interactively (kbd "ret")) (mark-whole-buffer) (call-interactively 'indent-region) (call-interactively 'jump-to-register) (call-interactively (kbd "ret")) ) the blocking point here (call-interactively (kbd "ret")) how can simulate ret key, if doing
m-x point-to-register ret
just use save-excursion. that's it's for. saves point , mark , buffer current, , restores them you.
(and if did decide roll own, , did decide in way planned, call functions need directly - no need use call-interactively. use c-h f see how each function called. example (point-to-register ?a) captures point in register a, , (indent-region (point-min) (point-max)) indents whole buffer.)
Comments
Post a Comment