0

My entire Emacs configuration is in one file named "init.el". The folding and unfolding is achieved with the outshine package.

I would like to share my config with some of my colleagues and I would like to provide them the ability to disable certain features such as elfeed, emms, etc..

Because I do not use a split (multiple) file approach, I'm not able to just comment out a (require 'emms) line.

I was thinking in having a variable defined at the beginning of the file which they can set to nil or t. Even though my method works (the one you see in the image below) I'm not sure if wrapping the use-package blocks inside a conditional is the right way to do it.

use-package comes with a :disabled option but that only disables one package. For someone who is not skilled with Emacs and requiring him to add all those :disabled keywords manually for each package is not optimal.

I would be grateful for any suggestion.

enter image description here

4
  • An admirable goal, but are you unnecessarily creating more work for yourself? Why not disable the packages in question with :disabled and teach them the basic movement commands and C-k/kill-line?
    – nega
    Mar 20 at 17:14
  • Maybe I don't even want to have the packages installed. Just adding :disabled to the packages still installs them. What is the wrong in using a flag and a conditional in disabling a whole group of packages? Isn't it easier to use a conditional than writing :disabled for 100 programming related packages which someone who writes in Org doesn't need?
    – Zoli
    Mar 20 at 20:12
  • :ensure nil will not cause a package to be installed. there's also the variable use-package-always-ensure. i wouldn't write :disabled for a hundred packages. i'd use a keyboard macro or sed
    – nega
    Mar 22 at 20:43
  • Also, the approach in my answer does not install packages when you comment out the sections. Because you did not comment on my solution (but only on my choice of implementation using org), I would like to emphasize that the approach should also work for you (without org and tangling). Commenting out a heading in org has the same effect as commenting out a section with outshine. I hope that was sufficiently clear... Mar 22 at 21:16

1 Answer 1

0

I am not sure how things worked on Emacs version < 29. But I have a very similar literal config file, where I am slowly trying to 'create' a 'lightweight' Spacemacs alternative (or more a Spacemacs complementary for easy debugging/testing. Only tested on Emacs 30 b.t.w., but I am almost sure it should work just fine also on Emacs 29).

You can find it here.

The file currently is not for public use (otherwise you probably have to comment out some sections). But anyway, I can explain how it works.

So, when tangling the org-file, whole sections can be excluded by commenting out the relevant sections, as explained in under the 'Usage info' section.

The first line of the file makes sure that the file gets tangled on save automatically.

Then, the first thing I do is to define a use function that installs a package if not installed yet, and then activates it.

For it to work correctly, I have the line:

(setq package-enable-at-startup nil)

in my early-init.el file.

Subsequently, I can include packages by just adding a

(use 'package-name)

to any of the code blocks.

Finally, I can provide all layers which I have placed under the section modules (it's not real layers, but it is a somewhat similar concept) in a single org file, and users can (de)activate it by (un)commenting some relevant section.

Of course, this has advantages and disadvantages compared to the real Spacemacs config. The main advanatage is that I can easily 'deactivate' layers, without them (and all their packages) getting uninstalled. And also, of course, there are no 'hidden/mystery' configurations inside the org/el file(s) (which makes it a good start for debugging/development).

P.S. Personally, I think I like this design better than the heavily preconfigured Doom/Spacemacs distributions. But I must add that I am a very lightweight user. If I would like to use a fully configured IDE, I might still head for Spacemacs (or maybe not... I am still exploring. In the end, this might become a community configured init (template) file, or it might not. Let's see where it goes...).

5
  • The thing is that I'm not using Org mode. I have an init.el file with the same folding and unfolding capabilities as Org mode thanks to the outshine package. I just moved away from the literate Org config and I like this format better. So I do not use org-babel and I have no way to control what is tangled or not. For me, everything is in one single Lisp file. reddit.com/r/emacs/comments/gfiadj/comment/fptwbu5/…
    – Zoli
    Mar 20 at 17:50
  • Yes I see, I prefer the literate file because a section can be commented out by commenting out a single line. Also, it can nicely be exported to different file formats (or rendered by e.g. github). But anyway, the essence is the line in early-init.el, i.c.w. the use function (that combines conditional package install, and package acivate). If you quickly want to 'disable' packages by commenting out lines, then I guess you should somehow use the 'package-activate' as I don't know another easy mechanism for it. Of course, this mechanism you can use also in the .el file. Mar 20 at 19:17
  • But of course, your colleagues could also use the use-package 'disable' line, to exclude configuration of individual packages. Indeed, I am trying to get a more 'layer' like behavior with the '.org' file. Mar 20 at 19:24
  • outshine also provides an easy way to comment out sections and the pretty looking GitHub file is exactly what I don't care about. Org mode just adds an unnecessary layer of abstraction to the whole config process.
    – Zoli
    Mar 20 at 20:09
  • That's nice, of course. Indeed, outshine looks good too... as I mentioned in my answer, our approaches look very similar. So anyway, I hope the part of the answer about how to disable packages by simply commenting out sections was useful... Mar 20 at 21:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.