Function: insert-image-file
insert-image-file is an autoloaded and byte-compiled function defined
in image-file.el.gz.
Signature
(insert-image-file FILE &optional VISIT BEG END REPLACE)
Documentation
Insert the image file FILE into the current buffer.
Optional arguments VISIT, BEG, END, and REPLACE are interpreted
as for the command insert-file-contents. Return list of
absolute file name and number of characters inserted.
Source Code
;; Defined in /usr/src/emacs/lisp/image-file.el.gz
;;;###autoload
(defun insert-image-file (file &optional visit beg end replace)
"Insert the image file FILE into the current buffer.
Optional arguments VISIT, BEG, END, and REPLACE are interpreted
as for the command `insert-file-contents'. Return list of
absolute file name and number of characters inserted."
(let ((rval
(image-file-call-underlying #'insert-file-contents-literally
'insert-file-contents
file visit beg end replace)))
;; Turn the image data into a real image, but only if the whole file
;; was inserted
(when (and (or (null beg) (zerop beg)) (null end))
(let* ((ibeg (point))
(iend (+ (point) (cadr rval)))
(visitingp (and visit (= ibeg (point-min)) (= iend (point-max))))
(image (create-image (encode-coding-region ibeg iend 'binary t)
nil t))
(props
`(display ,image
yank-handler
(image-file-yank-handler nil t)
intangible ,image
rear-nonsticky (display intangible)
;; This a cheap attempt to make the whole buffer
;; read-only when we're visiting the file (as
;; opposed to just inserting it).
,@(and visitingp
'(read-only t front-sticky (read-only))))))
(add-text-properties ibeg iend props)
(when visitingp
;; Inhibit the cursor when the buffer contains only an image,
;; because cursors look very strange on top of images.
(setq cursor-type nil)
;; This just makes the arrow displayed in the right fringe
;; area look correct when the image is wider than the window.
(setq truncate-lines t))))
rval))