Skip to main content
if changed to when
Source Link

I have not found any existing solution to do that and come up with my own:

;; Inspired by https://www.emacswiki.org/emacs/BookmarkPlus#BulkDownloadCompileLoad 
(defun fetch-and-load-elisp (pkg-name pkg-files base-url base-dir)
  (let ((pkg-dir (concat (file-name-as-directory base-dir) (symbol-name pkg-name))))
    (require 'url)
    (add-to-list 'load-path pkg-dir)
    (make-directory pkg-dir t)
    (mapcar (lambda (arg)
              (let ((local-file (concat (file-name-as-directory pkg-dir) arg)))
                (unless (file-exists-p local-file)
                  (url-copy-file (concat base-url arg) local-file t))))
            pkg-files)
    (byte-recompile-directory pkg-dir 0)
    (require pkg-name)))

(ifwhen (fetch-and-load-elisp 'zoom-frm '("frame-cmds.el" "frame-fns.el" "zoom-frm.el") "https://www.emacswiki.org/emacs/download/" "~/lisp/")
      (define-key ctl-x-map [(control ?+)] 'zoom-in/out)
      (define-key ctl-x-map [(control ?-)] 'zoom-in/out)
      (define-key ctl-x-map [(control ?=)] 'zoom-in/out)
      (define-key ctl-x-map [(control ?0)] 'zoom-in/out))

I am not proficient in ELISP, and perhaps it could be improved. Error handling comes to mind. Also, the byte compilation is now run every time, even when files were unchanged.

I have not found any existing solution to do that and come up with my own:

;; Inspired by https://www.emacswiki.org/emacs/BookmarkPlus#BulkDownloadCompileLoad 
(defun fetch-and-load-elisp (pkg-name pkg-files base-url base-dir)
  (let ((pkg-dir (concat (file-name-as-directory base-dir) (symbol-name pkg-name))))
    (require 'url)
    (add-to-list 'load-path pkg-dir)
    (make-directory pkg-dir t)
    (mapcar (lambda (arg)
              (let ((local-file (concat (file-name-as-directory pkg-dir) arg)))
                (unless (file-exists-p local-file)
                  (url-copy-file (concat base-url arg) local-file t))))
            pkg-files)
    (byte-recompile-directory pkg-dir 0)
    (require pkg-name)))

(if (fetch-and-load-elisp 'zoom-frm '("frame-cmds.el" "frame-fns.el" "zoom-frm.el") "https://www.emacswiki.org/emacs/download/" "~/lisp/")
      (define-key ctl-x-map [(control ?+)] 'zoom-in/out)
      (define-key ctl-x-map [(control ?-)] 'zoom-in/out)
      (define-key ctl-x-map [(control ?=)] 'zoom-in/out)
      (define-key ctl-x-map [(control ?0)] 'zoom-in/out))

I am not proficient in ELISP, and perhaps it could be improved. Error handling comes to mind. Also, the byte compilation is now run every time, even when files were unchanged.

I have not found any existing solution to do that and come up with my own:

;; Inspired by https://www.emacswiki.org/emacs/BookmarkPlus#BulkDownloadCompileLoad 
(defun fetch-and-load-elisp (pkg-name pkg-files base-url base-dir)
  (let ((pkg-dir (concat (file-name-as-directory base-dir) (symbol-name pkg-name))))
    (require 'url)
    (add-to-list 'load-path pkg-dir)
    (make-directory pkg-dir t)
    (mapcar (lambda (arg)
              (let ((local-file (concat (file-name-as-directory pkg-dir) arg)))
                (unless (file-exists-p local-file)
                  (url-copy-file (concat base-url arg) local-file t))))
            pkg-files)
    (byte-recompile-directory pkg-dir 0)
    (require pkg-name)))

(when (fetch-and-load-elisp 'zoom-frm '("frame-cmds.el" "frame-fns.el" "zoom-frm.el") "https://www.emacswiki.org/emacs/download/" "~/lisp/")
      (define-key ctl-x-map [(control ?+)] 'zoom-in/out)
      (define-key ctl-x-map [(control ?-)] 'zoom-in/out)
      (define-key ctl-x-map [(control ?=)] 'zoom-in/out)
      (define-key ctl-x-map [(control ?0)] 'zoom-in/out))

I am not proficient in ELISP, and perhaps it could be improved. Error handling comes to mind. Also, the byte compilation is now run every time, even when files were unchanged.

Source Link

I have not found any existing solution to do that and come up with my own:

;; Inspired by https://www.emacswiki.org/emacs/BookmarkPlus#BulkDownloadCompileLoad 
(defun fetch-and-load-elisp (pkg-name pkg-files base-url base-dir)
  (let ((pkg-dir (concat (file-name-as-directory base-dir) (symbol-name pkg-name))))
    (require 'url)
    (add-to-list 'load-path pkg-dir)
    (make-directory pkg-dir t)
    (mapcar (lambda (arg)
              (let ((local-file (concat (file-name-as-directory pkg-dir) arg)))
                (unless (file-exists-p local-file)
                  (url-copy-file (concat base-url arg) local-file t))))
            pkg-files)
    (byte-recompile-directory pkg-dir 0)
    (require pkg-name)))

(if (fetch-and-load-elisp 'zoom-frm '("frame-cmds.el" "frame-fns.el" "zoom-frm.el") "https://www.emacswiki.org/emacs/download/" "~/lisp/")
      (define-key ctl-x-map [(control ?+)] 'zoom-in/out)
      (define-key ctl-x-map [(control ?-)] 'zoom-in/out)
      (define-key ctl-x-map [(control ?=)] 'zoom-in/out)
      (define-key ctl-x-map [(control ?0)] 'zoom-in/out))

I am not proficient in ELISP, and perhaps it could be improved. Error handling comes to mind. Also, the byte compilation is now run every time, even when files were unchanged.