all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Dominic Martinez <dom@dominicm.dev>
To: "Sébastien Gendre" <seb@k-7.ch>,
	"GNU Emacs text editor" <help-gnu-emacs@gnu.org>
Subject: Re: Using Org-mode for literate Emacs configuration with use-package
Date: Sat, 13 Jul 2024 13:56:52 -0400	[thread overview]
Message-ID: <35710170-2886-475c-bce1-5885818352bc@dominicm.dev> (raw)
In-Reply-To: <87le2acq2f.fsf@k-7.ch>

On 7/9/24 3:39 PM, Sébastien Gendre wrote:
> I was thinking of writing Org-mode source block with different parts of
> my `(use-package)` call, so I can distribute it into different section of my
> Org-mode document. But in this case, I can no-longer evaluate my
> `(use-package)` call directly from my Org-mode document.
> 
> Do you have any suggestion ? How do you manage this problem ?

Yes, you can do this with noweb.

#+begin_src elisp :noweb-ref package-custom
(my-var1 "value")
(my-var2 "another-val")
#+end_src

#+begin_src elisp :noweb-ref package-custom
(even-more-vars "multiple-blocks")
#+end_src

#+begin_src elisp :noweb no-export :results none
(use-package my-package
   :custom
   <<package-custom>>)
#+end_src

Now use babel to evaluate the use-package source block (C-c C-c) and
noweb references will be inserted during evaluation.

Some explanation:
- The <<ref>> syntax inserts anything source blocks with the same
   :noweb-ref value.
- :noweb no-export says to insert noweb blocks on tangle or eval, but
   not on export (so your exports stay organized)
- :results none stops the evaluation output from being inserted into
   your Org file

Also see 16.11 Noweb Reference Syntax in the org manual.




  parent reply	other threads:[~2024-07-13 17:56 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-09 19:39 Using Org-mode for literate Emacs configuration with use-package Sébastien Gendre
2024-07-13 13:45 ` John Kitchin
2024-07-15 17:13   ` Sébastien Gendre
2024-07-13 14:36 ` Ihor Radchenko
2024-07-15 17:17   ` Sébastien Gendre
2024-07-15 17:32     ` Ihor Radchenko
2024-07-13 17:56 ` Dominic Martinez [this message]
2024-07-15 17:20   ` Sébastien Gendre
2024-07-15  9:37 ` Rens Oliemans
2024-07-15 17:20   ` Sébastien Gendre
2024-07-16  6:02 ` Björn Bidar
     [not found] <87le2acq2f.fsf__13832.1084481262$1720874764$gmane$org@k-7.ch>
2024-07-27  7:47 ` Dilip via General discussions about Org-mode.

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=35710170-2886-475c-bce1-5885818352bc@dominicm.dev \
    --to=dom@dominicm.dev \
    --cc=help-gnu-emacs@gnu.org \
    --cc=seb@k-7.ch \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.