[ESS] Function template

Stephen Eglen S.J.Eglen at damtp.cam.ac.uk
Tue Jan 22 22:55:29 CET 2013

> I've had this issue when in a directory that has an src
> directory that came across from a machine where I had
> a different username (johnm1, was john).  The old files in
> the src subdirectory then have names like johnm.locatefun.R
> where it should now be johnm1.locatefun.R.  There may be
> some easy way to fix all the file names from within an ess
> session -- if so I am eyes open!

For your specific problem, the easiest way I would change the filenames
in one src folder would be to use a newish feature of dired (i.e. part
of Emacs, not just ESS):

M-x dired RET /path/to/src

C-x C-q     dired-toggle-read-only

Now, the dired buffer text can be edited, including the filenames.  So
now you can do

M-x query-replace RET john RET johnm1 RET

and then hit C-c C-c to update the filenames...

Here's the relevant part of emacs.info

30.17 Editing the Dired Buffer

Wdired is a special mode that allows you to perform file operations by
editing the Dired buffer directly (the "W" in "Wdired" stands for
"writable".)  To enter Wdired mode, type `C-x C-q'
(`dired-toggle-read-only') while in a Dired buffer.  Alternatively, use
the `Immediate / Edit File Names' menu item.

   While in Wdired mode, you can rename files by editing the file names
displayed in the Dired buffer.  All the ordinary Emacs editing
commands, including rectangle operations and `query-replace', are
available for this.  Once you are done editing, type `C-c C-c'
(`wdired-finish-edit').  This applies your changes and switches back to
ordinary Dired mode.

   Apart from simply renaming files, you can move a file to another
directory by typing in the new file name (either absolute or relative).
To mark a file for deletion, delete the entire file name.  To change
the target of a symbolic link, edit the link target name which appears
next to the link name.

   The rest of the text in the buffer, such as the file sizes and
modification dates, is marked read-only, so you can't edit it.
However, if you set `wdired-allow-to-change-permissions' to `t', you
can edit the file permissions.  For example, you can change
`-rw-r--r--' to `-rw-rw-rw-' to make a file world-writable.  These
changes also take effect when you type `C-c C-c'.

More information about the ESS-help mailing list