I want to remap forward-sexp
to matlab-forward-sexp
in matlab-mode
.
Currently I do this:
(define-key matlab-mode-map [remap forward-sexp] 'matlab-forward-sexp-safe)
but when I type M-x forward-sexp
in matlab-mode I still get the old behaviour. Why? Does it only work when I call forward-sexp
through a keyboard shortcut?
when I type C-h f forward-sexp
everything seems ok:
forward-sexp is an interactive compiled Lisp function in `lisp.el'.
It is remapped to `matlab-forward-sexp-safe', which is bound to C-M-f,
<C-M-right>, ESC <C-right>.
(forward-sexp &optional ARG)
For more information check the manuals.
Move forward across one balanced expression (sexp).
With ARG, do it that many times. Negative arg -N means
move backward across N balanced expressions.
This command assumes point is not in a string or comment.
This function is advised.
After-advice `ctx-flash'.
[back]
If you really want to change the behavior of the function, you can use forward-sexp-function
.
Also you may like to check out Emacs-24's octave-mode, which uses SMIE for parsing, making forward-sexp automatically jump over actual Octave syntactic elements rather than only parens/brackets/braces.