* Org-mode+Babel: Refactor across files or code blocks
@ 2024-10-22 19:05 Pablo Padilla
2024-10-28 22:30 ` Rudolf Adamkovič
0 siblings, 1 reply; 2+ messages in thread
From: Pablo Padilla @ 2024-10-22 19:05 UTC (permalink / raw)
To: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 1810 bytes --]
Hi there, I have started to write some of my dotfiles using org-mode and I have regularly felt the need to refactor certain parts of my configuration. At the moment I mostly perform refactoring using find and replace but would like to have more robust support to refactor across distinct Babel blocks or across files.
A more detailed example follows:
I'm refactoring my Emacs config files so that they are generated with [org-babel-tangle][1]. I am able to do everything I need but I really miss better refactoring support.
As an example, after I define a symbol (variable, function), there maybe a lot of unrelated code and prose before the next usage:
> Some explanation about `a` and `x`:
> ```elisp
> (defun a ...)
> (defvar x ...)
> ```
> Another paragraph ...
> ```elisp
> ((((more))))(((lisp)))()()((((code)))
> ```
> Using `a` or `x`:
> ```elisp
> (doSomething (a) ...)
> (crashSystem x ...)
> ```
To rename a symbol, I enter [edit mode (`C-c '`)][2], and there is some limited refactoring support, e.g., rename symbol, extract variable, etc. However, changes to a symbol across all Babel blocks or across files is not supported.
My workflow today is to use `helm-projectile-ag` to find usages in the project (git repo) and then apply the required changes to each, one by one, by hand.
I have been googling for refactoring support across blocks/files so far with little success. I have posted this question to gather some pointers, references to Emacs packages that can improve my refactoring workflow or maybe help me rethink my workflow.
[1]: https://orgmode.org/manual/Extracting-Source-Code.html
[2]: https://orgmode.org/manual/Editing-Source-Code.html
Originally posted in https://emacs.stackexchange.com/q/80858/11978
Regards,
—
Pablo
[-- Attachment #2: Type: text/html, Size: 2685 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Org-mode+Babel: Refactor across files or code blocks
2024-10-22 19:05 Org-mode+Babel: Refactor across files or code blocks Pablo Padilla
@ 2024-10-28 22:30 ` Rudolf Adamkovič
0 siblings, 0 replies; 2+ messages in thread
From: Rudolf Adamkovič @ 2024-10-28 22:30 UTC (permalink / raw)
To: Pablo Padilla, emacs-orgmode
Pablo Padilla <pgpb.padilla@gmail.com> writes:
> However, changes to a symbol across all Babel blocks or across files
> is not supported.
One simple way that works is to use tangle and detangle functionality.
However, tangling comments are noisy and detangling is unreliable, in
that it can erase your data.
I have recently opened a thread about it:
https://list.orgmode.org/m27ca1cgly.fsf@adamkovic.org/
Once that is fixed, and it is a relatively simple and localized problem,
the situation will improve greatly!
Rudy
--
"All of humanity's problems stem from man's inability to sit quietly in
a room alone." --- Blaise Pascal, Pensées, 1670
Rudolf Adamkovič <rudolf@adamkovic.org> [he/him]
http://adamkovic.org
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-10-28 22:31 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-22 19:05 Org-mode+Babel: Refactor across files or code blocks Pablo Padilla
2024-10-28 22:30 ` Rudolf Adamkovič
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).