Function: comint-word
comint-word is a byte-compiled function defined in comint.el.gz.
Signature
(comint-word WORD-CHARS)
Documentation
Return the word of WORD-CHARS at point, or nil if none is found.
Word constituents are considered to be those in WORD-CHARS, which is like the
inside of a "[...]" (see skip-chars-forward), plus all non-ASCII characters.
Source Code
;; Defined in /usr/src/emacs/lisp/comint.el.gz
(defun comint-word (word-chars)
"Return the word of WORD-CHARS at point, or nil if none is found.
Word constituents are considered to be those in WORD-CHARS, which is like the
inside of a \"[...]\" (see `skip-chars-forward'), plus all non-ASCII characters."
;; FIXME: Need to handle "..." and '...' quoting in shell.el!
;; This should be combined with completion parsing somehow.
(let ((beg
(save-excursion
(let (giveup)
(while (not giveup)
(let ((startpoint (point)))
(skip-chars-backward (concat "\\\\" word-chars))
(if (and (eq (char-before (1- (point))) ?\\)
(memq (char-before) comint-file-name-quote-list))
(forward-char -2))
;; FIXME: This isn't consistent with Bash, at least -- not
;; all non-ASCII chars should be word constituents.
(if (and (not (bobp)) (>= (char-before) 128))
(forward-char -1))
(if (= (point) startpoint)
(setq giveup t)))))
(point))))
(when (< beg (point))
(let ((end
(save-excursion
(let (giveup)
(while (not giveup)
(let ((startpoint (point)))
(skip-chars-forward (concat "\\\\" word-chars))
(if (and (eq (char-before) ?\\)
(memq (char-after) comint-file-name-quote-list))
(forward-char 1))
(if (and (not (eobp)) (>= (char-after) 128))
(forward-char 1))
(if (= (point) startpoint)
(setq giveup t))))
(point)))))
;; Set match-data to match the entire string.
(set-match-data (list beg end))
(match-string 0)))))