emacs noob here.

I’m rewriting my init.el file from scratch using use-package macro. In my existing init file I use require to configure MELPA package archive.

(require 'package)

(add-to-list 'package-archives '("MELPA" . "http://melpa.org/packages/"))

(package-initialize)

Can I rewrite this using use-package macro?

  • thetemp_@alien.topB
    link
    fedilink
    English
    arrow-up
    1
    ·
    1 year ago

    You can use the `setopt’ macro, which is also new in Emacs 29.1.

    (setopt package-archives
            '(("gnu" . "https://elpa.gnu.org/packages/")
              ("nongnu" . "https://elpa.nongnu.org/nongnu/")
              ("melpa" . "https://melpa.org/packages/")))
    
  • mekeor@alien.topB
    link
    fedilink
    English
    arrow-up
    1
    ·
    1 year ago

    I don’t use use-package myself, but maybe you could write:

    (use-package package
      :init
      (add-to-list 'package-archives '("MELPA" . "http://melpa.org/packages/")))
    

    I’d expect it to understand that you are referring to package.el, where package-archives variable is defined.