Function: package-install-file

package-install-file is an autoloaded, interactive and byte-compiled function defined in package.el.gz.

Signature

(package-install-file FILE)

Documentation

Install a package from FILE.

The file can either be a tar file, an Emacs Lisp file, or a directory.

View in manual

Probably introduced at or before Emacs version 25.1.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/emacs-lisp/package.el.gz
;;;###autoload
(defun package-install-file (file)
  "Install a package from FILE.
The file can either be a tar file, an Emacs Lisp file, or a
directory."
  (interactive "fPackage file name: ")
  (with-temp-buffer
    (if (file-directory-p file)
        (progn
          (setq default-directory file)
          (dired-mode))
      (insert-file-contents-literally file)
      (set-visited-file-name file t)
      (set-buffer-modified-p nil)
      (when (string-match "\\.tar\\'" file) (tar-mode)))
    (unwind-protect
        (with-silent-modifications
          ;; When installing .tar files, `package-tar-file-info' touches
          ;; the modified bit which causes Emacs to query the user if
          ;; they are certain about killing this temporary buffer, since
          ;; it is marked as visiting FILE.  This of course is OK, since
          ;; this is not the actual visiting file, so we want to prevent
          ;; the modified bit from triggering this query.
          (package-install-from-buffer))
      (fundamental-mode))))             ; free auxiliary data