Function: gnus-search-query-return-string

gnus-search-query-return-string is a byte-compiled function defined in gnus-search.el.gz.

Signature

(gnus-search-query-return-string &optional DELIMITED TRIM)

Documentation

Return a string from the current buffer.

If DELIMITED is non-nil, assume the next character is a delimiter character, and return everything between point and the next occurrence of the delimiter, including the delimiters themselves. If TRIM is non-nil, do not return the delimiters. Otherwise, return one word.

Source Code

;; Defined in /usr/src/emacs/lisp/gnus/gnus-search.el.gz
(defun gnus-search-query-return-string (&optional delimited trim)
  "Return a string from the current buffer.
If DELIMITED is non-nil, assume the next character is a delimiter
character, and return everything between point and the next
occurrence of the delimiter, including the delimiters themselves.
If TRIM is non-nil, do not return the delimiters.  Otherwise,
return one word."
  ;; This function cannot handle nested delimiters, as it's not a
  ;; proper parser.  Ie, you cannot parse "to:bob or (from:bob or
  ;; (cc:bob or bcc:bob))".
  (let ((start (point))
	(delimiter (if (stringp delimited)
		       delimited
		     (when delimited
		       (char-to-string (char-after)))))
	end)
    (if delimiter
	(progn
	  (when trim
	    ;; Skip past first delimiter if we're trimming.
	    (forward-char 1))
	  (while (not end)
	    (unless (search-forward delimiter nil t (unless trim 2))
	      (signal 'gnus-search-parse-error
		      (list (format "Unmatched delimited input with %s in query" delimiter))))
	    (let ((here (point)))
	      (unless (equal (buffer-substring (- here 2) (- here 1)) "\\")
		(setq end (if trim (1- (point)) (point))
		      start (if trim (1+ start) start))))))
      (setq end (progn (re-search-forward "\\([[:blank:]]+\\|$\\)" (point-max) t)
		       (match-beginning 0))))
    (buffer-substring-no-properties start end)))