Function: term-extract-string

term-extract-string is a byte-compiled function defined in term.el.gz.

Signature

(term-extract-string)

Documentation

Return string around point that starts the current line or nil.

Source Code

;; Defined in /usr/src/emacs/lisp/term.el.gz
;; (TERM-GET-SOURCE prompt prev-dir/file source-modes mustmatch-p)
;;============================================================================
;; TERM-GET-SOURCE is used to prompt for filenames in command-interpreter
;; commands that process source files (like loading or compiling a file).
;; It prompts for the filename, provides a default, if there is one,
;; and returns the result filename.
;;
;; See TERM-SOURCE-DEFAULT for more on determining defaults.
;;
;; PROMPT is the prompt string.  PREV-DIR/FILE is the (directory . file) pair
;; from the last source processing command.  SOURCE-MODES is a list of major
;; modes used to determine what file buffers contain source files.  (These
;; two arguments are used for determining defaults).  If MUSTMATCH-P is true,
;; then the filename reader will only accept a file that exists.
;;
;; A typical use:
;; (interactive (term-get-source "Compile file" prev-lisp-dir/file
;;                                 '(lisp-mode) t))

;; This is pretty stupid about strings.  It decides we're in a string
;; if there's a quote on both sides of point on the current line.
(defun term-extract-string ()
  "Return string around `point' that starts the current line or nil."
  (save-excursion
    (let* ((point (point))
	   (bol (line-beginning-position))
	   (eol (line-end-position))
	   (start (and (search-backward "\"" bol t)
                       (1+ (point))))
	   (end (progn (goto-char point)
		       (and (search-forward "\"" eol t)
			    (1- (point))))))
      (and start end
	   (buffer-substring start end)))))