Mercurial > emacs
comparison lisp/dired-aux.el @ 33804:a4983aa962bb
(dired-add-entry): Don't call dired-get-filename
with `no-dir'; we want the directory part to be able to remove
it.
author | Gerd Moellmann <gerd@gnu.org> |
---|---|
date | Thu, 23 Nov 2000 13:53:12 +0000 |
parents | bb6d168a6387 |
children | da7c75342507 |
comparison
equal
deleted
inserted
replaced
33803:1f71c752b328 | 33804:a4983aa962bb |
---|---|
804 ;; And it skips "." or ".." (see `dired-trivial-filenames'). | 804 ;; And it skips "." or ".." (see `dired-trivial-filenames'). |
805 ;; Hidden subdirs are exposed if a file is added there. | 805 ;; Hidden subdirs are exposed if a file is added there. |
806 (setq filename (directory-file-name filename)) | 806 (setq filename (directory-file-name filename)) |
807 ;; Entry is always for files, even if they happen to also be directories | 807 ;; Entry is always for files, even if they happen to also be directories |
808 (let* ((opoint (point)) | 808 (let* ((opoint (point)) |
809 (cur-dir (dired-current-directory)) | 809 (cur-dir (dired-current-directory)) |
810 (orig-file-name filename) | 810 (orig-file-name filename) |
811 (directory (if relative cur-dir (file-name-directory filename))) | 811 (directory (if relative cur-dir (file-name-directory filename))) |
812 reason) | 812 reason) |
813 (setq filename | 813 (setq filename |
814 (if relative | 814 (if relative |
815 (file-relative-name filename directory) | 815 (file-relative-name filename directory) |
816 (file-name-nondirectory filename)) | 816 (file-name-nondirectory filename)) |
817 reason | 817 reason |
820 (progn | 820 (progn |
821 (skip-chars-forward "^\r\n") | 821 (skip-chars-forward "^\r\n") |
822 (if (eq (following-char) ?\r) | 822 (if (eq (following-char) ?\r) |
823 (dired-unhide-subdir)) | 823 (dired-unhide-subdir)) |
824 ;; We are already where we should be, except when | 824 ;; We are already where we should be, except when |
825 ;; point is before the subdir line or its total line. | 825 ;; point is before the subdir line or its total line. |
826 (let ((p (dired-after-subdir-garbage cur-dir))) | 826 (let ((p (dired-after-subdir-garbage cur-dir))) |
827 (if (< (point) p) | 827 (if (< (point) p) |
828 (goto-char p)))) | 828 (goto-char p)))) |
829 ;; else try to find correct place to insert | 829 ;; else try to find correct place to insert |
830 (if (dired-goto-subdir directory) | 830 (if (dired-goto-subdir directory) |
831 (progn;; unhide if necessary | 831 (progn ;; unhide if necessary |
832 (if (looking-at "\r");; point is at end of subdir line | 832 (if (looking-at "\r") ;; point is at end of subdir line |
833 (dired-unhide-subdir)) | 833 (dired-unhide-subdir)) |
834 ;; found - skip subdir and `total' line | 834 ;; found - skip subdir and `total' line |
835 ;; and uninteresting files like . and .. | 835 ;; and uninteresting files like . and .. |
836 ;; This better not moves into the next subdir! | 836 ;; This better not moves into the next subdir! |
837 (dired-goto-next-nontrivial-file)) | 837 (dired-goto-next-nontrivial-file)) |
839 (throw 'not-found "Subdir not found"))) | 839 (throw 'not-found "Subdir not found"))) |
840 (let (buffer-read-only opoint) | 840 (let (buffer-read-only opoint) |
841 (beginning-of-line) | 841 (beginning-of-line) |
842 (setq opoint (point)) | 842 (setq opoint (point)) |
843 (dired-add-entry-do-indentation marker-char) | 843 (dired-add-entry-do-indentation marker-char) |
844 ;; don't expand `.'. Show just the file name within directory. | 844 ;; don't expand `.'. Show just the file name within directory. |
845 (let ((default-directory directory)) | 845 (let ((default-directory directory)) |
846 (insert-directory filename | 846 (insert-directory filename |
847 (concat dired-actual-switches "d"))) | 847 (concat dired-actual-switches "d"))) |
848 ;; Compensate for a bug in ange-ftp. | 848 ;; Compensate for a bug in ange-ftp. |
849 ;; It inserts the file's absolute name, rather than | 849 ;; It inserts the file's absolute name, rather than |
850 ;; the relative one. That may be hard to fix since it | 850 ;; the relative one. That may be hard to fix since it |
851 ;; is probably controlled by something in ftp. | 851 ;; is probably controlled by something in ftp. |
852 (goto-char opoint) | 852 (goto-char opoint) |
853 (let ((inserted-name (dired-get-filename 'no-dir))) | 853 (let ((inserted-name (dired-get-filename))) |
854 (if (file-name-directory inserted-name) | 854 (if (file-name-directory inserted-name) |
855 (progn | 855 (progn |
856 (end-of-line) | 856 (end-of-line) |
857 (delete-char (- (length inserted-name))) | 857 (delete-char (- (length inserted-name))) |
858 (insert filename) | 858 (insert filename) |
859 (forward-char 1)) | 859 (forward-char 1)) |
860 (forward-line 1))) | 860 (forward-line 1))) |
861 ;; Give each line a text property recording info about it. | 861 ;; Give each line a text property recording info about it. |
862 (dired-insert-set-properties opoint (point)) | 862 (dired-insert-set-properties opoint (point)) |
863 (forward-line -1) | 863 (forward-line -1) |
864 (if dired-after-readin-hook;; the subdir-alist is not affected... | 864 (if dired-after-readin-hook ;; the subdir-alist is not affected... |
865 (save-excursion;; ...so we can run it right now: | 865 (save-excursion ;; ...so we can run it right now: |
866 (save-restriction | 866 (save-restriction |
867 (beginning-of-line) | 867 (beginning-of-line) |
868 (narrow-to-region (point) (save-excursion | 868 (narrow-to-region (point) (save-excursion |
869 (forward-line 1) (point))) | 869 (forward-line 1) (point))) |
870 (run-hooks 'dired-after-readin-hook)))) | 870 (run-hooks 'dired-after-readin-hook)))) |
871 (dired-move-to-filename)) | 871 (dired-move-to-filename)) |
872 ;; return nil if all went well | 872 ;; return nil if all went well |
873 nil)) | 873 nil)) |
874 (if reason ; don't move away on failure | 874 (if reason ; don't move away on failure |
875 (goto-char opoint)) | 875 (goto-char opoint)) |
876 (not reason))) ; return t on success, nil else | 876 (not reason))) ; return t on success, nil else |
877 | 877 |
878 ;; This is a separate function for the sake of nested dired format. | 878 ;; This is a separate function for the sake of nested dired format. |
879 (defun dired-add-entry-do-indentation (marker-char) | 879 (defun dired-add-entry-do-indentation (marker-char) |
880 ;; two spaces or a marker plus a space: | 880 ;; two spaces or a marker plus a space: |
881 (insert (if marker-char | 881 (insert (if marker-char |