emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Adding refactoring capabilities to Emacs


From: Eli Zaretskii
Subject: Re: Adding refactoring capabilities to Emacs
Date: Sat, 19 Aug 2023 14:18:00 +0300

> From: Eshel Yaron <me@eshelyaron.com>
> Cc: emacs-devel@gnu.org
> Date: Sat, 19 Aug 2023 12:58:00 +0200
> 
> My initial thinking is that it may be useful to consider two categories
> of refactoring operations:
> 
> 1. Common transformations that make sense in most languages.  These
> include renaming identifiers, reordering definitions/directives (such as
> import statements), extracting blocks of code as standalone functions
> and probably a few more.  IMO it'd be great if Emacs had standard
> commands and user options for these refactor operations across major
> modes.  For some languages, it might be difficult to provide some of
> these transformations even though they're clearly useful, so some major
> mode might want to indicate that they do not support some of these
> transformations.  For instance, renaming identifiers requires very
> precise knowledge of scoping and namespacing that might not be available
> to some major modes (at least not without a lot more work).
> 
> 2. Transformations that only make sense for a specific set of languages.
> For example, in Prolog we may want to move the unification of some term
> from the head of a clause to the start of its body.  That's a useful
> transformation that doesn't alter the program's semantics, but I can't
> think of a corresponding transformation in functional/imperative
> languages.  Perhaps for such operations Emacs could allow major modes to
> provide language-specific extensions to the refactoring facility.

Yes, there's a place for both language-independent and
language-dependent refactoring.  And I think more sub-categories are
in order, because some of them can be done with relatively simple
means which don't require intimate knowledge of the language syntax,
and others will require support from the likes of tree-sitter and LSP.

It would be good to start developing these capabilities, first for the
relatively simple transformations.  Patches are welcome.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]