代码之家  ›  专栏  ›  技术社区  ›  Flinkman

如何更改Emacs自动恢复文件的名称?

  •  2
  • Flinkman  · 技术社区  · 17 年前

    此时,它以以下格式保存文件:

    .#main.c -> sara@sara.home.com.27017:1231918415
    

    更新:我有Emacs22.1

    3 回复  |  直到 15 年前
        1
  •  8
  •   Community Mohan Dere    6 年前

    这不是自动恢复文件,而是用作文件锁定标记的链接。

    更新

    如果我告诉你,你能介绍我认识夏格吗?

    要改变这一点可能并不容易;我只是挖了一点,看起来它是在C代码中设置的。但让我们问下一个问题:你为什么想?我猜你在为 .c 不想与这些文件匹配的文件。如果是这样,请注意,所有这些锁文件链接都以 .#

    如果你真的想破解它,可以在filelock.c中emacs22的第320行。代码如下:

    /* 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++);
        }
    }
    
        2
  •  2
  •   namnor    13 年前

    您可以升级到emacs 24.3并在.emacs文件中添加以下行:

    (setq create-lockfiles nil)
    
        3
  •  0
  •   Andrew Grant    17 年前

    很奇怪,默认值的每一端都应该有#。。

    您可以通过重新定义auto-save-file-name-p和使auto-save file name函数自定义名称。在gnuemacs中,您可以将elisp添加到.emacs文件中。