home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / languages / elisp / packages / hiddn-bak.el < prev    next >
Encoding:
Text File  |  1990-07-22  |  2.6 KB  |  67 lines

  1. ;From ark1!nems!mimsy!haven!purdue!tut.cis.ohio-state.edu!rutgers!aramis.rutgers.edu!topaz.rutgers.edu!busboys.rutgers.edu!gaynor Thu Nov  9 14:02:36 1989
  2. ;Article 743 of comp.emacs
  3. ;Path: ark1!nems!mimsy!haven!purdue!tut.cis.ohio-state.edu!rutgers!aramis.rutgers.edu!topaz.rutgers.edu!busboys.rutgers.edu!gaynor
  4. ;>From gaynor@busboys.rutgers.edu (Silver)
  5. ;Newsgroups: comp.emacs
  6. ;Subject: Re: Changing location of autosave file
  7. ;Message-ID: <Nov.8.02.30.11.1989.329@busboys.rutgers.edu>
  8. ;Date: 8 Nov 89 07:30:14 GMT
  9. ;References: <11520004@hpsmtc1.HP.COM>
  10. ;Organization: Rutgers Univ., New Brunswick, N.J.
  11. ;Lines: 52
  12. ;
  13. ;I'm not all that annoyed with the network filesystem speeds, but rather with
  14. ;the visual clutter of the extra filenames.  I wrote the following piece of code
  15. ;to autosave and backup into hidden filenames.
  16. ;
  17. ;Regards, [Ag] gaynor@topaz.rutgers.edu
  18. ;
  19. ;------------------------------- hidden-files.el -------------------------------
  20. (provide 'hidden-files)
  21.  
  22. ;;;;;;;;;; backup
  23. ;;
  24. ;; Use ".bak." to prefix backup filenames.
  25.  
  26. (defun file-name-sans-versions (path)
  27. "Return FILENAME sans backup versions or strings.  This is a seperate procedure
  28. so your site-init or startup file can redefine it."
  29.   (let ((name (file-name-nondirectory path)))
  30.     (concat (or (file-name-directory path) "")
  31.         (substring name (if (string-match "\\`\\.bak\\." name) 5 0)))))
  32.  
  33. (defun make-backup-file-name (path)
  34. "Create the non-numeric backup file name for FILE.  This is a seperate function
  35. so you can redefine it for customization."
  36.   (concat (or (file-name-directory path) "")
  37.       ".bak."
  38.       (file-name-nondirectory path)))
  39.  
  40. (defun backup-file-name-p (path)
  41. "Return non-nil if FILE is a backup file name (numeric or not).  This is a
  42. separate function so you can redefine it for customization.  You may need to
  43. redefine file-name-sans-versions as well."
  44.   (string-match "\\`\\.bak\\." (file-name-nondirectory path)))
  45.  
  46.  
  47.  
  48. ;;;;;;;;;; auto-save
  49. ;;
  50. ;; Use ".ckp." to prefix auto-save filenames.
  51.  
  52. (defun make-auto-save-file-name ()
  53. "Return file name to use for auto-saves of current buffer.  Does not consider
  54. auto-save-visited-file-name; that is checked before calling this function.  You
  55. can redefine this for customization.  See also auto-save-file-name-p."
  56.   (if (buffer-file-name)
  57.     (concat (or (file-name-directory (buffer-file-name)) "")
  58.         ".ckp."
  59.         (file-name-nondirectory (buffer-file-name)))))
  60.  
  61. (defun auto-save-file-name-p (filename)
  62. "Return t if FILENAME can be yielded by make-auto-save-file-name.  FILENAME
  63. should lack slashes.  You can redefine this for customization."
  64.   (string-match "\\`\\.ckp\\." filename))
  65.  
  66.  
  67.