[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: "Args out of range:" error when opening existing files
From: |
Glenn Morris |
Subject: |
Re: "Args out of range:" error when opening existing files |
Date: |
Wed, 09 Oct 2002 16:15:16 +0100 |
User-agent: |
Gnus, GNU Emacs (www.gnu.org/directory/emacs.html) |
Joseph Shraibman wrote:
> I keep getting errors like this when opening existing files:
[...]
> string-equal: Args out of range: "/etc/hosts", 0, 18
I think you could solve this pretty easily:
i) Does it happen if you start Emacs with -q?
No, so it's something caused by your .emacs file.
ii) Maybe look for "string-equal" in .emacs? Oh look, there it is, with a
"0" and an "18" too:
> ; this prevents the creating of ~ backup files in the jsp directory, bec.
> ; the ~ files are visible to anyone who accesses them with a web browser
> (setq backup-enable-predicate
> (lambda (name)
> (or (< (length name) 5)
> (and
> (not (string-equal "/tmp/" (substring name 0 5)))
> (not (string-equal "/local/www/htdocs/"
> (substring name 0 18)))))))
Comment this out and your problems will go away.
(substring name 0 18)
is clearly going to give an error when you visit a file whose full name has
less than 18 characters.
So you want to have no backups for files beneath "/local/www/htdocs/".
I use something like this:
(defun my-backup-enable-predicate (name)
"Function to use for `backup-enable-predicate'.
Runs `normal-backup-enable-predicate', but checks further if that is non-nil."
(when (normal-backup-enable-predicate name)
(let* ((dir "/local/www/htdocs/")
(comp (compare-strings dir 0 nil name 0 nil)))
;; Directory is under dir.
(not (and (not (eq comp t))
(< comp (- (length dir))))))))
(setq backup-enable-predicate 'my-backup-enable-predicate)
Or, as you say you are using Emacs 21, you could use the variable
backup-directory-alist to keep the backups for your htdocs somewhere else.
For example:
(setq backup-directory-alist
'(("^/local/www/htdocs/" . "/path/to/secure/directory")))