Automate Emacs Lisp installation. (1) download Emacs Lisp (2) save to your repository (3) byte compile (4) load (5) show Emacs Lisp
M-x install-elisp M-x install-elisp-from-emacswiki For example, if you want to upgrade anything.el, you have only to issue: M-x install-elisp-from-emacswiki anything.el ;;; install-elisp.el --- Simple Emacs Lisp installer using curl ;; $Id: install-elisp.el,v 1.2 2007/07/24 10:44:31 rubikitch Exp $ ;; Copyright (C) 2007 rubikitch ;; Author: rubikitch <[EMAIL PROTECTED]> ;; Keywords: lisp, convenience, maint ;; URL: http://www.emacswiki.org/cgi-bin/wiki/download/install-elisp.el ;; This file is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by ;; the Free Software Foundation; either version 2, or (at your option) ;; any later version. ;; This file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. ;; You should have received a copy of the GNU General Public License ;; along with GNU Emacs; see the file COPYING. If not, write to ;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, ;; Boston, MA 02110-1301, USA. ;;; Commentary: ;; Automate Emacs Lisp installation. ;; (1) download Emacs Lisp ;; (2) save to your repository ;; (3) byte compile ;; (4) load ;; (5) show Emacs Lisp ;;; Installation: ;; To use this program, you must have curl, command-line HTTP client. ;; You need to add to .emacs: ;; (require 'install-elisp) ;; (setq install-elisp-repository-directory "~/emacs/lisp/") ;;; Usage: ;; M-x install-elisp ;; M-x install-elisp-from-emacswiki ;; ;; It is convenient to add to your Emacs Lisp programs: ;; (install-elisp "http://your.site/hogehoge.el") ;; because users have only to evaluate this sexp by C-x C-e. ;; If you want to complete EmacsWiki pagename, eval: ;; (install-elisp "http://www.emacswiki.org/cgi-bin/wiki/download/oddmuse.el") ;; It is very convenient to access EmacsWiki with oddmuse.el. ;;; Upgrade this program: ;; Simply eval: ;; (install-elisp-from-emacswiki "install-elisp.el") ;;; Related project: ;; Emacs Lisp Package Archive: http://tromey.com/elpa/ ;;; History: ;; $Log: install-elisp.el,v $ ;; Revision 1.2 2007/07/24 10:44:31 rubikitch ;; Fixed a serious bug. ;; New variable: install-elisp-use-view-mode ;; ;; Revision 1.1 2007/07/24 10:39:40 rubikitch ;; Initial revision ;; ;;; Code: (defvar install-elisp-repository-directory nil "Directory to save Emacs Lisp programs downloaded by install-elisp.el. You MUST set it in .emacs. Developer's note: The default is nil to prevent install-elisp from installing wrong place.") (defvar install-elisp-use-view-mode t "If non-nil, turn on `view-mode' for installed Emacs Lisp program.") (defun %install-elisp-create-buffer (url) (let ((buffer (generate-new-buffer " *install-elisp-tmp*"))) (shell-command (format "curl --silent '%s'" url) buffer) (switch-to-buffer buffer))) ;;;###autoload (defun install-elisp (url &optional filename) "Retrieve Emacs Lisp program from URL and save and byte-compile and load. If optional FILENAME is supplied, save URL as FILENAME, otherwise URL's basename." (interactive "sInstall Emacs Lisp from URL: ") (if (null install-elisp-repository-directory) (with-output-to-temp-buffer "*Help*" (princ "You must prepare to use install-elisp program! Set `install-elisp-repository-directory' to your local Emacs Lisp repository directory in your ~/.emacs. For example: (setq install-elisp-repository-directory \"~/emacs/lisp/\")")) (%install-elisp-create-buffer url) (write-file (expand-file-name (or filename (file-name-nondirectory url)) install-elisp-repository-directory)) (byte-compile-file buffer-file-name t) (and install-elisp-use-view-mode (view-mode 1)))) (defun %install-elisp-from (baseurl) "Return higher-order function installing from BASEURL, which accepts an argument FILENAME." `(lambda (filename) (install-elisp (concat ,baseurl filename) filename))) ;;;###autoload (defun install-elisp-from-emacswiki (filename) "Install Emacs Lisp program from the EmacsWiki." (interactive (list (if (fboundp 'oddmuse-read-pagename) (oddmuse-read-pagename "EmacsWiki") (read-string "PageName: ")))) (funcall (%install-elisp-from "http://www.emacswiki.org/cgi-bin/wiki/download/") filename)) (provide 'install-elisp) ;; How to save (DO NOT REMOVE!!) ;; (emacswiki-post "install-elisp.el") ;;; install-elisp.el ends here -- rubikitch http://www.rubyist.net/~rubikitch/ _______________________________________________ gnu-emacs-sources mailing list [email protected] http://lists.gnu.org/mailman/listinfo/gnu-emacs-sources
