Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watnot!watmath!clyde!rutgers!mit-eddie!PURDUE.EDU!ramsey From: ramsey@PURDUE.EDU.UUCP Newsgroups: comp.emacs Subject: concerning gnu emacs backup files (and other topics) Message-ID: <8704041832.AA17088@arthur.cs.purdue.edu> Date: Sat, 4-Apr-87 13:32:28 EST Article-I.D.: arthur.8704041832.AA17088 Posted: Sat Apr 4 13:32:28 1987 Date-Received: Sun, 5-Apr-87 12:56:15 EST Sender: nessus@eddie.MIT.EDU Lines: 244 Several months ago I started (unintentionally) a rather long discussion concerning gnu emacs backups. My intent was to discover a reliable way of placing all of my backup files into a single dedicated backup directory. This would allow me to use the gnu emacs backup capabilities, without running afoul of my systems administrator, who frowns on backup files in the systems directories (Dan, smile!). The most useful response to my query was from Neil Smithline, and it solved my problem (Thanks, Neil!). I am enclosing his code, and a few other items that might be useful: * simple file name completion for the shell * routines that save and restore the screen environment * a routine for mh-rmail that toggles in and out of mh-rmail by saving and restoring the screen environment, so that I can read mail at anytime, without having to re-build my screen when I exit mail. * keymap translation table routine to support xon/xoff This code runs under Mt. Xinu 4.3 NFS on Vaxen, and Sun 3.2 on Suns. I use Gnu Emacs Version 18.38.2. I haven't tried it on anything else. -Ed Ed Ramsey ramsey@cs.purdue.edu ARPA Computer Science Department ramsey%purdue.edu@relay.cs.net CSNET Purdue University {ucbvax,decvax,ihnp4}!purdue!ramsey UUCP West Lafayette, IN 47907 (317) 494-6002 PHONE ;; .emacs last modified: Sat Apr 4 11:39:21 EST 1987 ;; (to add comments :-) ;; ;; I use a wyse 60 at 19200 baud from an encore annex. The wyse 60 is ;; a mixed blessing. It allows 43 lines on the screen (which is a ;; real win), but is slow enough to require flow control above 4800 ;; baud. Hardware flow control doesn't work (at least for us) on the ;; annex, so I use xon/xoff (about which RMS has made many choice ;; comments :-). If encore ever make hardware flow control work, then ;; the xon/xoff can go away, and I can run at 38400! ;; ;; set up to work with xon/xoff flow control. ;; 1) enable xon/xoff (set-input-mode nil t) ;; 2) set up translate table to remap C-s and C-q (also C-h and DEL) (let ((the-table (make-string 128 0))) (let ((i 0)) (while (< i 128) (aset the-table i i) (setq i (1+ i)))) ;; Swap C-h with DEL (personal preference). This makes DEL the help key. ;; the next two lines can be commented out if you like to use DEL for delete (aset the-table ?\177 ?\^h) (aset the-table ?\^h ?\177) ;; Swap ^S with ^\ (aset the-table ?\^\\ ?\^s) (aset the-table ?\^s ?\^\\) ;; Swap ^Q with ^^ (aset the-table ?\^^ ?\^q) (aset the-table ?\^q ?\^^) (setq keyboard-translate-table the-table)) ;; ;; miscellaneous (setq inhibit-startup-message t) (setq text-mode-hook 'turn-on-auto-fill) (setq list-directory-verbose-switches "-Flag") (setq c-auto-newline t) (setq c-indent-level 4) (setq c-continued-statement-offset 4) (setq display-time-interval 10) (display-time) (defvar TeX-dvi-print-command "dvipr -r") ;; ;; keys (global-set-key "\C-x\C-e" 'compile) (global-set-key "\C-x\C-m" 'set-mark-command) (global-set-key "\eg" 'goto-line) (global-set-key "\C-xn" 'rnews) ;; ;; backups ;; ;; backup-by-copying is needed so that system files aren't changed to ;; be owned by me. (setq backup-by-copying t) ;; ;; From: Neil Gordon Smithline ;; Date: Tue, 20 Jan 87 14:41:16 EST ;; modified by ramsey@purdue.edu to fit my requirements :-) ;; this code causes *all* backups to be stored in my backup directory. The ;; advantage of this is that I have the security of backups, without leaving ;; backup files all over the system. ;; ;; ** this is the only line that needs to be changed ** (defvar backup-file-prefix "/usr/ramsey/.gnubackups/" "*Prefix to prepend to all backup filenames and auto-save filenames.") ;; (defun make-backup-file-name (file) "Create the non-numeric backup file name for FILE. This function differs from the standard version in that it includes the `backup-file-prefix'." (concat (file-name-directory file) backup-file-prefix (file-name-nondirectory file) "~")) ;; (defun make-auto-save-file-name () "Return file name to use for auto-saves of current buffer. Does not consider auto-save-visited-file-name; that is checked before calling this function. You can redefine this for customization. See also auto-save-file-name-p." (if buffer-file-name (concat (file-name-directory buffer-file-name) backup-file-prefix "#" (file-name-nondirectory buffer-file-name) "#") (expand-file-name (concat "#%" (buffer-name) "#")))) ;; (defun auto-save-file-name-p (filename) "Return t if FILENAME can be yielded by make-auto-save-file-name. FILENAME should lack slashes. You can redefine this for customization." (string-match (concat "^" backup-file-prefix "#.*#$") filename)) ;; (defun find-backup-file-name (fn) "Find a file name for a backup file, and suggestions for deletions. Value is a list whose car is the name for the backup file and whose cdr is a list of old versions to consider deleting now." (if (eq version-control 'never) (list (make-backup-file-name fn)) (let* ((base-versions (file-name-nondirectory (make-backup-file-name fn))) (bv-length (length base-versions)) (possibilities (file-name-all-completions base-versions (file-name-directory fn))) (versions (sort (mapcar 'backup-extract-version possibilities) '<)) (high-water-mark (apply 'max (cons 0 versions))) (deserve-versions-p (or version-control (> high-water-mark 0))) (number-to-delete (- (length versions) kept-old-versions kept-new-versions -1))) (if (not deserve-versions-p) (list (make-backup-file-name fn)) (cons (concat (make-backup-file-name fn) (int-to-string (1+ high-water-mark)) "~") (if (> number-to-delete 0) (mapcar (function (lambda (n) (concat (make-backup-file-name fn) (int-to-string n) "~"))) (let ((v (nthcdr kept-old-versions versions))) (rplacd (nthcdr (1- number-to-delete) v) ()) v)))))))) ;; ;; set up a shell (shell) ;; rename it now (so I don't have to rename it later if I want two shells) (rename-buffer "sh1") ;; (regexp must have changed because "popd|po" doesn't work anymore) (defvar shell-popd-regexp "po") (defvar shell-pushd-regexp "pu") ;; ;; set up file name completion (not bsd, but useful and simple) ;; (I don't remember the name of the person who sent this to me) (define-key shell-mode-map "\C-c\C-f" 'insert-file-name-with-completion) (defun insert-file-name-with-completion (name) "Prompts for a file or directory name and inserts that name after point. The name may be non-existent. Useful in Shell mode." (interactive "FInsert file name: ") (insert name)) ;; ;; date function (useful for logging times in job notes, etc ...) (defun current-date-and-time () "Insert the current date and time (as given by UNIX date) at dot." (interactive) (call-process "date" nil t nil)) (global-set-key "\C-xt" 'current-date-and-time) ;; ;; functions to save/restore current screen environment ;; *real* useful if you have 40 to 80 line screens with a lot of windows ;; and you want to jump into a package (like mh) that doesn't save your ;; current layout. One of these days (:-) I will implement ring buffers. (setq screen-saved nil) (defun screen-config-save () "Save the current screen configuration." (interactive) (setq screen-config (current-window-configuration)) (message "Current Screen Configuration Saved") (setq screen-saved t)) ;; (defun screen-config-restore () "Restore the screen configuration last saved." (interactive) (message "Last Saved Screen Configuration Restored") (if (eq screen-saved 't) (set-window-configuration screen-config) (message "Unable to Restore Screen Configuration")) (setq screen-saved nil)) ;; (global-set-key "\C-cS" 'screen-config-save) (global-set-key "\C-cR" 'screen-config-restore) ;; ;; mh mail (setq mh-summary-height 5) (setq mh-ins-buf-prefix " >> ") ;; screen save/restore tied to mh-rmail ;; I set this up so that C-x m toggled the mh environment. the first C-x m ;; saves the current configuration and drops you into mh-rmail. The second ;; C-x m restores the last saved state of the screen. A sentinel of ;; some kind is needed, because if you try to restore before you save, ;; gnu emacs dumps core, and trashes your shell! (setq screen-saved-mh nil) (defun screen-config-save-mh () "Save the current screen configuration." (interactive) (setq screen-config-mh (current-window-configuration)) (setq screen-saved-mh t)) ;; (defun screen-config-restore-mh () "Restore the screen configuration last saved." (interactive) (if (eq screen-saved-mh 't) (set-window-configuration screen-config-mh)) (setq screen-saved-mh nil)) ;; (global-set-key "\C-xm" 'mh-frontend-rmail) (defun mh-frontend-rmail () "Save screen and go to mh." (interactive) (screen-config-save-mh) (global-set-key "\C-xm" 'mh-exit-rmail) (mh-rmail)) ;; (defun mh-exit-rmail () "restore screen and exit mh." (interactive) (screen-config-restore-mh) (global-set-key "\C-xm" 'mh-frontend-rmail)) ;; ;; ;; end