Function: eshell-parse-special-reference

eshell-parse-special-reference is a byte-compiled function defined in esh-arg.el.gz.

Signature

(eshell-parse-special-reference)

Documentation

Parse a special syntax reference, of the form #<args>.

args := type whitespace arbitrary-args | arbitrary-args
type := "buffer" or "process"
arbitrary-args := any string of characters.

If the form has no type, the syntax is parsed as if type were
"buffer".

Source Code

;; Defined in /usr/src/emacs/lisp/eshell/esh-arg.el.gz
(defun eshell-parse-special-reference ()
  "Parse a special syntax reference, of the form `#<args>'.

args           := `type' `whitespace' `arbitrary-args' | `arbitrary-args'
type           := \"buffer\" or \"process\"
arbitrary-args := any string of characters.

If the form has no `type', the syntax is parsed as if `type' were
\"buffer\"."
  (when (and (not eshell-current-argument)
             (not eshell-current-quoted)
             (looking-at "#<\\(\\(buffer\\|process\\)\\s-\\)?"))
    (let ((here (point)))
      (goto-char (match-end 0)) ;; Go to the end of the match.
      (let ((buffer-p (if (match-string 1)
                          (string= (match-string 2) "buffer")
                        t)) ;; buffer-p is non-nil by default.
            (end (eshell-find-delimiter ?\< ?\>)))
        (when (not end)
          (throw 'eshell-incomplete ?\<))
        (if (eshell-arg-delimiter (1+ end))
            (prog1
                (list (if buffer-p 'get-buffer-create 'get-process)
                      (replace-regexp-in-string
                       (rx "\\" (group (or "\\" "<" ">"))) "\\1"
                       (buffer-substring-no-properties (point) end)))
              (goto-char (1+ end)))
          (ignore (goto-char here)))))))