* .emacs help
@ 2002-09-10 14:49 exmixllxer
2002-09-10 14:54 ` exmixllxer
0 siblings, 1 reply; 8+ messages in thread
From: exmixllxer @ 2002-09-10 14:49 UTC (permalink / raw)
When I set the bkup-backup-directory-info variable
via xemacs regular emacs barfs on it. Not sure why,
but it seems that xemacs refers to this variable but
emacs refers to the backup-directory-alist variable.
This is the error I get:
File error: "Cannot open load file", "backup-dir"
.emacs from xemacs customization:
(custom-set-variables
'(bkup-backup-directory-info (quote (("." "~emiller/emacs_bkup" ok-create))) nil (backup-dir)))
.emacs from emacs customization:
(custom-set-variables
'(backup-directory-alist (quote (("." . "~emiller/emacs_bkup")))))
% emacs --version
GNU Emacs 21.1.1
% xemacs --version
XEmacs 21.1 (patch 12)
Can anyone help me get both emacs and xemacs to backup
files to the same directory?
Thanks,
Eric
--
--------------------
exmixllxer@xattxbi.com
Remove the X's to reply
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: .emacs help
2002-09-10 14:49 .emacs help exmixllxer
@ 2002-09-10 14:54 ` exmixllxer
2002-09-11 1:25 ` Miles Bader
0 siblings, 1 reply; 8+ messages in thread
From: exmixllxer @ 2002-09-10 14:54 UTC (permalink / raw)
exmixllxer@xattxbi.com wrote:
> When I set the bkup-backup-directory-info variable
> via xemacs regular emacs barfs on it. Not sure why,
> but it seems that xemacs refers to this variable but
> emacs refers to the backup-directory-alist variable.
> This is the error I get:
> File error: "Cannot open load file", "backup-dir"
> .emacs from xemacs customization:
> (custom-set-variables
> '(bkup-backup-directory-info (quote (("." "~emiller/emacs_bkup" ok-create))) nil (backup-dir)))
Ugh, I think the parens are unbalanced. Odd since this came
right out of xemacs!
E
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: .emacs help
2002-09-10 14:54 ` exmixllxer
@ 2002-09-11 1:25 ` Miles Bader
0 siblings, 0 replies; 8+ messages in thread
From: Miles Bader @ 2002-09-11 1:25 UTC (permalink / raw)
Cc: bug-gnu-emacs
exmixllxer@xattxbi.com writes:
> > This is the error I get:
>
> > File error: "Cannot open load file", "backup-dir"
>
> > .emacs from xemacs customization:
> > (custom-set-variables
> > '(bkup-backup-directory-info (quote (("." "~emiller/emacs_bkup" ok-create))) nil (backup-dir)))
>
> Ugh, I think the parens are unbalanced. Odd since this came
> right out of xemacs!
No, the parens seem fine. The problem is that the `(backup-dir)' part
of the customization entry does what you might expect: it tells emacs
that the `backup-dir' feature is required before defining that variable,
and emacs will try to load `backup-dir.el' to define it.
Since `backup-dir.el' is an xemacs-only thing, it of course fails.
This is for bug-gnu-emacs:
It would be nice if emacs just ignored customization entries that result
in an error (I often ran into the same problem when trying to use older
versions of emacs with my emacs21 .emacs file).
-Miles
--
I'd rather be consing.
^ permalink raw reply [flat|nested] 8+ messages in thread
* RE: .emacs help
@ 2002-09-11 16:19 Rehm, Keith
2002-09-12 1:16 ` Miles Bader
0 siblings, 1 reply; 8+ messages in thread
From: Rehm, Keith @ 2002-09-11 16:19 UTC (permalink / raw)
Cc: bug-gnu-emacs
[-- Attachment #1: Type: text/plain, Size: 1666 bytes --]
Hi,
I am using GNU Emacs and use backup-dir seemingly.
I have:
(require 'backup-dir)
(if (boundp 'bkup-backup-directory-info)
(setq bkup-backup-directory-info '((t "c:/documents and
settings/keithr/desktop/emacsBackups/"
ok-create
full-path))))
in my .emacs and am using the backup-dir.el I have attached.
(?)
Keith
-----Original Message-----
From: Miles Bader [mailto:miles@lsi.nec.co.jp]
Sent: Tuesday, September 10, 2002 8:26 PM
To: help-gnu-emacs@gnu.org
Cc: bug-gnu-emacs@gnu.org
Subject: Re: .emacs help
exmixllxer@xattxbi.com writes:
> > This is the error I get:
>
> > File error: "Cannot open load file", "backup-dir"
>
> > .emacs from xemacs customization:
> > (custom-set-variables
> > '(bkup-backup-directory-info (quote (("." "~emiller/emacs_bkup"
ok-create))) nil (backup-dir)))
>
> Ugh, I think the parens are unbalanced. Odd since this came
> right out of xemacs!
No, the parens seem fine. The problem is that the `(backup-dir)' part
of the customization entry does what you might expect: it tells emacs
that the `backup-dir' feature is required before defining that variable,
and emacs will try to load `backup-dir.el' to define it.
Since `backup-dir.el' is an xemacs-only thing, it of course fails.
This is for bug-gnu-emacs:
It would be nice if emacs just ignored customization entries that result
in an error (I often ran into the same problem when trying to use older
versions of emacs with my emacs21 .emacs file).
-Miles
--
I'd rather be consing.
_______________________________________________
Help-gnu-emacs mailing list
Help-gnu-emacs@gnu.org
http://mail.gnu.org/mailman/listinfo/help-gnu-emacs
[-- Attachment #2: backup-dir.el --]
[-- Type: application/octet-stream, Size: 23845 bytes --]
;;; backup-dir.el --- allow backup files to live in some other directory(s).
;;; Author: Greg Klanderman <greg.klanderman@alum.mit.edu>
;;; Version: 2.9
;;; Date: January 8, 1999
;;; Created: Spring 1992
;;; Keywords: backup file
;;; Copyright (C) 1992-98 Greg Klanderman
;;;
;;; This program is free software; you can redistribute it and/or modify
;;; it under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 2, or (at your option)
;;; any later version.
;;;
;;; This program is distributed in the hope that it will be useful,
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;;; GNU General Public License for more details.
;;;
;;; A copy of the GNU General Public License can be obtained from the
;;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;;; Boston, MA 02111-1307, USA.
;;;
;;; Send bug reports, feedback, etc. to greg.klanderman@alum.mit.edu,
;;; greg@alphatech.com, or gregk@ai.mit.edu.
;;; Commentary:
;;;
;;; Allows backup files to be optionally stored in some directories, based on
;;; the value of the alist, `bkup-backup-directory-info'. This variable is a
;;; list of lists of the form (FILE-REGEXP BACKUP-DIR OPTIONS ...). If the
;;; filename to be backed up matches FILE-REGEXP, or FILE-REGEXP is t, then
;;; BACKUP-DIR is used as the path for its backups. Directories may begin
;;; with "/" to specify an absolute pathname.
;;;
;;; If BACKUP-DIR does not exist and OPTIONS contains the symbol `ok-create',
;;; then it is created if possible. Otherwise the usual behavior (backup in
;;; the same directory as the file) results.
;;;
;;; If OPTIONS contains the symbol `full-path', then the full path of the file
;;; being backed up is prepended to the backup file name, with each "/"
;;; replaced by a "!". This is intended for cases where an absolute backup
;;; path is used. If OPTIONS contains `prepend-name' in addition to
;;; `full-path', then the file name is prepended rather than appended to the
;;; path component when forming the backup name.
;;;
;;; If OPTIONS contains the symbol `search-upward' and the backup directory
;;; BACKUP-DIR is a relative path, then a directory with that name is searched
;;; for starting at the current directory and proceeding upward (.., ../..,
;;; etc) until one is found of that name or the root is reached, and if one is
;;; found it is used as the backup directory.
;;;
;;; Finally, if no FILE-REGEXP matches the file name being backed up, then the
;;; usual behavior results.
;;;
;;; These lines from my .emacs load this file and set the values I like:
;;;
;;; (require 'backup-dir)
;;; (setq bkup-backup-directory-info
;;; '(("/home/greg/.*" "/~/.backups/" ok-create full-path prepend-name)
;;; ("^/[^/:]+:" ".backups/") ; handle EFS files specially: don't
;;; ("^/[^/:]+:" "./") ; search-upward... its very slow
;;; (t ".backups/"
;;; full-path prepend-name search-upward)))
;;;
;;;
;;; The package also provides a new function, `find-file-latest-backup' to
;;; find the latest backup file for the current buffer's file.
;;;
;;; This package is based on `files.el' from XEmacs 20.3 and overrides
;;; functions defined there. The overridden functions are clearly
;;; marked below and the originals precede the new definitions in
;;; commented form.
;;;
;;; The package is known to work in the latest XEmacs betas. It has
;;; not been extensively tested on GNU Emacs past 18.58, though I have
;;; reports of it working through 20.2. It does not work under ms-dos.
;;; Change Log:
;;;
;;; January 8, 1999 Version 2.9
;;; * Fix bkup-search-upward-for-backup-dir,
;;; bkup-replace-slashes-with-exclamations, and
;;; bkup-backup-directory-and-basename for NT.
;;;
;;; November 13, 1998 Version 2.8
;;; * Reformat to fit within 80 columns.
;;; * Reformat ChangeLog section.
;;;
;;; June 10, 1998 Version 2.7
;;; * Add optional N argument to file-newest-backup and
;;; find-file-latest-backup.
;;;
;;; March 23, 1998 Version 2.6
;;; * Have to quote the eval-after-load form.
;;;
;;; February 22, 1998 Version 2.5
;;; * Fix infinite loop in bkup-search-upward-for-backup-dir due to a
;;; change in expand-file-name. Fix to not rely on expand-file-name.
;;;
;;; February 22, 1998 Version 2.4
;;; * Add a new option: prepend-name, suggested by Dave Bakhash.
;;;
;;; February 2, 1998 Version 2.3
;;; * Nuke byte-compiler-options.
;;; * Use eval-when-compile defvars to avoid compiler warnings.
;;; * Remove unused binding of non-num-bk-name from find-backup-file-name.
;;;
;;; October 27, 1997 Version 2.2
;;; * Update to adhere to lisp-mnt.el standards.
;;; * Don't require diff; instead use eval-after-load to patch
;;; diff-latest-backup-file (patch from Steve Baur).
;;;
;;; October 27, 1997 Version 2.1
;;; * Updated to support GNU Emacs 20.2. The function
;;; `backup-extract-version' now uses the free variable
;;; `backup-extract-version-start' rather than `bv-length'.
;;; Note, we continue to support older GNU Emacs and XEmacs
;;; by binding both names.
;;;
;;; October 22, 1997
;;; * Customization by Karl M. Hegbloom <karlheg@inetarena.com>
;;;
;;; December 28, 1996 Version 2.0
;;; * Updated for XEmacs 19.15b4, much of code reorganized & cleaned up
;;;
;;; December 27, 1996 Version 1.6
;;; * Explicit loading of dired replaced to use dired-load-hook
;;; (suggested by Thomas Feuster, feuster@tp4.physik.uni-giessen.de)
;;;
;;; December 2, 1996 Version 1.5
;;; * Took out obsolete byte compiler options
;;;
;;; September 24, 1996 Version 1.4
;;; * Various bugfixes.
;;; * Change to OPTIONS alist list (ok-create, full-path..) from
;;; separate fields for each option variable.
;;; * Added search-upward option.
;;; * Added new function `find-file-latest-backup' to find a file's
;;; latest backup.
;;;
;;; January 26, 1996 Version 1.3
;;; * Name change to backup-dir.el
;;;
;;; March 22, 1995 Version 1.2
;;; * Added new definitions for functions `file-newest-backup',
;;; `latest-backup-file', and `diff-latest-backup-file' so various other
;;; emacs functions will find the right backup files.
;;;
;;; April 23, 1993 Version 1.1
;;; * Reworked to allow different behavior for different files based on the
;;; alist `bkup-backup-directory-info'.
;;;
;;; Fall 1992 Version 1.0
;;; * Name change
;;; * Added ability to make directories absolute.
;;; * Added the full path stuff to make backup name unique for
;;; absolute directories.
;;;
;;; Spring 1992 Version 0.0
;;; * The original.
;;; Code:
(eval-when-compile
;; avoid compiler warnings: these are dynamically bound by
;; find-backup-file-name and used by backup extract-versions.
(defvar backup-extract-version-start) ; GNU Emacs 20.2
(defvar bv-length) ; XEmacs, older GNU Emacs
;; this is defined for msdos only
(unless (fboundp 'msdos-long-file-names)
(defun msdos-long-file-names () nil)))
;;; New variables affecting backup file behavior
;;; This is the only user-customizable variable for this package.
;;;
(defcustom bkup-backup-directory-info nil
"*Alist of (FILE-REGEXP BACKUP-DIR OPTIONS ...))
If the filename to be backed up matches FILE-REGEXP, or FILE-REGEXP is t,
then BACKUP-DIR is used as the path for its backups.
Directories may begin with \"/\" to specify an absolute pathname.
If BACKUP-DIR does not exist and OPTIONS contains the symbol `ok-create',
then it is created if possible. Otherwise the usual behavior (backup in the
same directory as the file) results.
If OPTIONS contains the symbol `full-path', then the full path of the file
being backed up is prepended to the backup file name, with each \"/\"
replaced by a \"!\". This is intended for cases where an absolute backup
path is used. If OPTIONS contains `prepend-name' in addition to `full-path',
then the file name is prepended rather than appended to the path component
when forming the backup name.
If OPTIONS contains the symbol `search-upward' and the backup directory
BACKUP-DIR is a relative path, then a directory with that name is searched
for starting at the current directory and proceeding upward (.., ../.., etc)
until one is found of that name, or the root is reached, and if one is found
it is used as the backup directory.
Finally, if no FILE-REGEXP matches the file name being backed up, then the
usual behavior results.
Once you save this variable with `M-x customize-variable',
`backup-dir' will be loaded for you each time you start XEmacs."
:type '(repeat
(list (regexp :tag "File regexp")
(string :tag "Backup Dir")
(set :inline t
(const ok-create)
(const full-path)
(const prepend-name)
(const search-upward))))
:require 'backup-dir
:group 'backup)
;;; New functions
;;;
(defun bkup-search-upward-for-backup-dir (base bd-name)
"Search upward for a directory named BD-NAME, starting in the
directory BASE and continuing with its parent directories until
one is found or the root is reached."
(let ((prev nil) (curr base) (gotit nil) (tryit nil))
(while (and (not gotit)
(not (equal curr prev))
(not (equal prev "/")))
(setq tryit (expand-file-name bd-name curr))
(if (and (file-directory-p tryit)
(file-exists-p tryit))
(setq gotit tryit)
(setq prev curr
curr (file-name-directory (directory-file-name curr)))))
(if (and gotit
(eq (aref gotit (1- (length gotit))) ?/))
(setq gotit (substring gotit 0 (1- (length gotit)))))
gotit))
(defun bkup-replace-slashes-with-exclamations (s)
"Replaces slashes in the string S with exclamations.
A new string is produced and returned."
(let ((ns (copy-sequence s))
(i (1- (length s)))
(mswin (eq system-type 'windows-nt))
(c nil))
(while (>= i 0)
(setq c (aref ns i))
(if (or (= c ?/)
(and mswin
(or (= c ?:) (= c ?\\))))
(aset ns i ?!))
(setq i (1- i)))
ns))
(defun bkup-try-making-directory (dir)
"Try making directory DIR, return non-nil if successful"
(condition-case ()
(progn (make-directory dir t)
t)
(t
nil)))
(defun bkup-backup-basename (file options)
"Gives the base part of the backup name for FILE, according to OPTIONS."
(if (memq 'full-path options)
(if (memq 'prepend-name options)
(concat (file-name-nondirectory file)
"!!"
(bkup-replace-slashes-with-exclamations
(file-name-directory file)))
(bkup-replace-slashes-with-exclamations file))
(file-name-nondirectory file)))
(defun bkup-backup-directory-and-basename (file)
"Return the cons of the backup directory name
and backup file name base for FILE."
(let ((file (expand-file-name file)))
(let ((dir (file-name-directory file))
(alist bkup-backup-directory-info)
(bk-dir nil)
(bk-base nil))
(if (listp alist)
(while (and (not bk-dir) alist)
(if (or (eq (car (car alist)) t)
(eq (string-match (car (car alist)) file) 0))
(let* ((bd (car (cdr (car alist))))
(bd-rel-p (not (file-name-absolute-p bd)))
(bd-expn (expand-file-name bd dir))
(bd-noslash (directory-file-name bd-expn))
(options (cdr (cdr (car alist))))
(ok-create (and (memq 'ok-create options) t))
(search-upward (and (memq 'search-upward options) t)))
(if bd-expn
(cond ((or (file-directory-p bd-expn)
(and ok-create
(not (file-exists-p bd-expn))
(bkup-try-making-directory bd-noslash)))
(setq bk-dir (file-name-as-directory bd-noslash)
bk-base (bkup-backup-basename file
options)))
((and bd-rel-p search-upward)
(let ((bd-up (bkup-search-upward-for-backup-dir
dir bd)))
(if bd-up
(setq bk-dir (file-name-as-directory bd-up)
bk-base (bkup-backup-basename
file options)))))))))
(setq alist (cdr alist))))
(if (and bk-dir bk-base)
(cons bk-dir bk-base)
(cons dir (bkup-backup-basename file nil))))))
;;; This next one is based on the following from `files.el'
;;; but accepts a second optional argument
;;(defun make-backup-file-name (file)
;; "Create the non-numeric backup file name for FILE.
;;This is a separate function so you can redefine it for customization."
;; (if (and (eq system-type 'ms-dos)
;; (not (msdos-long-file-names)))
;; (let ((fn (file-name-nondirectory file)))
;; (concat (file-name-directory file)
;; (if (string-match "\\([^.]*\\)\\(\\..*\\)?" fn)
;; (substring fn 0 (match-end 1)))
;; ".bak"))
;; (concat file "~")))
(defun bkup-make-backup-file-name (file &optional dir-n-base)
"Create the non-numeric backup file name for FILE.
Optionally accept a list containing the backup directory and
backup basename. NB: we don't really handle ms-dos."
(if (and (eq system-type 'ms-dos)
(not (and (fboundp 'msdos-long-file-names)
(msdos-long-file-names))))
(let ((fn (file-name-nondirectory file)))
(concat (file-name-directory file)
(if (string-match "\\([^.]*\\)\\(\\..*\\)?" fn)
(substring fn 0 (match-end 1)))
".bak"))
(let ((d-n-b (or dir-n-base
(bkup-backup-directory-and-basename file))))
(concat (car d-n-b) (cdr d-n-b) "~"))))
(defun bkup-existing-backup-files (fn)
"Return list of existing backup files for file"
(let* ((efn (expand-file-name fn))
(dir-n-base (bkup-backup-directory-and-basename efn))
(non-num-bk-name (bkup-make-backup-file-name efn dir-n-base))
(non-num-bk (file-exists-p non-num-bk-name))
(backup-dir (car dir-n-base))
(base-versions (concat (cdr dir-n-base) ".~"))
(possibilities (file-name-all-completions base-versions backup-dir))
(poss (mapcar #'(lambda (name) (concat backup-dir name))
possibilities)))
(mapcar #'expand-file-name
(if non-num-bk (cons non-num-bk-name poss) poss))))
(defun find-file-latest-backup (file &optional n)
"Find the latest backup file for FILE, or the Nth most recent
if optional second argument N is specified. Interactively, N
is specified with the prefix argument."
(interactive
(list
(read-file-name
(format "Find %slatest backup of file (default %s): "
(let* ((arg (prefix-numeric-value
current-prefix-arg))
(mod (% arg 10)))
(if (and (integerp arg) (> arg 1))
(format "%d%s "
arg
(cond ((= 1 mod) "st")
((= 2 mod) "nd")
((= 3 mod) "rd")
(t "th")))
""))
(file-name-nondirectory (buffer-file-name)))
nil (buffer-file-name) t)
(prefix-numeric-value current-prefix-arg)))
(let ((backup (file-newest-backup file n)))
(if backup
(find-file backup)
(message "no %s found for `%s'"
(if (> n 1) "such backup" "backups") file))))
;;; Functions changed from `files.el' and elsewhere -- originals
;;; precede new versions
;;(defun make-backup-file-name (file)
;; "Create the non-numeric backup file name for FILE.
;;This is a separate function so you can redefine it for customization."
;; (if (and (eq system-type 'ms-dos)
;; (not (msdos-long-file-names)))
;; (let ((fn (file-name-nondirectory file)))
;; (concat (file-name-directory file)
;; (if (string-match "\\([^.]*\\)\\(\\..*\\)?" fn)
;; (substring fn 0 (match-end 1)))
;; ".bak"))
;; (concat file "~")))
(defun make-backup-file-name (file)
"Create the non-numeric backup file name for FILE.
This is a separate function so you can redefine it for customization.
*** Changed by \"backup-dir.el\""
(bkup-make-backup-file-name file))
;;(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 the value is nil, don't make a backup."
;; (let ((handler (find-file-name-handler fn 'find-backup-file-name)))
;; ;; Run a handler for this function so that ange-ftp can refuse to do it.
;; (if handler
;; (funcall handler 'find-backup-file-name fn)
;; (if (eq version-control 'never)
;; (list (make-backup-file-name fn))
;; (let* ((base-versions (concat (file-name-nondirectory fn) ".~"))
;; ;; used by backup-extract-version:
;; (bv-length (length base-versions))
;; possibilities
;; (versions nil)
;; (high-water-mark 0)
;; (deserve-versions-p nil)
;; (number-to-delete 0))
;; (condition-case ()
;; (setq possibilities (file-name-all-completions
;; base-versions
;; (file-name-directory fn))
;; versions (sort (mapcar
;; #'backup-extract-version
;; possibilities)
;; '<)
;; high-water-mark (apply #'max 0 versions)
;; deserve-versions-p (or version-control
;; (> high-water-mark 0))
;; number-to-delete (- (length versions)
;; kept-old-versions kept-new-versions -1))
;; (file-error
;; (setq possibilities nil)))
;; (if (not deserve-versions-p)
;; (list (make-backup-file-name fn))
;; (cons (concat fn ".~" (int-to-string (1+ high-water-mark)) "~")
;; (if (and (> number-to-delete 0)
;; ;; Delete nothing if there is overflow
;; ;; in the number of versions to keep.
;; (>= (+ kept-new-versions kept-old-versions -1) 0))
;; (mapcar #'(lambda (n)
;; (concat fn ".~" (int-to-string n) "~"))
;; (let ((v (nthcdr kept-old-versions versions)))
;; (rplacd (nthcdr (1- number-to-delete) v) ())
;; v))))))))))
(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 the value is nil, don't make a backup.
*** Changed by \"backup-dir.el\""
(let ((handler (find-file-name-handler fn 'find-backup-file-name)))
;; Run a handler for this function so that ange-ftp can refuse to do it.
(if handler
(funcall handler 'find-backup-file-name fn)
(if (eq version-control 'never)
(list (make-backup-file-name fn))
(let* ((dir-n-base (bkup-backup-directory-and-basename fn)) ;add
(bk-dir (car dir-n-base)) ;add
(bk-base (cdr dir-n-base)) ;add
(base-versions (concat bk-base ".~")) ;mod
;; used by backup-extract-version:
(bv-length (length base-versions)) ;; older GNU and XEmacs
(backup-extract-version-start
(length base-versions)) ;; new GNU Emacs (20.2)
possibilities
(versions nil)
(high-water-mark 0)
(deserve-versions-p nil)
(number-to-delete 0))
(condition-case ()
(setq possibilities (file-name-all-completions
base-versions
bk-dir) ;mod
versions (sort (mapcar
#'backup-extract-version
possibilities)
'<)
high-water-mark (apply #'max 0 versions)
deserve-versions-p (or version-control
(> high-water-mark 0))
number-to-delete (- (length versions)
kept-old-versions
kept-new-versions -1))
(file-error
(setq possibilities nil)))
(if (not deserve-versions-p)
(list (bkup-make-backup-file-name fn dir-n-base)) ;mod
(cons (concat bk-dir base-versions
(int-to-string (1+ high-water-mark)) "~") ;mod
(if (and (> number-to-delete 0)
;; Delete nothing if there is overflow
;; in the number of versions to keep.
(>= (+ kept-new-versions kept-old-versions -1) 0))
(mapcar #'(lambda (n)
(concat bk-dir base-versions
(int-to-string n) "~")) ;mod
(let ((v (nthcdr kept-old-versions versions)))
(rplacd (nthcdr (1- number-to-delete) v) ())
v))))))))))
;;(defun file-newest-backup (filename)
;; "Return most recent backup file for FILENAME or nil if no backups exist."
;; (let* ((filename (expand-file-name filename))
;; (file (file-name-nondirectory filename))
;; (dir (file-name-directory filename))
;; (comp (file-name-all-completions file dir))
;; newest tem)
;; (while comp
;; (setq tem (car comp)
;; comp (cdr comp))
;; (cond ((and (backup-file-name-p tem)
;; (string= (file-name-sans-versions tem) file))
;; (setq tem (concat dir tem))
;; (if (or (null newest)
;; (file-newer-than-file-p tem newest))
;; (setq newest tem)))))
;; newest))
(defun file-newest-backup (filename &optional n)
"Return most recent backup file for FILENAME or nil if no backups exist.
Optional second argument N specifies the Nth newest backup, rather than the
most recent.
*** Changed by \"backup-dir.el\""
(nth (if (integerp n) (max 0 (1- n)) 0)
(sort (bkup-existing-backup-files filename)
'file-newer-than-file-p)))
;;; patch `latest-backup-file' from "dired"
;;;
;;; we use `dired-load-hook' to avoid loading dired now. This speeds things
;;; up considerably according to Thomas Feuster,
;;; feuster@tp4.physik.uni-giessen.de
;;;
;;; one really wonders why there are 3 functions to do the same thing...
;;;
(defun bkup-patch-latest-backup-file ()
(fset 'latest-backup-file (symbol-function 'file-newest-backup))
(remove-hook 'dired-load-hook 'bkup-patch-latest-backup-file))
(if (featurep 'dired)
;; if loaded, patch it now
(fset 'latest-backup-file (symbol-function 'file-newest-backup))
;; otherwise do it later
(add-hook 'dired-load-hook 'bkup-patch-latest-backup-file))
;;; patch `diff-latest-backup-file' from "diff"
;;;
(eval-after-load "diff"
'(fset 'diff-latest-backup-file
(symbol-function 'file-newest-backup)))
;;; finally, add to list of features
;;;
(provide 'backup-dir)
;;; backup-dir.el ends here
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: .emacs help
2002-09-11 16:19 Rehm, Keith
@ 2002-09-12 1:16 ` Miles Bader
0 siblings, 0 replies; 8+ messages in thread
From: Miles Bader @ 2002-09-12 1:16 UTC (permalink / raw)
Cc: help-gnu-emacs, bug-gnu-emacs
"Rehm, Keith" <keithr@SSD.FSI.com> writes:
> I am using GNU Emacs and use backup-dir seemingly.
> in my .emacs and am using the backup-dir.el I have attached.
I'm sure, but it's better if people use the built-in mechanism.
-Miles
--
Would you like fries with that?
^ permalink raw reply [flat|nested] 8+ messages in thread
* .emacs help
@ 2009-06-05 4:10 Benjamin Badgley
2009-06-05 8:02 ` Tassilo Horn
0 siblings, 1 reply; 8+ messages in thread
From: Benjamin Badgley @ 2009-06-05 4:10 UTC (permalink / raw)
To: help-gnu-emacs
Keep running into an error about wrong number of key command. Not versed
enough yet to comprehend the backtrace. Also not yet able to effectively
use rmail or gnus. Pointers to doc helpful. Can someone help?
--
Ben
; begin .emacs
; === Load Requires ===
; Get all the required load ups into one place, at the head of the file.
(require 'cl) ; load Common Lisp
(require 'emacs-goodies-el) ; load emacs goodies
(require 'advice) ; needed for framepop
(require 'w3m-load) ; load Emacs own internal web browser
(require 'recentf) ; load recent file menu
(require 'diff-mode "diff-mode" t) ; use diff mode
(require 'calendar) ; load the calender up
(require 'rmail) ; use rmail
(require 'gnus) ; load gnus
(require 'clipper) ; add a clipper
(require 'saveplace) ; keep your place
(require 'keywiz) ; game for knowing Emacs key bindings
(require 'remember) ; toss in a memory agent
;(require 'tex-suite) ; use AcuTex
(require 'filladapt); use filladapt
; === Main Emacs Preferences ===
; This is the vanilla of my emacs file, welcome.
; "Abandon hope all ye who enter." ;)
; === Core Vanilla ===
; Basic stuff I like having Emacs handle in house
(setq emacs-load-start-time (current-time)) ; load current time at start up
(enable-flow-control) ; enable flow control to address issue with gnus
(setq auto-save-timeout 600)
; autosave timeout in seconds - 300 is five minutes
(setq line-number-mode t) ; enable line numbers
(setq column-number-mode t) ; enable col numbers
(setq frame-title-format "%b" ) ; enable filename in buffer titles
(transient-mark-mode t) ; enable marked region to hilight
(delete-selection-mode 1) ; enable typing to replace hilighted region
(setq case-fold-search t) ; make searches case insensitive
(add-hook 'text-mode-hook 'turn-on-auto-fill) ; hook auto fill on in
text mode
(setq load-path (cons "~/emacs/" load-path))
; add usr home emacs directory to load path
(show-paren-mode 1) ; display parenths
(setq default-tab-width 5) ; set tabs
(global-font-lock-mode 1) ; set font lock global on
(setq font-lock-medium-decoration t) ; use medium font lock
(setq sentence-end-double-space nil) ; single space sentences
(setq-default filladapt-mode t) ; fill adapt enabled
(df "/" ) ; display disk use in the modeline
(add-hook 'text-mode-hook 'table-recognize) ; set emacs to manipulate tables
(setq initial-frame-alist '((cursor-type . (bar . 2))))
; set cursor to 2 pixel bar
(setq mouse-yank-at-point t) ; mouse pastes at the point
(defalias 'yes-or-no-p 'y-or-n-p) ; use y or n instead of yes or no
(setq-default save-place t) ; handy for editing large files, cursor
place saved
(add-hook 'text-mode-hook 'longlines-mode)
; enable text mode to use longline mode
(auto-compression-mode 1) ; use auto decompression, edit compressed files
; === More Advanced 'Nilla
; Here is a section of more advanced options for in house
; === recentf ===
(recentf-mode 1)
(setq recentf-max-saved-items 500)
(setq recentf-max-menu-items 60)
(setq recentf-exclude (append recentf-exclude '(".ftp:.*" ".sudo:.*" )))
(setq recentf-keep '(file-remote-p file-readable-p))
; === diff-mode ===
(setq diff-switches "-u" ) ; Use -u for plain diff also
(setq diff-default-read-only t)
; === Calendar ===
(setq calendar-latitude "38.63N")
(setq calendar-longitude "78.78W")
(setq calendar-location-name "Timberville, VA U.S.A.")
(setq mark-holidays-in-calendar t)
(setq calendar-time-display-form
'(24-hours ":" minutes (if time-zone " (") time-zone (if time-zone
")")))
(setq calendar-date-display-form
'((if dayname (concat dayname ", ")) day " " monthname " " year))
;(require 'astronomy "astronomy" t)
(setq solar-holidays t)
(setq hebrew-holidays t)
(setq islamic-holidays t)
(setq oriental-holidays t)
(setq christian-holidays t)
;; Display ISO week, available since 27.06.2008
(setq calendar-intermonth-header (propertize "WK" 'font-lock-face
'font-lock-function-name-face))
(setq calendar-intermonth-text
'(propertize
(format "%2d" (car (calendar-iso-from-absolute
(calendar-absolute-from-gregorian (list month day year)))))
'font-lock-face 'font-lock-function-name-face))
(setq calendar-daylight-savings-starts '(calendar-nth-named-day -1 0 3
year))
(setq calendar-daylight-savings-ends '(calendar-nth-named-day -1 0 9 year))
(setq calendar-week-start-day 1)
; === Backups ===
; Sends bacup files to a centeral directory ~/backups/
(defun make-backup-file-name(file)
(concat "~/backups/" (file-name-nondirectory file) "~"))
; === Undoc ===
; Kill MS Word documents dead.
;http://www.ccs.neu.edu/home/guttman/undoc.el
(autoload 'undoc "~/.emacs.d/undoc.el" "A minor mode which kills MS
Word files dead." t)
(autoload 'undoc-current-buffer "undoc" "" t)
(autoload 'undoc-region-after-mime-decode "undoc" "" t)
; === Remember ===
; Sends rembmer to ~/.notes file
(setq remember-handler-functions
'(remember-append-to-file))
; === Setnu ===
; Automagical line numbering for text mode
(autoload 'setnu-mode "~/.emacs.d/setnu+.el" "Minor mode for
numbering lines for text." t)
(add-hook 'text-mode-hook 'setnu-mode)
; === Browse Kill Ring ===
(autoload 'browse-kill-ring "~/.emacs.d/browse-kill-ring.el" "Enables
opening up of kill-ring in a buffer" t)
; === Flyspell ===
(require 'flyspell)
(defun turn-on-flyspell-mode () (flyspell-mode 1))
(defun turn-off-flyspell-mode () (flyspell-mode 0))
(setq flyspell-highlight-properties t
flyspell-multi-language-p nil
flyspell-issue-welcome-flag nil)
(defun turn-on-flyspell-prog-mode () (interactive)
(if (fboundp 'flyspell-prog-mode)
(flyspell-prog-mode)
(setq p-flyspell-restricted-checking t)
(flyspell-mode 1)))
(when (and (>= emacs-major-version 20) window-system)
(add-hook 'mail-send-hook 'turn-off-flyspell-mode)
(add-hook 'text-mode-hook 'turn-on-flyspell-mode)
(add-hook 'tex-mode-hook 'turn-on-flyspell-mode t)
(add-hook 'mail-setup-hook 'turn-on-flyspell-mode)
(add-hook 'fundamenal-mode-hook 'turn-on-flyspell-mode t)
(add-hook 'log-mode-hook 'turn-on-flyspell-mode t)
(add-hook 'math-edit-mode-hook 'turn-on-flyspell-prog-mode t)
(add-hook 'verilog-mode-hook 'turn-on-flyspell-prog-mode t)
(add-hook 'perl-mode-hook 'turn-on-flyspell-prog-mode t)
(add-hook 'tcl-mode-hook 'turn-on-flyspell-prog-mode t)
(add-hook 'c-mode-hook 'turn-on-flyspell-prog-mode t)
(add-hook 'postscript-mode-hook 'turn-on-flyspell-prog-mode t)
(add-hook 'c++-mode-hook 'turn-on-flyspell-prog-mode t)
(add-hook 'sh-mode-hook 'turn-on-flyspell-prog-mode t)
(add-hook 'emacs-lisp-mode-hook 'turn-on-flyspell-prog-mode t))
(defvar p-flyspell-restricted-checking nil
"If not nil, flyspell only checks spelling in comments and strings.")
(make-variable-buffer-local 'p-flyspell-restricted-checking)
(defadvice flyspell-get-word
(after checkable first activate)
"Return nil instead of word if checking restricted and not in comment
or string.
Spell check is restricted if p-flyspell-restricted-checking non-nil.
Word considered to be in comment or string if face property is set
to font-lock-comment-face or font-lock-string-face."
(setq ad-return-value
(if (and p-flyspell-restricted-checking
ad-return-value
(not (member (get-text-property (car (cdr ad-return-value))
`face)
(list 'font-lock-comment-face
'font-lock-string-face))))
nil
ad-return-value)))
(if (fboundp 'flyspell-prog-mode)
(ad-deactivate 'flyspell-get-word));
(dolist (hook '(text-mode-hook))
(add-hook hook (lambda () (flyspell-mode 1))))
(dolist (hook '(change-log-mode-hook log-edit-mode-hook))
(add-hook hook (lambda () (flyspell-mode -1))))
; === Accidental Closure Avoidance ===
; Saves you from exiting Emacs accidentally, prompts you to be sure.
;http://www.dotemacs.de/dotfiles/KilianAFoth.emacs.html
(global-set-key [(control x) (control c)]
(function
(lambda () (interactive)
(cond ((y-or-n-p "Quit? ")
(save-buffers-kill-emacs)))))
; === Cursor Color Modes ===
; Changes the cursor color to indicate which mode you're in.
(setq hcz-set-cursor-color-color "")
(setq hcz-set-cursor-color-buffer "")
(defun hcz-set-cursor-color-according-to-mode ()
"change cursor color according to some minor modes."
;;set-cursor-color is somewhat costly, so we only call it when
;;needed:
(let ((color
(if buffer-read-only "black"
(if overwrite-mode "red"
"blue"))))
(unless (and
(string= color hcz-set-cursor-color-color)
(string= (buffer-name) hcz-set-cursor-color-buffer))
(set-cursor-color (setq hcz-set-cursor-color-color color))
(setq hcz-set-cursor-color-buffer (buffer-name)))))
(add-hook 'post-command-hook 'hcz-set-cursor-color-according-to-mode)
; === Clipper ===
; Creates a buffer for keeping frequently used bits of code, text in.
; A similar feature akin to a Windows editor NoteTab.
(global-set-key "\C-cci" 'clipper-insert) ; insert text clip at point
(global-set-key "\C-ccc" 'clipper-create) ; create text clip
; === Framepop ===
(setq framepop-frame-parameters
'((name . nil) ; use buffer name
(unsplittable . t) ; always include this
(menu-bar-lines . 0) ; no menu bar
(minibuffer . nil) ; or minubuffer
(left . -1) ; top left corner of screen,
(top . 30) ; away from my main frame
(width . 71) ; narrower, so it fits nicely
(background-color . "wheat") ; buffer background color
(foreground-color . "cornsilk")
(font . "-*-courier-bold-o-*-*-12-*-*-*-m-*-*-*")))
(setq special-display-function 'framepop-special-display)
(setq special-display-buffer-names
'("*Shell Command Output*" "*grep*" "*compilation*"))
; === Ibuffer ===
(setq ibuffer-formats '((mark modified read-only " " (name 16 16) " "
(size 6 -1 :right) " " (mode 16 16 :center)
" " (process 8 -1) " " filename)
(mark " " (name 16 -1) " " filename))
ibuffer-elide-long-columns t
ibuffer-eliding-string "&")
; === Whitespace Nuke ===
(autoload 'nuke-trailing-whitespace "nuke-trailing-whitespace" nil t)
(add-hook 'mail-send-hook 'nuke-trailing-whitespace)
(add-hook 'write-file-hooks 'nuke-trailing-whitespace)
; === Silly Mail ===
(autoload 'sm-add-random-header "silly-mail" nil t)
(add-hook 'mail-setup-hook 'sm-add-random-header)
(add-hook 'mh-letter-mode-hook 'sm-add-random-header)
; === Load Abbrevs ===
(condition-case ()
(quietly-read-abbrev-file)
(file-error nil))
(add-hook 'MYMODE-mode-hook
(lambda ()
(setq abbrev-mode t)))
; === C, C++, Java Indentation ===
(defun my-c-mode-common-hook ()
(c-set-offset +)))
(add-hook 'c-mode-hook 'my-c-mode-common-hook)
; === Mode Alist ===
; Line below is template for adding to atlist
; (setq auto-mode-alist (cons '("\\.BAR\\'" . FOO-mode) auto-mode-alist))
(setq auto-mode-alist (cons '("\\.txt\\'" . text-mode) auto-mode-alist))
(setq auto-mode-alist (cons '("\\.c\\'" . cc-mode) auto-mode-alist))
(setq auto-mode-alist (cons '("\\.pl\\'" . perl-mode) auto-mode-alist))
(setq auto-mode-alist (cons '("\\.el\\'" . lisp-mode) auto-mode-alist))
(setq auto-mode-alist (cons '("\\.html\\'" . html-helper-mode)
auto-mode-alist))
(setq auto-mode-alist (cons '("\\.htm\\'" . html-helper-mode)
auto-mode-alist))
(setq auto-mode-alist (cons '("\\.m$" . matlab-mode) auto-mode-alist))
; === Odd Files ===
; Load all these odd files as text.
(setq auto-mode-alist (cons '("\\README\\' \\NOTES\\' \\INSTALL\\'
\\COPYING\\' \\AUTHORS\\' \\CREDITS\\' \\CHANGELOG\\' " . text-mode)
auto-mode-alist))
; === Encryption === Mail & News Settings ===
(load-library "mailcrypt")
(mc-setversion "gpg")
(setq mc-gpg-user-id "Benjamin Badgley")
(autoload 'mc-install-write-mode "mailcrypt" nil t)
(autoload 'mc-install-read-mode "mailcrypt" nil t)
(add-hook 'mail-mode-hook 'mc-install-write-mode)
; === Rmail ===
(add-hook 'rmail-show-message-hook 'mc-install-read-mode)
(add-hook 'rmail-summary-mode-hook 'mc-install-read-mode)
(setq user-mail-address "mortecanine@peoplepc.com")
(setq mail-host-address "pop3.peoplepc.com")
(setq mail-signature t) ; defaults to ~/.signature
(setq user-mail-address "mortecanine@peoplepc.com")
(setq smtpmail-default-smtp-server "smtpauth.peoplepc.com")
(setq smtpmail-local-domain nil)
(setq user-full-name "Ben Badgley")
(setq send-mail-function 'smtpmail-send-it)
(load-library "smtpmail")
(load-library "supercite")
(setq sc-nested-citation-p t)
(setenv "MAILHOST" "pop3.peoplepc.com")
(setq rmail-pop-password-required t)
(setq rmail-primary-inbox-list
'("po:mortecanine@peoplepc.com"
"po:benbadge72@gmail.com" ))
; === rmail reply function
(defun rmail-reply-t ()
"Reply only to the sender of the current message. (See rmail-reply.)"
(interactive)
(rmail-reply t))
(add-hook 'rmail-mode-hook
(lambda ()
(define-key rmail-mode-map "r" 'rmail-reply-t)
(define-key rmail-mode-map "R" 'rmail-reply)))
; === Gnus ===
(add-hook 'gnus-summary-mode-hook 'mc-install-read-mode)
(add-hook 'message-mode-hook 'mc-install-write-mode)
(add-hook 'news-reply-mode-hook 'mc-install-write-mode)
(setq nntp-maximum-request 1)
(setq gnus-nntp-server "news.peoplepc.com")
(setq gnus-cache-directory "~/news/cache/")
(setq gnus-home-directory "~/news/")
(setq gnus-startup-file "~/news/.newsrc")
(setq gnus-default-nntp-server "news.peoplepc.com")
(setq gnus-user-full-name "Ben Badgley")
(setq gnus-user-from-line "mortecanine@peoplepc.com")
(setq message-default-news-headers
"From: Ben Badgley <mortecanine@peoplepc.com>\nReply-To: Ben Badgley
<mortecanine@peoplepc.com>\n")
(setq gnus-use-generic-from "Ben Badgley")
(setq mail-host-address "pop3.peoplepc.com")
(setq gnus-local-organization "Don't need any")
(setq gnus-secondary-select-methods '((nnml "")))
(setq nnmail-pop-password-required t)(setq gnus-use-cache t)
(setq message-yank-prefix ">")
; === Color Theme ===
(require 'color-theme)
(color-theme-wheat) ; change color themes here
; === Time ===
(setq display-time-24hr-format t)
(setq display-time-day-and-date t)
(display-time)
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: .emacs help
2009-06-05 4:10 Benjamin Badgley
@ 2009-06-05 8:02 ` Tassilo Horn
0 siblings, 0 replies; 8+ messages in thread
From: Tassilo Horn @ 2009-06-05 8:02 UTC (permalink / raw)
To: help-gnu-emacs
Benjamin Badgley <mortecanine@peoplepc.com> writes:
Hi Benjamin,
> ; === Accidental Closure Avoidance ===
> ; Saves you from exiting Emacs accidentally, prompts you to be sure.
> ;http://www.dotemacs.de/dotfiles/KilianAFoth.emacs.html
> (global-set-key [(control x) (control c)]
> (function
> (lambda () (interactive)
> (cond ((y-or-n-p "Quit? ")
> (save-buffers-kill-emacs)))))
You don't close the global-set-key call here. The next lines are all
supplied as parameters, but global-set-key expects only 2.
> ; === Cursor Color Modes ===
> ; Changes the cursor color to indicate which mode you're in.
> (setq hcz-set-cursor-color-color "")
> (setq hcz-set-cursor-color-buffer "")
[...]
> ; === C, C++, Java Indentation ===
> (defun my-c-mode-common-hook ()
> (c-set-offset +)))
^
This paren closes the global-set-key call.
HTH,
Tassilo
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: .emacs help
@ 2009-06-07 11:39 Benjamin Badgley
0 siblings, 0 replies; 8+ messages in thread
From: Benjamin Badgley @ 2009-06-07 11:39 UTC (permalink / raw)
To: help-gnu-emacs
Apologies for not replying sooner. Yes it was a mishap of parenthesis.
Thank you for suggesting a look at it. This resolved the issue.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2009-06-07 11:39 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-09-10 14:49 .emacs help exmixllxer
2002-09-10 14:54 ` exmixllxer
2002-09-11 1:25 ` Miles Bader
-- strict thread matches above, loose matches on Subject: below --
2002-09-11 16:19 Rehm, Keith
2002-09-12 1:16 ` Miles Bader
2009-06-05 4:10 Benjamin Badgley
2009-06-05 8:02 ` Tassilo Horn
2009-06-07 11:39 Benjamin Badgley
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).