7.25 Renaming Variables

You can rename a Prolog variable across the current top-term with the following command:

C-c C-r

Rename a variable across the topmost Prolog term at point (sweeprolog-rename-variable).

User Option: sweeprolog-rename-variable-allow-existing

If non-nil, allow selecting an existing variable name as the new name of a variable being renamed with sweeprolog-rename-variable. If it is the symbol confirm, allow but ask for confirmation first. Defaults to confirm.

The command sweeprolog-rename-variable, bound to C-c C-r, prompts for two variable names and replaces all occurrences of the first variable in the term at point with the second. The prompt for the first (old) variable name provides completion based on the existing variable names in the current term, and it uses the variable at point as its default.

The user option sweeprolog-rename-variable-allow-existing controls what happens if the second (new) variable name that you insert in the minibuffer already occurs in the current clause. By default it is set to confirm, which says to ask for confirmation before selecting an existing variable name as the new name. This is because renaming a variable to another existing variable name potentially alters the semantics of the term by merging the two variables. Other alternatives for this user option are t for allowing such merges without confirmation, and nil for refusing them altogether.

If Context Menu mode is enabled, you can also rename variables by right-clicking on them with the mouse and selecting ‘Rename Variable’ from the top of the context menu. See Context Menu, for more information about context menus in Sweep.