unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* forward-sexp when on a floating point number
@ 2016-01-12 10:42 Oleh Krehel
  2016-01-12 13:58 ` Herring, Davis
                   ` (4 more replies)
  0 siblings, 5 replies; 15+ messages in thread
From: Oleh Krehel @ 2016-01-12 10:42 UTC (permalink / raw)
  To: emacs-devel


Hi all,

When working with C++ or Python code an having e.g. this point position:

    1|23.456

I'd like "C-M-f" (`forward-sexp') to move the point here:

    123.456|

Instead, I get this:

    123|.456

This of course extends to all other sexp interactions (`mark-sexp',
`kill-sexp', `bounds-of-thing-at-point' etc).  The problem here is that
I can't do something like:

    (modify-syntax-entry ?\. "w" c++-mode-syntax-table)

since the current behavior is actually correct for things like:

    f|oo.bar ()

I finally ended up with this solution:

    (setq forward-sexp-function 'my-forward-sexp-function)
    
    (defun my-forward-sexp-function (arg)
      (let ((forward-sexp-function nil))
        (forward-sexp arg))
      (when (and (eq (char-after) ?.)
                 (looking-back "[0-9]+" (line-beginning-position)))
        (forward-char)
        (skip-chars-forward "[0-9]")))

Is there any interest in making this behavior, i.e. treating each
floating point number as a single sexp, the default (or at least easily
customizable) in the core?

regards,
Oleh



^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2016-01-20 22:15 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-01-12 10:42 forward-sexp when on a floating point number Oleh Krehel
2016-01-12 13:58 ` Herring, Davis
2016-01-12 14:20 ` Andreas Schwab
2016-01-12 14:41   ` Oleh Krehel
2016-01-12 17:35 ` John Wiegley
2016-01-12 17:45 ` Dmitry Gutov
2016-01-17 23:07 ` Stefan Monnier
2016-01-17 23:42   ` John Wiegley
2016-01-18  1:36     ` Stefan Monnier
2016-01-18  5:08       ` John Wiegley
2016-01-18 13:30         ` Stefan Monnier
2016-01-18 19:02           ` John Wiegley
2016-01-18 21:03           ` Marcin Borkowski
2016-01-18 21:34             ` Stefan Monnier
2016-01-20 22:15               ` Marcin Borkowski

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).