aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Morris2011-02-17 23:48:40 -0800
committerGlenn Morris2011-02-17 23:48:40 -0800
commitd1be20a1d3580411aa303d5fa6af2a52eac52fd1 (patch)
treef76b9a6c5111b7b4488c6d0a86218a462d80dc86
parent7d315eb67800796d7d7f39030eb7682340d985e5 (diff)
downloademacs-d1be20a1d3580411aa303d5fa6af2a52eac52fd1.tar.gz
emacs-d1be20a1d3580411aa303d5fa6af2a52eac52fd1.zip
dired-x largely cosmetic changes.
* lisp/dired-x.el (dired-clean-up-after-deletion, dired-do-relsymlink) (dired-do-relsymlink-regexp, dired-find-buffer-nocreate): Use #'. (dired-hack-local-variables): Use inhibit-read-only. (dired-guess-default): Simplify. (dired-make-relative-symlink): Use dotimes. (dired-simultaneous-find-file): Use dolist. (dired-mark-sexp): Remove unneeded `if'. Use line-end-position. (dired-x-hands-off-my-keys): Doc fix. (dired-x-bind-find-file): Doc fix. Use remapping. (after-init-hook): No need to add dired-x-bind-find-file. (dired-x-find-file, dired-x-find-file-other-window): Doc fixes. No need to call expand-file-name. (dired-filename-at-point): Remove unused locals `end', `filename'.
-rw-r--r--lisp/ChangeLog16
-rw-r--r--lisp/dired-x.el265
2 files changed, 126 insertions, 155 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 8e850fb9409..de3b102c3a7 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,19 @@
12011-02-18 Glenn Morris <rgm@gnu.org>
2
3 * dired-x.el (dired-clean-up-after-deletion, dired-do-relsymlink)
4 (dired-do-relsymlink-regexp, dired-find-buffer-nocreate): Use #'.
5 (dired-hack-local-variables): Use inhibit-read-only.
6 (dired-guess-default): Simplify.
7 (dired-make-relative-symlink): Use dotimes.
8 (dired-simultaneous-find-file): Use dolist.
9 (dired-mark-sexp): Remove unneeded `if'. Use line-end-position.
10 (dired-x-hands-off-my-keys): Doc fix.
11 (dired-x-bind-find-file): Doc fix. Use remapping.
12 (after-init-hook): No need to add dired-x-bind-find-file.
13 (dired-x-find-file, dired-x-find-file-other-window): Doc fixes.
14 No need to call expand-file-name.
15 (dired-filename-at-point): Remove unused locals `end', `filename'.
16
12011-02-18 Stefan Monnier <monnier@iro.umontreal.ca> 172011-02-18 Stefan Monnier <monnier@iro.umontreal.ca>
2 18
3 * emacs-lisp/pcase.el (pcase--u1): Understand non-linear patterns. 19 * emacs-lisp/pcase.el (pcase--u1): Understand non-linear patterns.
diff --git a/lisp/dired-x.el b/lisp/dired-x.el
index 202b4e754d7..e591bb5d1d9 100644
--- a/lisp/dired-x.el
+++ b/lisp/dired-x.el
@@ -337,7 +337,7 @@ Remove expanded subdir of deleted dir, if any."
337 (when dired-clean-up-buffers-too 337 (when dired-clean-up-buffers-too
338 (let ((buf (get-file-buffer fn))) 338 (let ((buf (get-file-buffer fn)))
339 (and buf 339 (and buf
340 (funcall (function y-or-n-p) 340 (funcall #'y-or-n-p
341 (format "Kill buffer of %s, too? " 341 (format "Kill buffer of %s, too? "
342 (file-name-nondirectory fn))) 342 (file-name-nondirectory fn)))
343 (kill-buffer buf))) 343 (kill-buffer buf)))
@@ -828,26 +828,25 @@ See also `dired-enable-local-variables'."
828 828
829(defun dired-hack-local-variables () 829(defun dired-hack-local-variables ()
830 "Evaluate local variables in `dired-local-variables-file' for dired buffer." 830 "Evaluate local variables in `dired-local-variables-file' for dired buffer."
831 (if (and dired-local-variables-file 831 (and (stringp dired-local-variables-file)
832 (stringp dired-local-variables-file) 832 (file-exists-p dired-local-variables-file)
833 (file-exists-p dired-local-variables-file)) 833 (let ((opoint (point-max))
834 (let ((opoint (point-max)) 834 (inhibit-read-only t)
835 buffer-read-only 835 ;; In case user has `enable-local-variables' set to nil we
836 ;; In case user has `enable-local-variables' set to nil we 836 ;; override it locally with dired's variable.
837 ;; override it locally with dired's variable. 837 (enable-local-variables dired-enable-local-variables))
838 (enable-local-variables dired-enable-local-variables)) 838 ;; Insert 'em.
839 ;; Insert 'em. 839 (save-excursion
840 (save-excursion 840 (goto-char opoint)
841 (goto-char opoint) 841 (insert "\^L\n")
842 (insert "\^L\n") 842 (insert-file-contents dired-local-variables-file))
843 (insert-file-contents dired-local-variables-file)) 843 ;; Hack 'em.
844 ;; Hack 'em. 844 (let ((buffer-file-name dired-local-variables-file))
845 (let ((buffer-file-name dired-local-variables-file)) 845 (hack-local-variables))
846 (hack-local-variables)) 846 ;; Make sure that the modeline shows the proper information.
847 ;; Make sure that the modeline shows the proper information. 847 (dired-sort-set-modeline)
848 (dired-sort-set-modeline) 848 ;; Delete this stuff: `eobp' is used to find last subdir by dired.el.
849 ;; Delete this stuff: `eobp' is used to find last subdir by dired.el. 849 (delete-region opoint (point-max)))))
850 (delete-region opoint (point-max)))))
851 850
852(defun dired-omit-here-always () 851(defun dired-omit-here-always ()
853 "Create `dired-local-variables-file' for omitting and reverts directory. 852 "Create `dired-local-variables-file' for omitting and reverts directory.
@@ -856,14 +855,12 @@ dired."
856 (interactive) 855 (interactive)
857 (if (file-exists-p dired-local-variables-file) 856 (if (file-exists-p dired-local-variables-file)
858 (message "File `./%s' already exists." dired-local-variables-file) 857 (message "File `./%s' already exists." dired-local-variables-file)
859
860 ;; Create `dired-local-variables-file'. 858 ;; Create `dired-local-variables-file'.
861 (with-current-buffer (get-buffer-create " *dot-dired*") 859 (with-current-buffer (get-buffer-create " *dot-dired*")
862 (erase-buffer) 860 (erase-buffer)
863 (insert "Local Variables:\ndired-omit-mode: t\nEnd:\n") 861 (insert "Local Variables:\ndired-omit-mode: t\nEnd:\n")
864 (write-file dired-local-variables-file) 862 (write-file dired-local-variables-file)
865 (kill-buffer (current-buffer))) 863 (kill-buffer))
866
867 ;; Run extra-hooks and revert directory. 864 ;; Run extra-hooks and revert directory.
868 (dired-extra-startup) 865 (dired-extra-startup)
869 (dired-revert))) 866 (dired-revert)))
@@ -1134,10 +1131,9 @@ See `dired-guess-shell-alist-user'."
1134 1131
1135 ;; Return commands or nil if flist is still non-nil. 1132 ;; Return commands or nil if flist is still non-nil.
1136 ;; Evaluate the commands in order that any logical testing will be done. 1133 ;; Evaluate the commands in order that any logical testing will be done.
1137 (cond ((not (cdr cmds)) 1134 (if (cdr cmds)
1138 (eval (car cmds))) ; single command 1135 (mapcar #'eval cmds)
1139 (t 1136 (eval (car cmds))))) ; single command
1140 (mapcar (function eval) cmds)))))
1141 1137
1142(defun dired-guess-shell-command (prompt files) 1138(defun dired-guess-shell-command (prompt files)
1143 "Ask user with PROMPT for a shell command, guessing a default from FILES." 1139 "Ask user with PROMPT for a shell command, guessing a default from FILES."
@@ -1207,8 +1203,7 @@ results in
1207 ;; Find common initial file name components: 1203 ;; Find common initial file name components:
1208 (let (next) 1204 (let (next)
1209 (while (and (setq next (string-match "/" file1 index)) 1205 (while (and (setq next (string-match "/" file1 index))
1210 (setq next (1+ next)) 1206 (< (setq next (1+ next)) (min len1 len2))
1211 (< next (min len1 len2))
1212 ;; For the comparison, both substrings must end in 1207 ;; For the comparison, both substrings must end in
1213 ;; `/', so NEXT is *one plus* the result of the 1208 ;; `/', so NEXT is *one plus* the result of the
1214 ;; string-match. 1209 ;; string-match.
@@ -1233,9 +1228,8 @@ results in
1233 (setq count (1+ count) 1228 (setq count (1+ count)
1234 start (1+ start))) 1229 start (1+ start)))
1235 ;; ... and prepend a "../" for each slash found: 1230 ;; ... and prepend a "../" for each slash found:
1236 (while (> count 0) 1231 (dotimes (n count)
1237 (setq count (1- count) 1232 (setq name1 (concat "../" name1)))))
1238 name1 (concat "../" name1)))))
1239 (make-symbolic-link 1233 (make-symbolic-link
1240 (directory-file-name name1) ; must not link to foo/ 1234 (directory-file-name name1) ; must not link to foo/
1241 ; (trailing slash!) 1235 ; (trailing slash!)
@@ -1255,7 +1249,7 @@ not absolute ones like
1255 1249
1256For absolute symlinks, use \\[dired-do-symlink]." 1250For absolute symlinks, use \\[dired-do-symlink]."
1257 (interactive "P") 1251 (interactive "P")
1258 (dired-do-create-files 'relsymlink (function dired-make-relative-symlink) 1252 (dired-do-create-files 'relsymlink #'dired-make-relative-symlink
1259 "RelSymLink" arg dired-keep-marker-relsymlink)) 1253 "RelSymLink" arg dired-keep-marker-relsymlink))
1260 1254
1261(defun dired-do-relsymlink-regexp (regexp newname &optional arg whole-name) 1255(defun dired-do-relsymlink-regexp (regexp newname &optional arg whole-name)
@@ -1264,7 +1258,7 @@ See functions `dired-do-rename-regexp' and `dired-do-relsymlink'
1264for more info." 1258for more info."
1265 (interactive (dired-mark-read-regexp "RelSymLink")) 1259 (interactive (dired-mark-read-regexp "RelSymLink"))
1266 (dired-do-create-files-regexp 1260 (dired-do-create-files-regexp
1267 (function dired-make-relative-symlink) 1261 #'dired-make-relative-symlink
1268 "RelSymLink" arg regexp newname whole-name dired-keep-marker-relsymlink)) 1262 "RelSymLink" arg regexp newname whole-name dired-keep-marker-relsymlink))
1269 1263
1270 1264
@@ -1304,50 +1298,36 @@ displayed this way is restricted by the height of the current window and
1304 1298
1305To keep dired buffer displayed, type \\[split-window-vertically] first. 1299To keep dired buffer displayed, type \\[split-window-vertically] first.
1306To display just marked files, type \\[delete-other-windows] first." 1300To display just marked files, type \\[delete-other-windows] first."
1307
1308 (interactive "P") 1301 (interactive "P")
1309 (dired-simultaneous-find-file (dired-get-marked-files) noselect)) 1302 (dired-simultaneous-find-file (dired-get-marked-files) noselect))
1310 1303
1311(defun dired-simultaneous-find-file (file-list noselect) 1304(defun dired-simultaneous-find-file (file-list noselect)
1312
1313 "Visit all files in FILE-LIST and display them simultaneously. 1305 "Visit all files in FILE-LIST and display them simultaneously.
1314The current window is split across all files in FILE-LIST, as evenly as 1306The current window is split across all files in FILE-LIST, as evenly as
1315possible. Remaining lines go to the bottom-most window. The number of 1307possible. Remaining lines go to the bottom-most window. The number of
1316files that can be displayed this way is restricted by the height of the 1308files that can be displayed this way is restricted by the height of the
1317current window and the variable `window-min-height'. With non-nil 1309current window and the variable `window-min-height'. With non-nil
1318NOSELECT the files are merely found but not selected." 1310NOSELECT the files are merely found but not selected."
1319
1320 ;; We don't make this function interactive because it is usually too clumsy 1311 ;; We don't make this function interactive because it is usually too clumsy
1321 ;; to specify FILE-LIST interactively unless via dired. 1312 ;; to specify FILE-LIST interactively unless via dired.
1322
1323 (let (size) 1313 (let (size)
1324
1325 (if noselect 1314 (if noselect
1326 ;; Do not select the buffer. 1315 ;; Do not select the buffer.
1327 (find-file-noselect (car file-list)) 1316 (find-file-noselect (car file-list))
1328
1329 ;; We will have to select the buffer. Calculate and check window size. 1317 ;; We will have to select the buffer. Calculate and check window size.
1330 (setq size (/ (window-height) (length file-list))) 1318 (setq size (/ (window-height) (length file-list)))
1331 (or (<= window-min-height size) 1319 (or (<= window-min-height size)
1332 (error "Too many files to visit simultaneously. Try C-u prefix")) 1320 (error "Too many files to visit simultaneously. Try C-u prefix"))
1333 (find-file (car file-list))) 1321 (find-file (car file-list)))
1334
1335 ;; Decrement. 1322 ;; Decrement.
1336 (setq file-list (cdr file-list)) 1323 (dolist (file (cdr file-list))
1337
1338 (while file-list
1339
1340 (if noselect 1324 (if noselect
1341 ;; Do not select the buffer. 1325 ;; Do not select the buffer.
1342 (find-file-noselect (car file-list)) 1326 (find-file-noselect file)
1343
1344 ;; Vertically split off a window of desired size. Upper window will 1327 ;; Vertically split off a window of desired size. Upper window will
1345 ;; have SIZE lines. Select lower (larger) window. We split it again. 1328 ;; have SIZE lines. Select lower (larger) window. We split it again.
1346 (select-window (split-window nil size)) 1329 (select-window (split-window nil size))
1347 (find-file (car file-list))) 1330 (find-file file)))))
1348
1349 ;; Decrement.
1350 (setq file-list (cdr file-list)))))
1351 1331
1352 1332
1353;;; MISCELLANEOUS COMMANDS. 1333;;; MISCELLANEOUS COMMANDS.
@@ -1431,7 +1411,7 @@ Otherwise obeys the value of `dired-vm-read-only-folders'."
1431 (equal dired-directory dirname)))) 1411 (equal dired-directory dirname))))
1432 ;; We don't want to switch to the same buffer--- 1412 ;; We don't want to switch to the same buffer---
1433 (setq buffers (delq cur-buf buffers));;need setq with delq 1413 (setq buffers (delq cur-buf buffers));;need setq with delq
1434 (or (car (sort buffers (function dired-buffer-more-recently-used-p))) 1414 (or (car (sort buffers #'dired-buffer-more-recently-used-p))
1435 ;; ---unless it's the only possibility: 1415 ;; ---unless it's the only possibility:
1436 (and cur-buf-matches cur-buf))) 1416 (and cur-buf-matches cur-buf)))
1437 (dired-old-find-buffer-nocreate dirname mode))) 1417 (dired-old-find-buffer-nocreate dirname mode)))
@@ -1522,65 +1502,65 @@ to mark all zero length files."
1522 ;; there is no file line. Upon success, all variables are set, either 1502 ;; there is no file line. Upon success, all variables are set, either
1523 ;; to nil or the appropriate value, so they need not be initialized. 1503 ;; to nil or the appropriate value, so they need not be initialized.
1524 ;; Moves point within the current line. 1504 ;; Moves point within the current line.
1525 (if (dired-move-to-filename) 1505 (dired-move-to-filename)
1526 (let (pos 1506 (let (pos
1527 (mode-len 10) ; length of mode string 1507 (mode-len 10) ; length of mode string
1528 ;; like in dired.el, but with subexpressions \1=inode, \2=s: 1508 ;; like in dired.el, but with subexpressions \1=inode, \2=s:
1529 (dired-re-inode-size "\\s *\\([0-9]*\\)\\s *\\([0-9]*\\) ?")) 1509 (dired-re-inode-size "\\s *\\([0-9]*\\)\\s *\\([0-9]*\\) ?"))
1530 (beginning-of-line) 1510 (beginning-of-line)
1531 (forward-char 2) 1511 (forward-char 2)
1532 (if (looking-at dired-re-inode-size) 1512 (if (looking-at dired-re-inode-size)
1533 (progn 1513 (progn
1534 (goto-char (match-end 0)) 1514 (goto-char (match-end 0))
1535 (setq inode (string-to-number (buffer-substring (match-beginning 1) 1515 (setq inode (string-to-number
1536 (match-end 1))) 1516 (buffer-substring (match-beginning 1)
1537 s (string-to-number (buffer-substring (match-beginning 2) 1517 (match-end 1)))
1538 (match-end 2))))) 1518 s (string-to-number
1539 (setq inode nil 1519 (buffer-substring (match-beginning 2)
1540 s nil)) 1520 (match-end 2)))))
1541 (setq mode (buffer-substring (point) (+ mode-len (point)))) 1521 (setq inode nil
1542 (forward-char mode-len) 1522 s nil))
1543 (setq nlink (read (current-buffer))) 1523 (setq mode (buffer-substring (point) (+ mode-len (point))))
1544 ;; Karsten Wenger <kw@cis.uni-muenchen.de> fixed uid. 1524 (forward-char mode-len)
1545 (setq uid (buffer-substring (1+ (point)) 1525 (setq nlink (read (current-buffer)))
1546 (progn (forward-word 1) (point)))) 1526 ;; Karsten Wenger <kw@cis.uni-muenchen.de> fixed uid.
1547 (re-search-forward directory-listing-before-filename-regexp) 1527 (setq uid (buffer-substring (1+ (point))
1548 (goto-char (match-beginning 1)) 1528 (progn (forward-word 1) (point))))
1549 (forward-char -1) 1529 (re-search-forward directory-listing-before-filename-regexp)
1550 (setq size (string-to-number (buffer-substring (save-excursion 1530 (goto-char (match-beginning 1))
1551 (backward-word 1) 1531 (forward-char -1)
1552 (setq pos (point))) 1532 (setq size (string-to-number
1553 (point)))) 1533 (buffer-substring (save-excursion
1554 (goto-char pos) 1534 (backward-word 1)
1555 (backward-word 1) 1535 (setq pos (point)))
1556 ;; if no gid is displayed, gid will be set to uid 1536 (point))))
1557 ;; but user will then not reference it anyway in PREDICATE. 1537 (goto-char pos)
1558 (setq gid (buffer-substring (save-excursion 1538 (backward-word 1)
1559 (forward-word 1) (point)) 1539 ;; if no gid is displayed, gid will be set to uid
1560 (point)) 1540 ;; but user will then not reference it anyway in PREDICATE.
1561 time (buffer-substring (match-beginning 1) 1541 (setq gid (buffer-substring (save-excursion
1562 (1- (dired-move-to-filename))) 1542 (forward-word 1) (point))
1563 name (buffer-substring (point) 1543 (point))
1564 (or 1544 time (buffer-substring (match-beginning 1)
1565 (dired-move-to-end-of-filename t) 1545 (1- (dired-move-to-filename)))
1566 (point))) 1546 name (buffer-substring (point)
1567 sym (progn 1547 (or
1568 (if (looking-at " -> ") 1548 (dired-move-to-end-of-filename t)
1569 (buffer-substring 1549 (point)))
1570 (progn (forward-char 4) (point)) 1550 sym (if (looking-at " -> ")
1571 (progn (end-of-line) (point))) 1551 (buffer-substring (progn (forward-char 4) (point))
1572 ""))) 1552 (line-end-position))
1573 t) 1553 ""))
1574 nil) 1554 t)
1575 (eval predicate))) 1555 (eval predicate)))
1576 (format "'%s file" predicate)))) 1556 (format "'%s file" predicate))))
1577 1557
1578 1558
1579;;; FIND FILE AT POINT. 1559;;; FIND FILE AT POINT.
1580 1560
1581(defcustom dired-x-hands-off-my-keys t 1561(defcustom dired-x-hands-off-my-keys t
1582 "Non-nil means don't bind `dired-x-find-file' over `find-file' on keyboard. 1562 "Non-nil means don't remap `find-file' to `dired-x-find-file'.
1583Similarly for `dired-x-find-file-other-window' over `find-file-other-window'. 1563Similarly for `find-file-other-window' and `dired-x-find-file-other-window'.
1584If you change this variable without using \\[customize] after `dired-x.el' 1564If you change this variable without using \\[customize] after `dired-x.el'
1585is loaded then call \\[dired-x-bind-find-file]." 1565is loaded then call \\[dired-x-bind-find-file]."
1586 :type 'boolean 1566 :type 'boolean
@@ -1590,62 +1570,37 @@ is loaded then call \\[dired-x-bind-find-file]."
1590 (dired-x-bind-find-file)) 1570 (dired-x-bind-find-file))
1591 :group 'dired-x) 1571 :group 'dired-x)
1592 1572
1593;; Bind `dired-x-find-file{-other-window}' over wherever
1594;; `find-file{-other-window}' is bound?
1595(defun dired-x-bind-find-file () 1573(defun dired-x-bind-find-file ()
1596 "Bind `dired-x-find-file' in place of `find-file' \(or reverse\). 1574 "Bind `dired-x-find-file' in place of `find-file' (or vice-versa).
1597Similarly for `dired-x-find-file-other-window' and `find-file-other-window'. 1575Similarly for `dired-x-find-file-other-window' and `find-file-other-window'.
1598Binding direction based on `dired-x-hands-off-my-keys'. 1576Binding direction based on `dired-x-hands-off-my-keys'."
1599This function is part of `after-init-hook'."
1600 (interactive) 1577 (interactive)
1601 (if (called-interactively-p 'interactive) 1578 (if (called-interactively-p 'interactive)
1602 (setq dired-x-hands-off-my-keys 1579 (setq dired-x-hands-off-my-keys
1603 (not (y-or-n-p "Bind dired-x-find-file over find-file? ")))) 1580 (not (y-or-n-p "Bind dired-x-find-file over find-file? "))))
1604 (cond ((not dired-x-hands-off-my-keys) 1581 (define-key (current-global-map) [remap find-file]
1605 (substitute-key-definition 'find-file 1582 (if (not dired-x-hands-off-my-keys) 'dired-x-find-file))
1606 'dired-x-find-file 1583 (define-key (current-global-map) [remap find-file-other-window]
1607 (current-global-map)) 1584 (if (not dired-x-hands-off-my-keys) 'dired-x-find-file-other-window)))
1608 (substitute-key-definition 'find-file-other-window 1585
1609 'dired-x-find-file-other-window 1586;; Now call it so binding is correct. This could go in the :initialize
1610 (current-global-map))) 1587;; slot, but then dired-x-bind-find-file has to be defined before the
1611 (t 1588;; defcustom, and we get free variable warnings.
1612 (substitute-key-definition 'dired-x-find-file
1613 'find-file
1614 (current-global-map))
1615 (substitute-key-definition 'dired-x-find-file-other-window
1616 'find-file-other-window
1617 (current-global-map))))
1618 ;; Clear mini-buffer.
1619 (message nil))
1620
1621;; Now call it so binding is correct and put on `after-init-hook' in case
1622;; user changes binding.
1623(dired-x-bind-find-file) 1589(dired-x-bind-find-file)
1624(add-hook 'after-init-hook 'dired-x-bind-find-file)
1625 1590
1626(defun dired-x-find-file (filename) 1591(defun dired-x-find-file (filename)
1627 "Edit file FILENAME. 1592 "Edit file FILENAME.
1628May create a new window, or reuse an existing one. 1593Like `find-file', except that when called interactively with a
1629See the function `display-buffer'. 1594prefix argument, it offers the filename near point as a default."
1630
1631Identical to `find-file' except when called interactively, with a prefix arg
1632\(e.g., \\[universal-argument]\), in which case it guesses filename near point.
1633Useful for editing file mentioned in buffer you are viewing,
1634or to test if that file exists. Use minibuffer after snatching filename."
1635 (interactive (list (dired-x-read-filename-at-point "Find file: "))) 1595 (interactive (list (dired-x-read-filename-at-point "Find file: ")))
1636 (find-file (expand-file-name filename))) 1596 (find-file filename))
1637 1597
1638(defun dired-x-find-file-other-window (filename) 1598(defun dired-x-find-file-other-window (filename)
1639 "Edit file FILENAME, in another window. 1599 "Edit file FILENAME, in another window.
1640May create a new window, or reuse an existing one. 1600Like `find-file-other-window', except that when called interactively with
1641See the function `display-buffer'. 1601a prefix argument, when it offers the filename near point as a default."
1642
1643Identical to `find-file-other-window' except when called interactively, with
1644a prefix arg \(e.g., \\[universal-argument]\), in which case it guesses filename near point.
1645Useful for editing file mentioned in buffer you are viewing,
1646or to test if that file exists. Use minibuffer after snatching filename."
1647 (interactive (list (dired-x-read-filename-at-point "Find file: "))) 1602 (interactive (list (dired-x-read-filename-at-point "Find file: ")))
1648 (find-file-other-window (expand-file-name filename))) 1603 (find-file-other-window filename))
1649 1604
1650;;; Internal functions. 1605;;; Internal functions.
1651 1606
@@ -1653,14 +1608,14 @@ or to test if that file exists. Use minibuffer after snatching filename."
1653(defun dired-filename-at-point () 1608(defun dired-filename-at-point ()
1654 "Return the filename closest to point, expanded. 1609 "Return the filename closest to point, expanded.
1655Point should be in or after a filename." 1610Point should be in or after a filename."
1656 (let ((filename-chars "-.[:alnum:]_/:$+@") 1611 (save-excursion
1657 start end filename prefix) 1612 ;; First see if just past a filename.
1658 (save-excursion 1613 (or (eobp) ; why?
1659 ;; First see if just past a filename. 1614 (when (looking-at "[] \t\n[{}()]") ; whitespace or some parens
1660 (or (eobp) ; why? 1615 (skip-chars-backward " \n\t\r({[]})")
1661 (when (looking-at "[] \t\n[{}()]") ; whitespace or some parens 1616 (or (bobp) (backward-char 1))))
1662 (skip-chars-backward " \n\t\r({[]})") 1617 (let ((filename-chars "-.[:alnum:]_/:$+@")
1663 (or (bobp) (backward-char 1)))) 1618 start prefix)
1664 (if (looking-at (format "[%s]" filename-chars)) 1619 (if (looking-at (format "[%s]" filename-chars))
1665 (progn 1620 (progn
1666 (skip-chars-backward filename-chars) 1621 (skip-chars-backward filename-chars)