Function: python-info-encoding-from-cookie
python-info-encoding-from-cookie is a byte-compiled function defined
in python.el.gz.
Signature
(python-info-encoding-from-cookie)
Documentation
Detect current buffer's encoding from its coding cookie.
Returns the encoding as a symbol.
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/python.el.gz
(defun python-info-encoding-from-cookie ()
"Detect current buffer's encoding from its coding cookie.
Returns the encoding as a symbol."
(let ((first-two-lines
(save-excursion
(save-restriction
(widen)
(goto-char (point-min))
(forward-line 2)
(buffer-substring-no-properties
(point)
(point-min))))))
(when (string-match (python-rx coding-cookie) first-two-lines)
(intern (match-string-no-properties 1 first-two-lines)))))