Closed mkrauss closed 1 year ago
It would make sense, but do you know of any modes that treat floats as atoms?
That's the ones I can come up with in a couple minutes. Admittedly, not most, but some of the best - json-mode would be joining good company.
Sorry, I mistakenly thought you meant M-f (forward-word)
but not C-M-f (forward-sexp)
.
I have surveyed the behavior of each mode:
c-mode:
Inside strings:
forward-sexp: stops at dot.
forward-word: stops at dot.
Inside comments:
forward-sexp: stops at dot.
forward-word: stops at dot.
Float literal:
forward-sexp: stops at dot.
forward-word: stops at dot.
Dot operator/symbol with dot:
forward-sexp: stops at dot.
forward-word: stops at dot.
js2-mode:
Inside strings:
forward-sexp: stops at dot.
forward-word: stops at dot.
Inside comments:
forward-sexp: exits from the comment.
forward-word: stops at dot.
Float literal:
forward-sexp: skips whole literal.
forward-word: stops at dot.
Dot operator/symbol with dot:
forward-sexp: stops at dot.
forward-word: stops at dot.
python-mode:
Inside strings:
forward-sexp: stops at dot.
forward-word: stops at dot.
Inside comments:
forward-sexp: stops at dot.
forward-word: stops at dot.
Float literal:
forward-sexp: skips whole literal.
forward-word: stops at dot.
Dot operator/symbol with dot:
forward-sexp: skips whole expression.
forward-word: stops at dot.
emacs-lisp-mode:
Inside strings:
forward-sexp: skips whole literal.
forward-word: stops at dot.
Inside comments:
forward-sexp: skips whole literal.
forward-word: stops at dot.
Float literal:
forward-sexp: skips whole literal.
forward-word: stops at dot.
Dot operator/symbol with dot:
forward-sexp: skips whole literal.
forward-word: stops at dot.
shell-script-mode:
Inside strings:
forward-sexp: skips whole literal.
forward-word: stops at dot.
Inside comments:
forward-sexp: skips whole literal.
forward-word: stops at dot.
Float literal:
forward-sexp: skips whole literal.
forward-word: stops at dot.
Dot operator/symbol with dot:
forward-sexp: skips whole literal.
forward-word: stops at dot.
python-mode
seems to be the most sophisticated.
I will implement a function for forward-sexp-function
as follows:
.
is a symbol, using with-syntax-table
.
I would think that a number should be an atom for purposes of *-sexp functions, but they treat them as two separate sexps separated by a period. This behavior makes it near impossible to use keyboard macros to operate on values regardless of whether they are scalar data or complex sub-objects.