Mercurial > hg > xemacs-beta
comparison lisp/files.el @ 265:8efd647ea9ca r20-5b31
Import from CVS: tag r20-5b31
author | cvs |
---|---|
date | Mon, 13 Aug 2007 10:25:37 +0200 |
parents | 727739f917cb |
children | 966663fcf606 |
comparison
equal
deleted
inserted
replaced
264:682d2a9d41a5 | 265:8efd647ea9ca |
---|---|
128 :type 'boolean | 128 :type 'boolean |
129 :group 'backup) | 129 :group 'backup) |
130 | 130 |
131 (defvar backup-enable-predicate | 131 (defvar backup-enable-predicate |
132 '(lambda (name) | 132 '(lambda (name) |
133 (not (or (string-equal "/tmp/" (substring name 0 5)) | 133 (not (or (string-match "^/tmp/" name) |
134 (let ((tmpdir (temp-directory))) | 134 (let ((tmpdir (temp-directory))) |
135 (and tmpdir | 135 (and tmpdir |
136 (string-equal (concat tmpdir "/") | 136 (string-match (concat "^" (regexp-quote tmpdir) "/") |
137 (substring name 0 (1+ (length tmpdir))))))))) | 137 tmpdir)))))) |
138 "Predicate that looks at a file name and decides whether to make backups. | 138 "Predicate that looks at a file name and decides whether to make backups. |
139 Called with an absolute file name as argument, it returns t to enable backup.") | 139 Called with an absolute file name as argument, it returns t to enable backup.") |
140 | 140 |
141 (defcustom buffer-offer-save nil | 141 (defcustom buffer-offer-save nil |
142 "*Non-nil in a buffer means offer to save the buffer on exit | 142 "*Non-nil in a buffer means offer to save the buffer on exit |
384 | 384 |
385 (defvar cd-path nil | 385 (defvar cd-path nil |
386 "Value of the CDPATH environment variable, as a list. | 386 "Value of the CDPATH environment variable, as a list. |
387 Not actually set up until the first time you use it.") | 387 Not actually set up until the first time you use it.") |
388 | 388 |
389 (defvar cdpath-previous nil | |
390 "Prior value of the CDPATH environment variable.") | |
391 | |
389 (defvar path-separator ":" | 392 (defvar path-separator ":" |
390 "Character used to separate concatenated paths.") | 393 "Character used to separate concatenated paths.") |
391 | 394 |
392 (defun parse-colon-path (cd-path) | 395 ;; Merged with equivalent C Code. |
393 "Explode a colon-separated list of paths into a string list." | 396 ;(defun parse-colon-path (cd-path) |
394 (and cd-path | 397 ; "Explode a colon-separated list of paths into a string list." |
395 (let (cd-list (cd-start 0) cd-colon) | 398 ; (and cd-path |
396 (setq cd-path (concat cd-path path-separator)) | 399 ; (let (cd-list (cd-start 0) cd-colon) |
397 (while (setq cd-colon (string-match path-separator cd-path cd-start)) | 400 ; (setq cd-path (concat cd-path path-separator)) |
398 (setq cd-list | 401 ; (while (setq cd-colon (string-match path-separator cd-path cd-start)) |
399 (nconc cd-list | 402 ; (setq cd-list |
400 (list (if (= cd-start cd-colon) | 403 ; (nconc cd-list |
401 nil | 404 ; (list (if (= cd-start cd-colon) |
402 (substitute-in-file-name | 405 ; nil |
403 (file-name-as-directory | 406 ; (substitute-in-file-name |
404 (substring cd-path cd-start cd-colon))))))) | 407 ; (file-name-as-directory |
405 (setq cd-start (+ cd-colon 1))) | 408 ; (substring cd-path cd-start cd-colon))))))) |
406 cd-list))) | 409 ; (setq cd-start (+ cd-colon 1))) |
410 ; cd-list))) | |
407 | 411 |
408 (defun cd-absolute (dir) | 412 (defun cd-absolute (dir) |
409 "Change current directory to given absolute file name DIR." | 413 "Change current directory to given absolute file name DIR." |
410 ;; Put the name into directory syntax now, | 414 ;; Put the name into directory syntax now, |
411 ;; because otherwise expand-file-name may give some bad results. | 415 ;; because otherwise expand-file-name may give some bad results. |
434 (and (member cd-path '(nil ("./"))) | 438 (and (member cd-path '(nil ("./"))) |
435 (null (getenv "CDPATH")))))) | 439 (null (getenv "CDPATH")))))) |
436 (if (file-name-absolute-p dir) | 440 (if (file-name-absolute-p dir) |
437 (cd-absolute (expand-file-name dir)) | 441 (cd-absolute (expand-file-name dir)) |
438 ;; XEmacs | 442 ;; XEmacs |
439 (if (null cd-path) | 443 (unless (and cd-path (equal (getenv "CDPATH") cdpath-previous)) |
440 ;;#### Unix-specific | 444 ;;#### Unix-specific |
441 (let ((trypath (parse-colon-path (getenv "CDPATH")))) | 445 (let ((trypath (parse-colon-path |
442 (setq cd-path (or trypath (list "./"))))) | 446 (setq cdpath-previous (getenv "CDPATH"))))) |
447 (setq cd-path (or trypath (list "./"))))) | |
443 (or (catch 'found | 448 (or (catch 'found |
444 (mapcar #'(lambda (x) | 449 (mapcar #'(lambda (x) |
445 (let ((f (expand-file-name (concat x dir)))) | 450 (let ((f (expand-file-name (concat x dir)))) |
446 (if (file-directory-p f) | 451 (if (file-directory-p f) |
447 (progn | 452 (progn |
1380 (progn | 1385 (progn |
1381 (setq mode (cdr (car alist))) | 1386 (setq mode (cdr (car alist))) |
1382 (setq alist nil)) | 1387 (setq alist nil)) |
1383 (setq alist (cdr alist)))))) | 1388 (setq alist (cdr alist)))))) |
1384 (if mode | 1389 (if mode |
1385 (funcall mode)) | 1390 (if (not (fboundp mode)) |
1391 (progn | |
1392 (if (or (not (boundp 'package-get-base)) | |
1393 (not package-get-base)) | |
1394 (load "package-get-base")) | |
1395 (require 'package-get) | |
1396 (let ((name (package-get-package-provider mode))) | |
1397 (if name | |
1398 (message "Mode %s is not installed. Download package %s" mode name) | |
1399 (message "Mode %s either doesn't exist or is not a known package" mode)) | |
1400 (sit-for 2) | |
1401 (error "%s" mode))) | |
1402 (funcall mode))) | |
1386 )))))) | 1403 )))))) |
1387 | 1404 |
1388 (defvar hack-local-variables-hook nil | 1405 (defvar hack-local-variables-hook nil |
1389 "Normal hook run after processing a file's local variables specs. | 1406 "Normal hook run after processing a file's local variables specs. |
1390 Major modes can use this to examine user-specified local variables | 1407 Major modes can use this to examine user-specified local variables |