aleix's blog

Install Emacs packages from command line

8 January 2013 4:33 pm (emacs)

Lately, I have found myself playing with packages and my .emacs too much. Sometimes I had to comment the use of a package (e.g. smex) because it was not installed.

So, at the end, I wrote this basic elisp to install a package from the command line.

$ emacs --batch --expr "(define pkg-to-install 'smex)" -l emacs-pkg-install.el

The elisp script looks like this:

;;
;; Install package from command line. Example:
;;
;;   $ emacs --batch --expr "(define pkg-to-install 'smex)" -l emacs-pkg-install.el
;;

(require 'package)

(add-to-list 'package-archives
             '("melpa" . "http://melpa.milkbox.net/packages/") t)

(add-to-list 'package-archives
             '("marmalade" . "http://marmalade-repo.org/packages/") t)

;; Fix HTTP1/1.1 problems
(setq url-http-attempt-keepalives nil)

(package-refresh-contents)

(package-install pkg-to-install)

For convenience, you can wrap it in a shell script and simply type:

$ ./emacs-pkg-install.sh smex

The shell script:

#!/bin/sh

if [ $# -ne 1 ]
then
  echo "Usage: `basename $0` <package>"
  exit 1
fi

emacs --batch --eval "(defconst pkg-to-install '$1)" -l emacs-pkg-install.el

67 responses

  1. George Jones says:

    Thanks for the code.

    I had do

    (package-initialize)

    after

    (require 'package).

    Also had to explicitly call

    emacs-snapshot

    in the .sh script ... maybe it was pulling an older version?

    Thanks,
    ---George Jones

  2. Alejandro says:

    Thanks for the code.
    Great scripts man!
    =D

  3. Assignment Service by Buyassignment.com says:

    Command Prompt agenda permit you to employment in a circumstances that look more like a conservative working structure instead of the symbol.

  4. StephenScott says:

    They are the most confided in the business. The journalists are upbeat to help and they can compose on any given subject. One need not stress over the cost as the costs are extremely reasonable. The essayists make unique work buy coursework online and they convey on time.

  5. Coursework Writing Service says:

    Emacs incorporates an office that lets you effortlessly download and introduce bundles that execute extra highlights. Each bundle is a different Emacs Lisp program, now and then including different parts, for example, an Info manual.

  6. StephenScott says:
  7. vpn torrent says:

    thankyou for uploading this sitevpn torrent

  8. scienzappeal says:

    This is very basic programming tips that you give in this lesson. Students who new in this field ca understand easily.I am waiting for expert level programming.

  9. Bingwear says:

    This was a great and interesting article to read Nike Air Max Zero QS Men's Shoes Black / Grey 789695 001 . I have really enjoyed all of this very cool information

  10. Tyfanati says:

    The leading assignment help UK firm offers state of the art services to its clients with a promise of delivering all the required work well within the Zapatillas Adidas EQT Support ADV Unisexo Negro / Azul claro BA8338

  11. Bingwear says:

    This is great information for students. This article is very helpful i really like this Air Jordan 6 Retro Unisex Scarpe Bianca / Blu thanks. I also have some information relevant for online dissertation help.

  12. Sopfanati says:

    This is great information for students. This article is very helpful i really like this Nike Air Huarache Run Ultra Unisex Sko Sort 819685 002 thanks. I also have some information relevant for online dissertation help.

  13. Electronics Engineering Assignment Help says:

    This is great information for students. This article is very helpful i really like this blog thanks. I also have some information relevant for online dissertation help.

  14. Bingwear says:

    The Kvinner Air Jordan 7 Retro Hyper Rosa Joggesko Svart 442960-018 which you people are given are really good, These look really great.

  15. Online MYOB Accounting Homework Help says:

    Things are very open and intensely clear explanation of issues. was truly information. Your website is very beneficial.

  16. Psychology Project Help says:

    Pretty helpful material, much thanks for this article

  17. write my thesis ireland says:

    Thanks for this great website.. i appreciate your working style. i have bookmarked this website

  18. hotmail says:

    thanks.

  19. Java Homework Help says:

    Get the dissertation writing service students look for these days with the prime focus being creating a well researched and lively content on any topic.

  20. write my essay for me cheap says:

    Hey, ever since I stumbled upon your comic on ‘Invictus’ i have been hooked. I simply love them and hope to follow your example. Since I have been drawing caricatures and doodles all my life, I am starting to realize that life is too short and a deskbound boring career is not something I would want at the expense of my creative side. So I am starting to learn how to convert my pen sketches into digital art, do you have any suggestions?

  21. Do My DBM Project says:

    Hi buddy, your blog' s design is simple and clean and i like it. Your blog posts about Online writing Help are superb. Please keep them coming. Greets!

  22. Financial Management australia homework help says:

    Science Channel’s are giving a complete knowledge to its viewers about every thing students write done dissertation on this subjects and show its importance.

  23. Botany Medical Thesis Writing Service says:

    Things are very open and intensely clear explanation of issues. was truly information. Your website is very beneficial.

  24. Oncology Doctorate Essay Writing Service says:

    This is great information for students. This article is very helpful i really like this blog thanks. I also have some information relevant for online dissertation help.

  25. Make My Python Programming Project For Me says:

    I loved the way you discuss the topic great work thanks for the share Your informative post.

  26. Sex Positions says:

    I was very pleased to find this site.I wanted to thank you for this great read!! I definitely enjoying every little bit of it and I have you bookmarked to check out new stuff you post. Sex Positions

  27. Oolong Tea says:

    I have bookmarked your website because this site contains valuable information in it. I am really happy with articles quality and presentation. Thanks a lot for keeping great stuff. I am very much thankful for this site. Oolong Tea

  28. Banana says:

    I read your post and I found it amazing! thank! Banana

  29. Cranberries says:

    I don t have the time at the moment to fully read your site but I have bookmarked it and also add your RSS feeds. I will be back in a day or two. thanks for a great site. Cranberries

  30. Chromium says:

    Thank you very much for sharing such a useful article. Will definitely saved and revisit your site Chromium

  31. Blueberries says:

    Really nice and interesting post. I was looking for this kind of information and enjoyed reading this one. Blueberries

  32. Strawberry says:

    Actually I read it yesterday but I had some thoughts about it and today I wanted to read it again because it is very well written. Strawberry

  33. Chives says:

    I’ve been searching for some decent stuff on the subject and haven't had any luck up until this point, You just got a new biggest fan!.. Chives

  34. Lentils says:

    The writer is enthusiastic about purchasing wooden furniture on the web and his exploration about best wooden furniture has brought about the arrangement of this article. Lentils

  35. moe gotta know says:

    moe gotta know
    Thank you for your work on the blog! You're doing a good job!

  36. Look this says:

    I love to read on these topics!

  37. Social media: The New Hybrid Element of the Promotion Mix Case Study Help says:

    Thanx for sharing such useful post keep it up :)

  38. Index Design Assignment Help | DatabaseHelpOnline.xyz says:

    Things are very open and intensely clear explanation of issues. was truly information. Your website is very beneficial.

  39. Assignment Help says:

    When you must switch to the World Wide Web to search for some Assignment help. Our high expert's professionals who have extensive experience in writing assignment will not only make you avail with the quality assignment, but you will also get plagiarism free assignment within the given time.

  40. All Assignment help review says:

    A superior all assignment Help review offered by this website
    with the advantage of online support with high proficiency level based on its latest research and information by professional reviews writers. Wide ranges of subjects are covered with separate writers for each subject.

  41. hotmail live login says:

    Pretty helpful material, much thanks for this article

  42. MBA Assignment Writing Service says:

    nice

  43. fnaf says:

    nice

  44. Kaleerein says:

    This is very Amazing and Very Informative Artical we get alot of Informations from this artical we really appreciate your team work.

  45. Assignment Help says:

    For education purpose you can look forward to the Assignment help Online.Our assignment experts works hard to live up to the expectations and provide total peace of mind.Assignment Help is into assignment writing service sector and helps pupils in completing their academic tasks. Students can use our service for the same purpose.

  46. Yeh Hai Mohabbatein Episode says:

    What a perfect work. You are a great writer I read your article carefuly the article is full of quality material. I was looking article like these. Today I got my favourite blog that is related to articles that I was looking. Thanks for sharing with us

  47. All Assignment help review says:

    A superior all assignment Help review offered by this website with the advantage of online support with high proficiency level based on its latest research and information by professional reviews writers. Wide ranges of
    subjects are covered with separate writers for each subject.

  48. Do My Civil Engineering Projects says:

    My Friend Recommended This Blog And He Was Totally Right Keep Up The Fantastic Work!

  49. Academic Paper Writing says:

    this is one of the most relevant post I have ever seen hope to see some thing similar coming up to me like these here thou.

  50. Online Audit Homework Help says:

    I Loved The Way You Discuss The Topic Great Work Thanks For The Share Your Informative Post.

  51. SPSS Assignment Help says:

    Great Information,It Has Lot For Stuff Which Is Informative.I Will Share The Post With My Friends.

  52. Assignment Help says:

    If you are searching Assignment help.Our experts write high quality assignment.Our professionals have been working on Networking assignments, IT plans, Enterprise software presentations and much more.

  53. AllAssignmentHelp.com reviews says:

    We Provide assignment help for students especially in usa getting brilliant quality reviews writing USA, essays and dissertations.We at Top Quality Assignment believe that there is no shortcut to success and to attain success, hard work, dedication, and commitment must be present.Allassignmenthelp reviews best in writing unique Assignment.

  54. Topcelebsjackets says:

    Extraordinary work and I'm a tremendous aficionado of your sites and ceaselessly observing all the article in your online journals. It transformed into marvelous cool submit and I have never been unmistakable in no way, shape or form in my reality.

  55. Menstruation cramps says:

    Excellent work very well optimised your information.

  56. Treatment for white spots on teeth says:

    Good work, I become a huge fan for your blog. The hard work, efforts you keep on your work makes the effortless success for you. I appreciate this blog and info which is really useful.

  57. Natural Home Remedies for Ringworm says:

    Landing on this blog feels that definitely, we may gain some info which is really useful for us, thanks for sharing with us.

  58. Perdita di peso rapidamente says:

    This post is valuable. It describes step by step how to install emacs packages from command line. It has helped me a lot to accomplish my work quickly.

  59. sephora gift card balance says:

    Our product catalog at Sephora is inclusive of diverse product brands under the categories of make-up, skincare fragrance, and hair-care

  60. One Punch Man Season 2 says:

    great work

  61. Bareburger says:

    The poster of the company is a bear on a unicycle, holding a beer and a burger. This is at the very start of their business but now “BareBurger Menu” is serving their sustainable fare all over the world. If “BareBurger Menu” has some new updates do tell us and all the readers of this website.Bareburger

  62. lisa says:

    One Punch Man Season 2 but still there is no confirm news from the studio. The producers have not even announced the release date of the new season. The fans got excited by the news of One Punch Man being removed from hiatus
    Our product catalog at Sephora is inclusive of diverse product brands under the categories of make-up, skincare fragrance, and hair-caresephora gift card balance

  63. Programming Assignment Help says:

    Hello I am michael, SEO Expert in complete my assignment services. There is one information, it is very useful to you or biggeners.Are your looking for someone to write your programming assignment, here are expert assignment helpers of Programming Assignment Help are well efficient and capable of creating unique assignments for college or university students all across the globe.

  64. street view says:

    I read your entire article and I genuinely like it.Thank you for discussing this great post.

  65. Dianabol says:

    Dianabol was one of the first steroids. It is very popular between bodybuilders and athletes thanks to its long-lasting results. It is legal in some countries. But in some pothers it but requires a prescription. Now you can buy a legal alternative of dianabol. It is called d-bal. It promotes fast muscle gains, maximizes strength and stamina.

  66. happy wheels says:

    Chill with me: geometry dash

  67. Bay Leves says:

    Bay leaves are commonly found in biryani, pulao, soups, curries and most Indian dishes.
    The presence of vitamin A and C along with folic acid and various minerals in bay leaf makes it a nutrient-dense herb.

Leave a Reply