This answer depends on the
bind-key.el file in Wiegley's
Probably a cleaner way to do this, but this should work for your purposes. You say you want the cursor to "hop" over the delimiters, but also say the cursor should move over one space. I assumed you meant 2 spaces. Remove the first
(defun special-tab ()
"Wrapper for tab key invocation.
If point is just before a close delimiter, skip forward until
there is no closed delimiter in front of point. Otherwise, invoke
normal tab command for current mode.
Must be bound to <tab> using bind-key* macro from bind-key package.
Note, this function will not be called if `override-global-mode' is
(defun next-char-delims (delims)
(let ((char (and (not (equal (point) (point-max)))
(string (char-after (point))))))
(when char (member char delims))))
(let ((open '("'" "\"" ")" "]")))
(if (next-char-delims open)
(progn (forward-char 1)
(while (next-char-delims open)
(call-interactively (key-binding (kbd "TAB"))))))
(if (macrop 'bind-key*)
(bind-key* (kbd "<tab>") 'special-tab)
(user-error "Must have bind-key from use-package.el to use special-tab function."))