Function: eshell-parse-backslash

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

Signature

(eshell-parse-backslash)

Documentation

Parse a single backslash (\) character and the character after.

If the character after the backslash is special, always ignore the backslash and return the escaped character.

Otherwise, if the backslash is not in quoted string, the backslash is ignored and the character after is returned. If the backslash is in a quoted string, the backslash and the character after are both returned.

Source Code

;; Defined in /usr/src/emacs/lisp/eshell/esh-arg.el.gz
(defun eshell-parse-backslash ()
  "Parse a single backslash (\\) character and the character after.
If the character after the backslash is special, always ignore
the backslash and return the escaped character.

Otherwise, if the backslash is not in quoted string, the
backslash is ignored and the character after is returned.  If the
backslash is in a quoted string, the backslash and the character
after are both returned."
  (when (eq (char-after) ?\\)
    (when (eshell-looking-at-backslash-return (point))
	(throw 'eshell-incomplete ?\\))
    (forward-char 2) ; Move one char past the backslash.
    (if (eq (char-before) ?\n)
        ;; Escaped newlines are extra-special: they expand to an empty
        ;; token to allow for continuing Eshell commands across
        ;; multiple lines.
        'eshell-empty-token
      ;; If the char is in a quote, backslash only has special meaning
      ;; if it is escaping a special char.
      (if eshell-current-quoted
          (if (memq (char-before) eshell-special-chars-inside-quoting)
              (list 'eshell-escape-arg (char-to-string (char-before)))
            (concat "\\" (char-to-string (char-before))))
        (if (memq (char-before) eshell-special-chars-outside-quoting)
            (list 'eshell-escape-arg (char-to-string (char-before)))
          (char-to-string (char-before)))))))