redguardtoo / elpa-mirror

Create local emacs package repository. 15 seconds to install 115 packages.
315 stars 55 forks source link

Setting default output directory #12

Closed agsdot closed 8 years ago

agsdot commented 8 years ago

Hi Chen Bin,

Thanks for all the great emacs packages you post on github.

Recently during the melpa outages, to get stuff up and running reliably, I installed elpa-mirror .

Now ideally, I'd like to set it up in my .emacs.d such that I can

  1. Have the default directory name be pre-selected.
  2. Have the elpamr-create-mirror-for-installed command be run once a day, probably at some certain time interval.

In my emacs.d, I have the following code set, but when I run elpamr-create-mirror-for-installed it does not default to ~/myelpa . I still have to indicate the directory at the prompt.

(require 'elpa-mirror) (setq elpamr-default-output-directory "~/myelpa")

Any ideas on what's going wrong?

P.s. If you have any idea on how to setup a "cron (type) job" in elisp for emacs to run that elpamr-create-mirror-for-installed once a day, say at noon or at 3pm, I'd greatly appreciate the advice.

redguardtoo commented 8 years ago

upgrade to v1.2.2, check README

agsdot commented 8 years ago

@redguardtoo , thanks for the rapid feedback.

setq elpamr-default-output-directory now works properly. I'm not sure what was happening before, prior to the changes you made -- it doesn't look like much was changed with regards to the code for that, just removal of html generating code.

With regards to the script to run elpa-mirror in the shell, I was thinking that this is a more likely scenario:

emacs --batch -l ~/.emacs.d/init.el -l ~/.emacs.d/elpa/elpa-mirror-*/elpa-mirror.el --eval='(setq elpamr-default-output-directory "~/myelpa")' --eval='(elpamr-create-mirror-for-installed)'

You referenced elpa-mirror.el as being inside ~/projs/elpa-mirror/ -- maybe this is your repo for where you develop the code? Most people would not have elpa-mirror.el within that directory.

Still I wonder, how could one code running the elpamr-create-mirror-for-installed command once a day in emacs, and not use a cron job or shell script? Thanks for your advice.

agsdot commented 8 years ago

@redguardtoo , I solved the whole timing issue with the following code.

(use-package elpa-mirror
  :ensure elpa-mirror
  :config
  (progn
    (setq dotemacs-backup-elpa-directory (concat user-emacs-directory ".backup-elpa/"))
    (setq elpamr-default-output-directory dotemacs-backup-elpa-directory)
    (run-at-time "15:00" 86400 'elpamr-create-mirror-for-installed)))

(use-package f
  :ensure f
  :config
  (progn
    (unless (f-exists? dotemacs-backup-elpa-directory)
      (f-mkdir dotemacs-backup-elpa-directory)
      (elpamr-create-mirror-for-installed))))

It works pretty well. I'll be closing this issue. Thanks for your help, and once again great package -- I sure hope it helps negate any issues if melpa is down again!