| 1278 | | (if (and automount-dir-prefix |
|---|
| 1279 | | (string-match automount-dir-prefix filename) |
|---|
| 1280 | | (file-exists-p (file-name-directory |
|---|
| 1281 | | (substring filename (1- (match-end 0)))))) |
|---|
| 1282 | | (setq filename (substring filename (1- (match-end 0))))) |
|---|
| 1283 | | (let ((tail directory-abbrev-alist)) |
|---|
| 1284 | | ;; If any elt of directory-abbrev-alist matches this name, |
|---|
| 1285 | | ;; abbreviate accordingly. |
|---|
| 1286 | | (while tail |
|---|
| 1287 | | (if (string-match (car (car tail)) filename) |
|---|
| | 1282 | (save-match-data |
|---|
| | 1283 | (if (and automount-dir-prefix |
|---|
| | 1284 | (string-match automount-dir-prefix filename) |
|---|
| | 1285 | (file-exists-p (file-name-directory |
|---|
| | 1286 | (substring filename (1- (match-end 0)))))) |
|---|
| | 1287 | (setq filename (substring filename (1- (match-end 0))))) |
|---|
| | 1288 | (let ((tail directory-abbrev-alist)) |
|---|
| | 1289 | ;; If any elt of directory-abbrev-alist matches this name, |
|---|
| | 1290 | ;; abbreviate accordingly. |
|---|
| | 1291 | (while tail |
|---|
| | 1292 | (if (string-match (car (car tail)) filename) |
|---|
| | 1293 | (setq filename |
|---|
| | 1294 | (concat (cdr (car tail)) (substring filename (match-end 0))))) |
|---|
| | 1295 | (setq tail (cdr tail))) |
|---|
| | 1296 | ;; Compute and save the abbreviated homedir name. |
|---|
| | 1297 | ;; We defer computing this until the first time it's needed, to |
|---|
| | 1298 | ;; give time for directory-abbrev-alist to be set properly. |
|---|
| | 1299 | ;; We include a slash at the end, to avoid spurious matches |
|---|
| | 1300 | ;; such as `/usr/foobar' when the home dir is `/usr/foo'. |
|---|
| | 1301 | (or abbreviated-home-dir |
|---|
| | 1302 | (setq abbreviated-home-dir |
|---|
| | 1303 | (let ((abbreviated-home-dir "$foo")) |
|---|
| | 1304 | (concat "^" (abbreviate-file-name (expand-file-name "~")) |
|---|
| | 1305 | "\\(/\\|$\\)")))) |
|---|
| | 1306 | |
|---|
| | 1307 | ;; If FILENAME starts with the abbreviated homedir, |
|---|
| | 1308 | ;; make it start with `~' instead. |
|---|
| | 1309 | (if (and (string-match abbreviated-home-dir filename) |
|---|
| | 1310 | ;; If the home dir is just /, don't change it. |
|---|
| | 1311 | (not (and (= (match-end 0) 1) |
|---|
| | 1312 | (= (aref filename 0) ?/))) |
|---|
| | 1313 | ;; MS-DOS root directories can come with a drive letter; |
|---|
| | 1314 | ;; Novell Netware allows drive letters beyond `Z:'. |
|---|
| | 1315 | (not (and (or (eq system-type 'ms-dos) |
|---|
| | 1316 | (eq system-type 'cygwin) |
|---|
| | 1317 | (eq system-type 'windows-nt)) |
|---|
| | 1318 | (save-match-data |
|---|
| | 1319 | (string-match "^[a-zA-`]:/$" filename))))) |
|---|
| 1289 | | (concat (cdr (car tail)) (substring filename (match-end 0))))) |
|---|
| 1290 | | (setq tail (cdr tail))) |
|---|
| 1291 | | ;; Compute and save the abbreviated homedir name. |
|---|
| 1292 | | ;; We defer computing this until the first time it's needed, to |
|---|
| 1293 | | ;; give time for directory-abbrev-alist to be set properly. |
|---|
| 1294 | | ;; We include a slash at the end, to avoid spurious matches |
|---|
| 1295 | | ;; such as `/usr/foobar' when the home dir is `/usr/foo'. |
|---|
| 1296 | | (or abbreviated-home-dir |
|---|
| 1297 | | (setq abbreviated-home-dir |
|---|
| 1298 | | (let ((abbreviated-home-dir "$foo")) |
|---|
| 1299 | | (concat "^" (abbreviate-file-name (expand-file-name "~")) |
|---|
| 1300 | | "\\(/\\|$\\)")))) |
|---|
| 1301 | | |
|---|
| 1302 | | ;; If FILENAME starts with the abbreviated homedir, |
|---|
| 1303 | | ;; make it start with `~' instead. |
|---|
| 1304 | | (if (and (string-match abbreviated-home-dir filename) |
|---|
| 1305 | | ;; If the home dir is just /, don't change it. |
|---|
| 1306 | | (not (and (= (match-end 0) 1) |
|---|
| 1307 | | (= (aref filename 0) ?/))) |
|---|
| 1308 | | ;; MS-DOS root directories can come with a drive letter; |
|---|
| 1309 | | ;; Novell Netware allows drive letters beyond `Z:'. |
|---|
| 1310 | | (not (and (or (eq system-type 'ms-dos) |
|---|
| 1311 | | (eq system-type 'cygwin) |
|---|
| 1312 | | (eq system-type 'windows-nt)) |
|---|
| 1313 | | (save-match-data |
|---|
| 1314 | | (string-match "^[a-zA-`]:/$" filename))))) |
|---|
| 1315 | | (setq filename |
|---|
| 1316 | | (concat "~" |
|---|
| 1317 | | (substring filename (match-beginning 1) (match-end 1)) |
|---|
| 1318 | | (substring filename (match-end 0))))) |
|---|
| 1319 | | filename)) |
|---|
| | 1321 | (concat "~" |
|---|
| | 1322 | (match-string 1 filename) |
|---|
| | 1323 | (substring filename (match-end 0))))) |
|---|
| | 1324 | filename))) |
|---|
| 2759 | | (t (make-local-variable var) |
|---|
| 2760 | | ;; Make sure the string has no text properties. |
|---|
| 2761 | | ;; Some text properties can get evaluated in various ways, |
|---|
| 2762 | | ;; so it is risky to put them on with a local variable list. |
|---|
| 2763 | | (if (stringp val) |
|---|
| 2764 | | (set-text-properties 0 (length val) nil val)) |
|---|
| 2765 | | (set var val)))) |
|---|
| | 2757 | (t |
|---|
| | 2758 | ;; Make sure the string has no text properties. |
|---|
| | 2759 | ;; Some text properties can get evaluated in various ways, |
|---|
| | 2760 | ;; so it is risky to put them on with a local variable list. |
|---|
| | 2761 | (if (stringp val) |
|---|
| | 2762 | (set-text-properties 0 (length val) nil val)) |
|---|
| | 2763 | (set (make-local-variable var) val)))) |
|---|