diff options
| author | Paul Eggert | 2017-08-28 21:50:09 -0700 |
|---|---|---|
| committer | Paul Eggert | 2017-08-28 21:51:39 -0700 |
| commit | c1854b1d31e1b0a3a9e91ef41110a5fa77bedb31 (patch) | |
| tree | 88827e83e8191bdf4deaa67031d43d38c45ec045 | |
| parent | 7b8699759f3332e8b5cfe6eed5a80090d9ef8948 (diff) | |
| download | emacs-c1854b1d31e1b0a3a9e91ef41110a5fa77bedb31.tar.gz emacs-c1854b1d31e1b0a3a9e91ef41110a5fa77bedb31.zip | |
Silence false alarms for symlinks to sources
Problem reported by Glenn Morris (Bug#28264).
* lisp/files.el (files--splice-dirname-file): New function.
(file-truename, file-chase-links): Use it.
| -rw-r--r-- | lisp/files.el | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/lisp/files.el b/lisp/files.el index b3eab29c53a..5f55aa75a70 100644 --- a/lisp/files.el +++ b/lisp/files.el | |||
| @@ -1153,6 +1153,21 @@ names beginning with `~'." | |||
| 1153 | (and (file-name-absolute-p file) | 1153 | (and (file-name-absolute-p file) |
| 1154 | (not (eq (aref file 0) ?~)))) | 1154 | (not (eq (aref file 0) ?~)))) |
| 1155 | 1155 | ||
| 1156 | (defun files--splice-dirname-file (dirname file) | ||
| 1157 | "Splice DIRNAME to FILE like the operating system would. | ||
| 1158 | If FILENAME is relative, return DIRNAME concatenated to FILE. | ||
| 1159 | Otherwise return FILE, quoted with `/:' if DIRNAME and FILE have | ||
| 1160 | different handlers; although this quoting is dubious if DIRNAME | ||
| 1161 | is remote, it is not clear what would be better. This function | ||
| 1162 | differs from `expand-file-name' in that DIRNAME must be a | ||
| 1163 | directory name and leading `~' and `/:' are not special in FILE." | ||
| 1164 | (if (files--name-absolute-system-p file) | ||
| 1165 | (if (eq (find-file-name-handler dirname 'file-symlink-p) | ||
| 1166 | (find-file-name-handler file 'file-symlink-p)) | ||
| 1167 | file | ||
| 1168 | (concat "/:" file)) | ||
| 1169 | (concat dirname file))) | ||
| 1170 | |||
| 1156 | (defun file-truename (filename &optional counter prev-dirs) | 1171 | (defun file-truename (filename &optional counter prev-dirs) |
| 1157 | "Return the truename of FILENAME. | 1172 | "Return the truename of FILENAME. |
| 1158 | If FILENAME is not absolute, first expands it against `default-directory'. | 1173 | If FILENAME is not absolute, first expands it against `default-directory'. |
| @@ -1253,10 +1268,7 @@ containing it, until no links are left at any level. | |||
| 1253 | ;; We can't safely use expand-file-name here | 1268 | ;; We can't safely use expand-file-name here |
| 1254 | ;; since target might look like foo/../bar where foo | 1269 | ;; since target might look like foo/../bar where foo |
| 1255 | ;; is itself a link. Instead, we handle . and .. above. | 1270 | ;; is itself a link. Instead, we handle . and .. above. |
| 1256 | (setq filename | 1271 | (setq filename (files--splice-dirname-file dir target) |
| 1257 | (concat (if (files--name-absolute-system-p target) | ||
| 1258 | "/:" dir) | ||
| 1259 | target) | ||
| 1260 | done nil) | 1272 | done nil) |
| 1261 | ;; No, we are done! | 1273 | ;; No, we are done! |
| 1262 | (setq done t)))))))) | 1274 | (setq done t)))))))) |
| @@ -1291,10 +1303,8 @@ it means chase no more than that many links and then stop." | |||
| 1291 | (directory-file-name (file-name-directory newname)))) | 1303 | (directory-file-name (file-name-directory newname)))) |
| 1292 | ;; Now find the parent of that dir. | 1304 | ;; Now find the parent of that dir. |
| 1293 | (setq newname (file-name-directory newname))) | 1305 | (setq newname (file-name-directory newname))) |
| 1294 | (setq newname (concat (if (files--name-absolute-system-p tem) | 1306 | (setq newname (files--splice-dirname-file (file-name-directory newname) |
| 1295 | "/:" | 1307 | tem)) |
| 1296 | (file-name-directory newname)) | ||
| 1297 | tem)) | ||
| 1298 | (setq count (1+ count)))) | 1308 | (setq count (1+ count)))) |
| 1299 | newname)) | 1309 | newname)) |
| 1300 | 1310 | ||