tags:

views:

126

answers:

2

At the moment it saves the file with format:

.#main.c -> [email protected]:1231918415

This makes it problematic since it ends with ".c".

I need it to be .#main.c#

Update: I have emacs 22.1

+1  A: 

That's strange, the default should have # at each end..

You can customize the name by redefining the auto-save-file-name-p and make-auto-save-file-name functions. In GNU emacs you would add the elisp to your .emacs file.

Andrew Grant
my system is not using (make-auto-save-file-name), when I run that. It produce the right name.
Flinkman
+3  A: 

That's not the auto-recovery file, that's the link used as a locking token for the file.

update

If I tell you, will you introduce me to Summer Glau?

It's probably not going to be easy to change that; I just dug a bit and it looks like it's set in the C code. But let's ask the next question: why do you want to? I'm guessing you're hitting a regular expression for .c files that you don't want to match these. If so, note that all these lockfile links start with .# -- invariably, that's hardcoded -- so you could always exclude files with names that match "^.#" (depending on which regex syntax you use.)

If you really want to hack at it, it's in filelock.c at about line 320 in EMACS 22. Here's the code:

/* Write the name of the lock file for FN into LFNAME.  Length will be
   that of FN plus two more for the leading `.#' plus 1 for the
   trailing period plus one for the digit after it plus one for the
   null.  */
#define MAKE_LOCK_NAME(lock, file) \
  (lock = (char *) alloca (SBYTES (file) + 2 + 1 + 1 + 1), \
   fill_in_lock_file_name (lock, (file)))

static void
fill_in_lock_file_name (lockfile, fn)
     register char *lockfile;
     register Lisp_Object fn;
{
  register char *p;
  struct stat st;
  int count = 0;

  strcpy (lockfile, SDATA (fn));

  /* Shift the nondirectory part of the file name (including the null)
     right two characters.  Here is one of the places where we'd have to
     do something to support 14-character-max file names.  */
  for (p = lockfile + strlen (lockfile); p != lockfile && *p != '/'; p--)
    p[2] = *p;

  /* Insert the `.#'.  */
  p[1] = '.';
  p[2] = '#';

  p = p + strlen (p);

  while (lstat (lockfile, &st) == 0 && !S_ISLNK (st.st_mode))
    {
      if (count > 9)
    {
      *p = '\0';
      return;
    }
      sprintf (p, ".%d", count++);
    }
}
Charlie Martin
Thanks. How do I change the name?
Flinkman
You hack the code to append a '#', making sure that the buffer has room. You also make sure that the corresponding part of code that checks the lockfile understands your new file name format.
Jouni K. Seppänen
And you make sure to keep track of the change, and re-apply it to every future version of EMACS.
Charlie Martin