diff options
| author | Richard M. Stallman | 2002-06-26 08:40:22 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 2002-06-26 08:40:22 +0000 |
| commit | 8f6490b8df1e8846d0c62faae0654cadca003b0b (patch) | |
| tree | 683478fe354aff3584f3e3ad3c6afe9aadf31f14 | |
| parent | 6c488ddb7988ec0c64a3a3b98fa61938c37df568 (diff) | |
| download | emacs-8f6490b8df1e8846d0c62faae0654cadca003b0b.tar.gz emacs-8f6490b8df1e8846d0c62faae0654cadca003b0b.zip | |
Delete changes not supposed to be installed yet.
| -rw-r--r-- | lisp/dired.el | 325 |
1 files changed, 159 insertions, 166 deletions
diff --git a/lisp/dired.el b/lisp/dired.el index a3a9d7f7cee..16333a45858 100644 --- a/lisp/dired.el +++ b/lisp/dired.el | |||
| @@ -72,9 +72,6 @@ some of the `ls' switches are not supported; see the doc string of | |||
| 72 | "/etc/chown")) | 72 | "/etc/chown")) |
| 73 | "Name of chown command (usually `chown' or `/etc/chown').") | 73 | "Name of chown command (usually `chown' or `/etc/chown').") |
| 74 | 74 | ||
| 75 | (defvar dired-use-ls-dired (not (not (string-match "gnu" system-configuration))) | ||
| 76 | "Non-nil means Dired should use `ls --dired'.") | ||
| 77 | |||
| 78 | (defvar dired-chmod-program "chmod" | 75 | (defvar dired-chmod-program "chmod" |
| 79 | "Name of chmod command (usually `chmod').") | 76 | "Name of chmod command (usually `chmod').") |
| 80 | 77 | ||
| @@ -220,10 +217,9 @@ This is what the `do' commands look for and what the `mark' commands store.") | |||
| 220 | (defvar dired-file-version-alist) | 217 | (defvar dired-file-version-alist) |
| 221 | 218 | ||
| 222 | (defvar dired-directory nil | 219 | (defvar dired-directory nil |
| 223 | "The directory name or wildcard spec that this Dired directory lists. | 220 | "The directory name or shell wildcard that was used as argument to `ls'. |
| 224 | Local to each dired buffer. May be a list, in which case the car is the | 221 | Local to each dired buffer. May be a list, in which case the car is the |
| 225 | directory name and the cdr is the list of files to include. | 222 | directory name and the cdr is the actual files to list.") |
| 226 | The directory name must be absolute, but need not be fully expanded.") | ||
| 227 | 223 | ||
| 228 | (defvar dired-actual-switches nil | 224 | (defvar dired-actual-switches nil |
| 229 | "The value of `dired-listing-switches' used to make this buffer's text.") | 225 | "The value of `dired-listing-switches' used to make this buffer's text.") |
| @@ -424,6 +420,9 @@ Optional third argument FILTER, if non-nil, is a function to select | |||
| 424 | (push file result))) | 420 | (push file result))) |
| 425 | result))) | 421 | result))) |
| 426 | 422 | ||
| 423 | ;; Function dired-ls is redefinable for VMS, ange-ftp, Prospero or | ||
| 424 | ;; other special applications. | ||
| 425 | |||
| 427 | ;; The dired command | 426 | ;; The dired command |
| 428 | 427 | ||
| 429 | (defun dired-read-dir-and-switches (str) | 428 | (defun dired-read-dir-and-switches (str) |
| @@ -512,17 +511,14 @@ If DIRNAME is already in a dired buffer, that buffer is used without refresh." | |||
| 512 | ;; like find-file does. | 511 | ;; like find-file does. |
| 513 | ;; Optional argument MODE is passed to dired-find-buffer-nocreate, | 512 | ;; Optional argument MODE is passed to dired-find-buffer-nocreate, |
| 514 | ;; see there. | 513 | ;; see there. |
| 515 | (let* (dirname | 514 | (let* ((dirname (if (consp dir-or-list) (car dir-or-list) dir-or-list)) |
| 516 | buffer | 515 | ;; The following line used to use dir-or-list. |
| 516 | ;; That never found an existing buffer, in the case | ||
| 517 | ;; where it is a list. | ||
| 518 | (buffer (dired-find-buffer-nocreate dirname mode)) | ||
| 517 | ;; note that buffer already is in dired-mode, if found | 519 | ;; note that buffer already is in dired-mode, if found |
| 518 | new-buffer-p | 520 | (new-buffer-p (not buffer)) |
| 519 | (old-buf (current-buffer))) | 521 | (old-buf (current-buffer))) |
| 520 | (if (consp dir-or-list) | ||
| 521 | (setq dirname (car dir-or-list)) | ||
| 522 | (setq dirname dir-or-list)) | ||
| 523 | ;; Look for an existing buffer. | ||
| 524 | (setq buffer (dired-find-buffer-nocreate dirname mode) | ||
| 525 | new-buffer-p (null buffer)) | ||
| 526 | (or buffer | 522 | (or buffer |
| 527 | (let ((default-major-mode 'fundamental-mode)) | 523 | (let ((default-major-mode 'fundamental-mode)) |
| 528 | ;; We don't want default-major-mode to run hooks and set auto-fill | 524 | ;; We don't want default-major-mode to run hooks and set auto-fill |
| @@ -533,7 +529,8 @@ If DIRNAME is already in a dired buffer, that buffer is used without refresh." | |||
| 533 | (if (not new-buffer-p) ; existing buffer ... | 529 | (if (not new-buffer-p) ; existing buffer ... |
| 534 | (cond (switches ; ... but new switches | 530 | (cond (switches ; ... but new switches |
| 535 | ;; file list may have changed | 531 | ;; file list may have changed |
| 536 | (setq dired-directory dir-or-list) | 532 | (if (consp dir-or-list) |
| 533 | (setq dired-directory dir-or-list)) | ||
| 537 | ;; this calls dired-revert | 534 | ;; this calls dired-revert |
| 538 | (dired-sort-other switches)) | 535 | (dired-sort-other switches)) |
| 539 | ;; If directory has changed on disk, offer to revert. | 536 | ;; If directory has changed on disk, offer to revert. |
| @@ -556,16 +553,21 @@ If DIRNAME is already in a dired buffer, that buffer is used without refresh." | |||
| 556 | (file-name-directory dirname)) | 553 | (file-name-directory dirname)) |
| 557 | (or switches (setq switches dired-listing-switches)) | 554 | (or switches (setq switches dired-listing-switches)) |
| 558 | (if mode (funcall mode) | 555 | (if mode (funcall mode) |
| 559 | (dired-mode dir-or-list switches)) | 556 | (dired-mode dirname switches)) |
| 560 | ;; default-directory and dired-actual-switches are set now | 557 | ;; default-directory and dired-actual-switches are set now |
| 561 | ;; (buffer-local), so we can call dired-readin: | 558 | ;; (buffer-local), so we can call dired-readin: |
| 562 | (let ((failed t)) | 559 | (let ((failed t)) |
| 563 | (unwind-protect | 560 | (unwind-protect |
| 564 | (progn (dired-readin) | 561 | (progn (dired-readin dir-or-list buffer) |
| 565 | (setq failed nil)) | 562 | (setq failed nil)) |
| 566 | ;; dired-readin can fail if parent directories are inaccessible. | 563 | ;; dired-readin can fail if parent directories are inaccessible. |
| 567 | ;; Don't leave an empty buffer around in that case. | 564 | ;; Don't leave an empty buffer around in that case. |
| 568 | (if failed (kill-buffer buffer)))) | 565 | (if failed (kill-buffer buffer)))) |
| 566 | ;; No need to narrow since the whole buffer contains just | ||
| 567 | ;; dired-readin's output, nothing else. The hook can | ||
| 568 | ;; successfully use dired functions (e.g. dired-get-filename) | ||
| 569 | ;; as the subdir-alist has been built in dired-readin. | ||
| 570 | (run-hooks 'dired-after-readin-hook) | ||
| 569 | (goto-char (point-min)) | 571 | (goto-char (point-min)) |
| 570 | (dired-initial-position dirname)) | 572 | (dired-initial-position dirname)) |
| 571 | (set-buffer old-buf) | 573 | (set-buffer old-buf) |
| @@ -581,7 +583,6 @@ If DIRNAME is already in a dired buffer, that buffer is used without refresh." | |||
| 581 | ;; This differs from dired-buffers-for-dir in that it does not consider | 583 | ;; This differs from dired-buffers-for-dir in that it does not consider |
| 582 | ;; subdirs of default-directory and searches for the first match only. | 584 | ;; subdirs of default-directory and searches for the first match only. |
| 583 | ;; Also, the major mode must be MODE. | 585 | ;; Also, the major mode must be MODE. |
| 584 | (setq dirname (expand-file-name dirname)) | ||
| 585 | (let (found (blist dired-buffers)) ; was (buffer-list) | 586 | (let (found (blist dired-buffers)) ; was (buffer-list) |
| 586 | (or mode (setq mode 'dired-mode)) | 587 | (or mode (setq mode 'dired-mode)) |
| 587 | (while blist | 588 | (while blist |
| @@ -590,11 +591,9 @@ If DIRNAME is already in a dired buffer, that buffer is used without refresh." | |||
| 590 | (save-excursion | 591 | (save-excursion |
| 591 | (set-buffer (cdr (car blist))) | 592 | (set-buffer (cdr (car blist))) |
| 592 | (if (and (eq major-mode mode) | 593 | (if (and (eq major-mode mode) |
| 593 | (equal dirname | 594 | (if (consp dired-directory) |
| 594 | (expand-file-name | 595 | (equal (car dired-directory) dirname) |
| 595 | (if (consp dired-directory) | 596 | (equal dired-directory dirname))) |
| 596 | (car dired-directory) | ||
| 597 | dired-directory)))) | ||
| 598 | (setq found (cdr (car blist)) | 597 | (setq found (cdr (car blist)) |
| 599 | blist nil) | 598 | blist nil) |
| 600 | (setq blist (cdr blist)))))) | 599 | (setq blist (cdr blist)))))) |
| @@ -606,30 +605,40 @@ If DIRNAME is already in a dired buffer, that buffer is used without refresh." | |||
| 606 | ;; dired-readin differs from dired-insert-subdir in that it accepts | 605 | ;; dired-readin differs from dired-insert-subdir in that it accepts |
| 607 | ;; wildcards, erases the buffer, and builds the subdir-alist anew | 606 | ;; wildcards, erases the buffer, and builds the subdir-alist anew |
| 608 | ;; (including making it buffer-local and clearing it first). | 607 | ;; (including making it buffer-local and clearing it first). |
| 609 | (defun dired-readin () | 608 | (defun dired-readin (dir-or-list buffer) |
| 610 | ;; default-directory and dired-actual-switches must be buffer-local | 609 | ;; default-directory and dired-actual-switches must be buffer-local |
| 611 | ;; and initialized by now. | 610 | ;; and initialized by now. |
| 612 | (let (dirname) | 611 | ;; Thus we can test (equal default-directory dirname) instead of |
| 613 | (if (consp dired-directory) | 612 | ;; (file-directory-p dirname) and save a filesystem transaction. |
| 614 | (setq dirname (car dired-directory)) | 613 | ;; Also, we can run this hook which may want to modify the switches |
| 615 | (setq dirname dired-directory)) | 614 | ;; based on default-directory, e.g. with ange-ftp to a SysV host |
| 615 | ;; where ls won't understand -Al switches. | ||
| 616 | (let (dirname | ||
| 617 | (indent-tabs-mode nil)) | ||
| 618 | (if (consp dir-or-list) | ||
| 619 | (setq dirname (car dir-or-list)) | ||
| 620 | (setq dirname dir-or-list)) | ||
| 616 | (setq dirname (expand-file-name dirname)) | 621 | (setq dirname (expand-file-name dirname)) |
| 622 | (if (consp dir-or-list) | ||
| 623 | (setq dir-or-list (cons dirname (cdr dir-or-list)))) | ||
| 624 | (run-hooks 'dired-before-readin-hook) | ||
| 617 | (save-excursion | 625 | (save-excursion |
| 618 | ;; This hook which may want to modify dired-actual-switches | ||
| 619 | ;; based on dired-directory, e.g. with ange-ftp to a SysV host | ||
| 620 | ;; where ls won't understand -Al switches. | ||
| 621 | (run-hooks 'dired-before-readin-hook) | ||
| 622 | (message "Reading directory %s..." dirname) | 626 | (message "Reading directory %s..." dirname) |
| 623 | (if (consp buffer-undo-list) | 627 | (set-buffer buffer) |
| 624 | (setq buffer-undo-list nil)) | 628 | (let (buffer-read-only (failed t)) |
| 625 | (let (buffer-read-only | ||
| 626 | ;; Don't make undo entries for readin. | ||
| 627 | (buffer-undo-list t)) | ||
| 628 | (widen) | 629 | (widen) |
| 629 | (erase-buffer) | 630 | (erase-buffer) |
| 630 | (dired-readin-insert)) | 631 | (dired-readin-insert dir-or-list) |
| 632 | (indent-rigidly (point-min) (point-max) 2) | ||
| 633 | ;; We need this to make the root dir have a header line as all | ||
| 634 | ;; other subdirs have: | ||
| 635 | (goto-char (point-min)) | ||
| 636 | (if (not (looking-at "^ /.*:$")) | ||
| 637 | (dired-insert-headerline default-directory)) | ||
| 638 | ;; can't run dired-after-readin-hook here, it may depend on the subdir | ||
| 639 | ;; alist to be OK. | ||
| 640 | ) | ||
| 631 | (message "Reading directory %s...done" dirname) | 641 | (message "Reading directory %s...done" dirname) |
| 632 | (goto-char (point-min)) | ||
| 633 | ;; Must first make alist buffer local and set it to nil because | 642 | ;; Must first make alist buffer local and set it to nil because |
| 634 | ;; dired-build-subdir-alist will call dired-clear-alist first | 643 | ;; dired-build-subdir-alist will call dired-clear-alist first |
| 635 | (set (make-local-variable 'dired-subdir-alist) nil) | 644 | (set (make-local-variable 'dired-subdir-alist) nil) |
| @@ -637,56 +646,56 @@ If DIRNAME is already in a dired buffer, that buffer is used without refresh." | |||
| 637 | (let ((attributes (file-attributes dirname))) | 646 | (let ((attributes (file-attributes dirname))) |
| 638 | (if (eq (car attributes) t) | 647 | (if (eq (car attributes) t) |
| 639 | (set-visited-file-modtime (nth 5 attributes)))) | 648 | (set-visited-file-modtime (nth 5 attributes)))) |
| 640 | (set-buffer-modified-p nil) | 649 | (if (consp buffer-undo-list) |
| 641 | ;; No need to narrow since the whole buffer contains just | 650 | (setq buffer-undo-list nil)) |
| 642 | ;; dired-readin's output, nothing else. The hook can | 651 | (set-buffer-modified-p nil)))) |
| 643 | ;; successfully use dired functions (e.g. dired-get-filename) | ||
| 644 | ;; as the subdir-alist has been built in dired-readin. | ||
| 645 | (run-hooks 'dired-after-readin-hook)))) | ||
| 646 | 652 | ||
| 647 | ;; Subroutines of dired-readin | 653 | ;; Subroutines of dired-readin |
| 648 | 654 | ||
| 649 | (defun dired-readin-insert () | 655 | (defun dired-readin-insert (dir-or-list) |
| 650 | ;; Insert listing for the specified dir (and maybe file list) | 656 | ;; Just insert listing for the passed-in directory or |
| 651 | ;; already in dired-directory, assuming a clean buffer. | 657 | ;; directory-and-file list, assuming a clean buffer. |
| 652 | (let (dir file-list) | 658 | (let (dirname) |
| 653 | (if (consp dired-directory) | 659 | (if (consp dir-or-list) |
| 654 | (setq dir (car dired-directory) | 660 | (setq dirname (car dir-or-list)) |
| 655 | file-list (cdr dired-directory)) | 661 | (setq dirname dir-or-list)) |
| 656 | (setq dir dired-directory | 662 | ;; Expand before comparing in case one or both have been abbreviated. |
| 657 | file-list nil)) | 663 | (if (and (equal (expand-file-name default-directory) |
| 658 | (if (and (equal "" (file-name-nondirectory dir)) | 664 | (expand-file-name dirname)) |
| 659 | (not file-list)) | 665 | (not (consp dir-or-list))) |
| 660 | ;; If we are reading a whole single directory... | 666 | ;; If we are reading a whole single directory... |
| 661 | (dired-insert-directory dir dired-actual-switches nil nil t) | 667 | (dired-insert-directory dir-or-list dired-actual-switches nil t) |
| 662 | (if (not (file-readable-p | 668 | (if (not (file-readable-p |
| 663 | (directory-file-name (file-name-directory dir)))) | 669 | (directory-file-name (file-name-directory dirname)))) |
| 664 | (error "Directory %s inaccessible or nonexistent" dir) | 670 | (error "Directory %s inaccessible or nonexistent" dirname) |
| 665 | ;; Else treat it as a wildcard spec | 671 | ;; Else assume it contains wildcards, |
| 666 | ;; unless we have an explicit list of files. | 672 | ;; unless it is an explicit list of files. |
| 667 | (dired-insert-directory dir dired-actual-switches | 673 | (dired-insert-directory dir-or-list dired-actual-switches |
| 668 | file-list (not file-list) t))))) | 674 | (not (listp dir-or-list))) |
| 669 | 675 | (or (consp dir-or-list) | |
| 670 | (defun dired-insert-directory (dir switches &optional file-list wildcard hdr) | 676 | (save-excursion ;; insert wildcard instead of total line: |
| 671 | "Insert a directory listing of DIR, Dired style. | 677 | (goto-char (point-min)) |
| 672 | Use SWITCHES to make the listings. | 678 | (insert "wildcard " (file-name-nondirectory dirname) "\n"))))))) |
| 673 | If FILE-LIST is non-nil, list only those files. | 679 | |
| 674 | Otherwise, if WILDCARD is non-nil, expand wildcards; | 680 | (defun dired-insert-directory (dir-or-list switches &optional wildcard full-p) |
| 675 | in that case, DIR should be a file name that uses wildcards. | 681 | ;; Do the right thing whether dir-or-list is atomic or not. If it is, |
| 676 | In other cases, DIR should be a directory name or a directory filename. | 682 | ;; inset all files listed in the cdr (the car is the passed-in directory |
| 677 | If HDR is non-nil, insert a header line with the directory name." | 683 | ;; list). |
| 678 | (let ((opoint (point)) | 684 | (let ((opoint (point)) |
| 679 | (process-environment (copy-sequence process-environment)) | 685 | (process-environment (copy-sequence process-environment)) |
| 680 | end) | 686 | end) |
| 681 | (if dired-use-ls-dired | ||
| 682 | (setq switches (concat "--dired " switches))) | ||
| 683 | ;; We used to specify the C locale here, to force English month names; | 687 | ;; We used to specify the C locale here, to force English month names; |
| 684 | ;; but this should not be necessary any more, | 688 | ;; but this should not be necessary any more, |
| 685 | ;; with the new value of dired-move-to-filename-regexp. | 689 | ;; with the new value of dired-move-to-filename-regexp. |
| 686 | (if file-list | 690 | (if (consp dir-or-list) |
| 687 | (dolist (f file-list) | 691 | ;; In this case, use the file names in the cdr |
| 688 | (insert-directory f switches nil nil)) | 692 | ;; exactly as originally given to dired-noselect. |
| 689 | (insert-directory dir switches wildcard (not wildcard))) | 693 | (mapcar |
| 694 | (function (lambda (x) (insert-directory x switches wildcard full-p))) | ||
| 695 | (cdr dir-or-list)) | ||
| 696 | ;; Expand the file name here because it may have been abbreviated | ||
| 697 | ;; in dired-noselect. | ||
| 698 | (insert-directory (expand-file-name dir-or-list) switches wildcard full-p)) | ||
| 690 | ;; Quote certain characters, unless ls quoted them for us. | 699 | ;; Quote certain characters, unless ls quoted them for us. |
| 691 | (if (not (string-match "b" dired-actual-switches)) | 700 | (if (not (string-match "b" dired-actual-switches)) |
| 692 | (save-excursion | 701 | (save-excursion |
| @@ -698,25 +707,8 @@ If HDR is non-nil, insert a header line with the directory name." | |||
| 698 | (while (search-forward "\^m" end t) | 707 | (while (search-forward "\^m" end t) |
| 699 | (replace-match "\\015" nil t)) | 708 | (replace-match "\\015" nil t)) |
| 700 | (set-marker end nil))) | 709 | (set-marker end nil))) |
| 701 | (dired-insert-set-properties opoint (point)) | 710 | (dired-insert-set-properties opoint (point))) |
| 702 | ;; If we used --dired and it worked, the lines are already indented. | 711 | (setq dired-directory dir-or-list)) |
| 703 | ;; Otherwise, indent them. | ||
| 704 | (unless (save-excursion | ||
| 705 | (forward-line -1) | ||
| 706 | (looking-at " ")) | ||
| 707 | (let ((indent-tabs-mode nil)) | ||
| 708 | (indent-rigidly opoint (point) 2))) | ||
| 709 | ;; Insert text at the beginning to standardize things. | ||
| 710 | (save-excursion | ||
| 711 | (goto-char opoint) | ||
| 712 | (if (and (or hdr wildcard) (not (looking-at "^ /.*:$"))) | ||
| 713 | ;; Note that dired-build-subdir-alist will replace the name | ||
| 714 | ;; by its expansion, so it does not matter whether what we insert | ||
| 715 | ;; here is fully expanded, but it should be absolute. | ||
| 716 | (insert " " (directory-file-name (file-name-directory dir)) ":\n")) | ||
| 717 | (when wildcard | ||
| 718 | ;; Insert "wildcard" line where "total" line would be for a full dir. | ||
| 719 | (insert " wildcard " (file-name-nondirectory dir) "\n"))))) | ||
| 720 | 712 | ||
| 721 | ;; Make the file names highlight when the mouse is on them. | 713 | ;; Make the file names highlight when the mouse is on them. |
| 722 | (defun dired-insert-set-properties (beg end) | 714 | (defun dired-insert-set-properties (beg end) |
| @@ -734,6 +726,13 @@ If HDR is non-nil, insert a header line with the directory name." | |||
| 734 | help-echo "mouse-2: visit this file in other window"))) | 726 | help-echo "mouse-2: visit this file in other window"))) |
| 735 | (error nil)) | 727 | (error nil)) |
| 736 | (forward-line 1)))) | 728 | (forward-line 1)))) |
| 729 | |||
| 730 | (defun dired-insert-headerline (dir);; also used by dired-insert-subdir | ||
| 731 | ;; Insert DIR's headerline with no trailing slash, exactly like ls | ||
| 732 | ;; would, and put cursor where dired-build-subdir-alist puts subdir | ||
| 733 | ;; boundaries. | ||
| 734 | (save-excursion (insert " " (directory-file-name dir) ":\n"))) | ||
| 735 | |||
| 737 | 736 | ||
| 738 | ;; Reverting a dired buffer | 737 | ;; Reverting a dired buffer |
| 739 | 738 | ||
| @@ -756,7 +755,7 @@ If HDR is non-nil, insert a header line with the directory name." | |||
| 756 | ;; treat top level dir extra (it may contain wildcards) | 755 | ;; treat top level dir extra (it may contain wildcards) |
| 757 | (dired-uncache | 756 | (dired-uncache |
| 758 | (if (consp dired-directory) (car dired-directory) dired-directory)) | 757 | (if (consp dired-directory) (car dired-directory) dired-directory)) |
| 759 | (dired-readin) | 758 | (dired-readin dired-directory (current-buffer)) |
| 760 | (let ((dired-after-readin-hook nil)) | 759 | (let ((dired-after-readin-hook nil)) |
| 761 | ;; don't run that hook for each subdir... | 760 | ;; don't run that hook for each subdir... |
| 762 | (dired-insert-old-subdirs old-subdir-alist)) | 761 | (dired-insert-old-subdirs old-subdir-alist)) |
| @@ -1576,14 +1575,10 @@ regardless of the language.") | |||
| 1576 | ;; This is the UNIX version. | 1575 | ;; This is the UNIX version. |
| 1577 | (or eol (setq eol (progn (end-of-line) (point)))) | 1576 | (or eol (setq eol (progn (end-of-line) (point)))) |
| 1578 | (beginning-of-line) | 1577 | (beginning-of-line) |
| 1579 | ;; First try assuming `ls --dired' was used. | 1578 | (if (re-search-forward dired-move-to-filename-regexp eol t) |
| 1580 | (let ((change (next-single-property-change (point) 'dired-filename | 1579 | (goto-char (match-end 0)) |
| 1581 | nil eol))) | 1580 | (if raise-error |
| 1582 | (if change (goto-char change) | 1581 | (error "No file on this line")))) |
| 1583 | (if (re-search-forward dired-move-to-filename-regexp eol t) | ||
| 1584 | (goto-char (match-end 0)) | ||
| 1585 | (if raise-error | ||
| 1586 | (error "No file on this line")))))) | ||
| 1587 | 1582 | ||
| 1588 | (defun dired-move-to-end-of-filename (&optional no-error) | 1583 | (defun dired-move-to-end-of-filename (&optional no-error) |
| 1589 | ;; Assumes point is at beginning of filename, | 1584 | ;; Assumes point is at beginning of filename, |
| @@ -1592,65 +1587,63 @@ regardless of the language.") | |||
| 1592 | ;; (dired-move-to-filename t). | 1587 | ;; (dired-move-to-filename t). |
| 1593 | ;; On failure, signals an error (with non-nil NO-ERROR just returns nil). | 1588 | ;; On failure, signals an error (with non-nil NO-ERROR just returns nil). |
| 1594 | ;; This is the UNIX version. | 1589 | ;; This is the UNIX version. |
| 1595 | (if (get-text-property (point) 'dired-filename) | 1590 | (let (opoint file-type executable symlink hidden case-fold-search used-F eol) |
| 1596 | (goto-char (next-single-property-change (point) 'dired-filename)) | 1591 | ;; case-fold-search is nil now, so we can test for capital F: |
| 1597 | (let (opoint file-type executable symlink hidden case-fold-search used-F eol) | 1592 | (setq used-F (string-match "F" dired-actual-switches) |
| 1598 | ;; case-fold-search is nil now, so we can test for capital F: | 1593 | opoint (point) |
| 1599 | (setq used-F (string-match "F" dired-actual-switches) | 1594 | eol (save-excursion (end-of-line) (point)) |
| 1600 | opoint (point) | 1595 | hidden (and selective-display |
| 1601 | eol (save-excursion (end-of-line) (point)) | 1596 | (save-excursion (search-forward "\r" eol t)))) |
| 1602 | hidden (and selective-display | 1597 | (if hidden |
| 1603 | (save-excursion (search-forward "\r" eol t)))) | 1598 | nil |
| 1604 | (if hidden | 1599 | (save-excursion;; Find out what kind of file this is: |
| 1605 | nil | 1600 | ;; Restrict perm bits to be non-blank, |
| 1606 | (save-excursion ;; Find out what kind of file this is: | 1601 | ;; otherwise this matches one char to early (looking backward): |
| 1607 | ;; Restrict perm bits to be non-blank, | 1602 | ;; "l---------" (some systems make symlinks that way) |
| 1608 | ;; otherwise this matches one char to early (looking backward): | 1603 | ;; "----------" (plain file with zero perms) |
| 1609 | ;; "l---------" (some systems make symlinks that way) | 1604 | (if (re-search-backward |
| 1610 | ;; "----------" (plain file with zero perms) | 1605 | dired-permission-flags-regexp nil t) |
| 1611 | (if (re-search-backward | 1606 | (setq file-type (char-after (match-beginning 1)) |
| 1612 | dired-permission-flags-regexp nil t) | 1607 | symlink (eq file-type ?l) |
| 1613 | (setq file-type (char-after (match-beginning 1)) | 1608 | ;; Only with -F we need to know whether it's an executable |
| 1614 | symlink (eq file-type ?l) | 1609 | executable (and |
| 1615 | ;; Only with -F we need to know whether it's an executable | 1610 | used-F |
| 1616 | executable (and | 1611 | (string-match |
| 1617 | used-F | 1612 | "[xst]";; execute bit set anywhere? |
| 1618 | (string-match | 1613 | (concat |
| 1619 | "[xst]" ;; execute bit set anywhere? | 1614 | (buffer-substring (match-beginning 2) |
| 1620 | (concat | 1615 | (match-end 2)) |
| 1621 | (buffer-substring (match-beginning 2) | 1616 | (buffer-substring (match-beginning 3) |
| 1622 | (match-end 2)) | 1617 | (match-end 3)) |
| 1623 | (buffer-substring (match-beginning 3) | 1618 | (buffer-substring (match-beginning 4) |
| 1624 | (match-end 3)) | 1619 | (match-end 4)))))) |
| 1625 | (buffer-substring (match-beginning 4) | 1620 | (or no-error (error "No file on this line")))) |
| 1626 | (match-end 4)))))) | 1621 | ;; Move point to end of name: |
| 1627 | (or no-error (error "No file on this line")))) | 1622 | (if symlink |
| 1628 | ;; Move point to end of name: | 1623 | (if (search-forward " ->" eol t) |
| 1629 | (if symlink | 1624 | (progn |
| 1630 | (if (search-forward " ->" eol t) | 1625 | (forward-char -3) |
| 1631 | (progn | 1626 | (and used-F |
| 1632 | (forward-char -3) | 1627 | dired-ls-F-marks-symlinks |
| 1633 | (and used-F | 1628 | (eq (preceding-char) ?@);; did ls really mark the link? |
| 1634 | dired-ls-F-marks-symlinks | 1629 | (forward-char -1)))) |
| 1635 | (eq (preceding-char) ?@) ;; did ls really mark the link? | 1630 | (goto-char eol);; else not a symbolic link |
| 1636 | (forward-char -1)))) | 1631 | ;; ls -lF marks dirs, sockets and executables with exactly one |
| 1637 | (goto-char eol) ;; else not a symbolic link | 1632 | ;; trailing character. (Executable bits on symlinks ain't mean |
| 1638 | ;; ls -lF marks dirs, sockets and executables with exactly one | 1633 | ;; a thing, even to ls, but we know it's not a symlink.) |
| 1639 | ;; trailing character. (Executable bits on symlinks ain't mean | 1634 | (and used-F |
| 1640 | ;; a thing, even to ls, but we know it's not a symlink.) | 1635 | (or (memq file-type '(?d ?s)) |
| 1641 | (and used-F | 1636 | executable) |
| 1642 | (or (memq file-type '(?d ?s)) | 1637 | (forward-char -1)))) |
| 1643 | executable) | 1638 | (or no-error |
| 1644 | (forward-char -1)))) | 1639 | (not (eq opoint (point))) |
| 1645 | (or no-error | 1640 | (error (if hidden |
| 1646 | (not (eq opoint (point))) | 1641 | (substitute-command-keys |
| 1647 | (error (if hidden | 1642 | "File line is hidden, type \\[dired-hide-subdir] to unhide") |
| 1648 | (substitute-command-keys | 1643 | "No file on this line"))) |
| 1649 | "File line is hidden, type \\[dired-hide-subdir] to unhide") | 1644 | (if (eq opoint (point)) |
| 1650 | "No file on this line"))) | 1645 | nil |
| 1651 | (if (eq opoint (point)) | 1646 | (point)))) |
| 1652 | nil | ||
| 1653 | (point))))) | ||
| 1654 | 1647 | ||
| 1655 | 1648 | ||
| 1656 | ;;; COPY NAMES OF MARKED FILES INTO KILL-RING. | 1649 | ;;; COPY NAMES OF MARKED FILES INTO KILL-RING. |