diff options
| author | Glenn Morris | 2011-02-18 19:53:35 -0800 |
|---|---|---|
| committer | Glenn Morris | 2011-02-18 19:53:35 -0800 |
| commit | 30abce25f2c78c46994f22d60295c40578097b76 (patch) | |
| tree | 456b892ad3e7e1d5ddfbfaa36f1c09f0edde8f4c | |
| parent | 4d737eb2db5f2847106fa18713381a72895217e5 (diff) | |
| download | emacs-30abce25f2c78c46994f22d60295c40578097b76.tar.gz emacs-30abce25f2c78c46994f22d60295c40578097b76.zip | |
Merge dired-x's dired-add-entry modifications into the main definition.
* lisp/dired-aux.el (dired-add-entry): Give it a doc-string.
Merge dired-x's dired-omit handling here.
(dired-omit-mode, dired-omit-regexp, dired-omit-localp): Declare.
* lisp/dired-x.el (dired-omit-new-add-entry): Merge into dired-add-entry.
* doc/misc/dired-x.texi (Technical Details): No longer redefines
dired-add-entry.
| -rw-r--r-- | doc/misc/ChangeLog | 4 | ||||
| -rw-r--r-- | doc/misc/dired-x.texi | 11 | ||||
| -rw-r--r-- | lisp/ChangeLog | 5 | ||||
| -rw-r--r-- | lisp/dired-aux.el | 202 | ||||
| -rw-r--r-- | lisp/dired-x.el | 41 |
5 files changed, 130 insertions, 133 deletions
diff --git a/doc/misc/ChangeLog b/doc/misc/ChangeLog index b0d006ce14b..c11618649da 100644 --- a/doc/misc/ChangeLog +++ b/doc/misc/ChangeLog | |||
| @@ -1,3 +1,7 @@ | |||
| 1 | 2011-02-19 Glenn Morris <rgm@gnu.org> | ||
| 2 | |||
| 3 | * dired-x.texi (Technical Details): No longer redefines dired-add-entry. | ||
| 4 | |||
| 1 | 2011-02-18 Glenn Morris <rgm@gnu.org> | 5 | 2011-02-18 Glenn Morris <rgm@gnu.org> |
| 2 | 6 | ||
| 3 | * dired-x.texi (Optional Installation File At Point): Simplify. | 7 | * dired-x.texi (Optional Installation File At Point): Simplify. |
diff --git a/doc/misc/dired-x.texi b/doc/misc/dired-x.texi index eff8e4600bd..931af07be4e 100644 --- a/doc/misc/dired-x.texi +++ b/doc/misc/dired-x.texi | |||
| @@ -190,14 +190,9 @@ from @file{dired.el} | |||
| 190 | @end itemize | 190 | @end itemize |
| 191 | 191 | ||
| 192 | @noindent | 192 | @noindent |
| 193 | and the following functions from @file{dired-aux.el} | 193 | and from @file{dired-aux.el} the function @code{dired-read-shell-command}. |
| 194 | 194 | In addition, once @file{dired.el} is loaded, @code{dired-add-entry} | |
| 195 | @itemize @bullet | 195 | obeys Dired Omit mode (@pxref{Omitting Files in Dired}), if it is active. |
| 196 | @item | ||
| 197 | @code{dired-add-entry} | ||
| 198 | @item | ||
| 199 | @code{dired-read-shell-command} | ||
| 200 | @end itemize | ||
| 201 | 196 | ||
| 202 | @node Installation, Omitting Files in Dired, Introduction, Top | 197 | @node Installation, Omitting Files in Dired, Introduction, Top |
| 203 | @chapter Installation | 198 | @chapter Installation |
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index b4b2d687e85..8e54788610e 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,5 +1,10 @@ | |||
| 1 | 2011-02-19 Glenn Morris <rgm@gnu.org> | 1 | 2011-02-19 Glenn Morris <rgm@gnu.org> |
| 2 | 2 | ||
| 3 | * dired-x.el (dired-omit-new-add-entry): Merge into dired-add-entry. | ||
| 4 | * dired-aux.el (dired-add-entry): Give it a doc-string. | ||
| 5 | Merge dired-x's dired-omit handling here. | ||
| 6 | (dired-omit-mode, dired-omit-regexp, dired-omit-localp): Declare. | ||
| 7 | |||
| 3 | * international/mule-diag.el (list-input-methods-1): | 8 | * international/mule-diag.el (list-input-methods-1): |
| 4 | Indent all lines of multi-line doc-strings. (Bug#8066) | 9 | Indent all lines of multi-line doc-strings. (Bug#8066) |
| 5 | 10 | ||
diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el index cb1324051a7..bf70262ee73 100644 --- a/lisp/dired-aux.el +++ b/lisp/dired-aux.el | |||
| @@ -1039,92 +1039,124 @@ See Info node `(emacs)Subdir switches' for more details." | |||
| 1039 | (file-name-directory filename) (file-name-nondirectory filename) | 1039 | (file-name-directory filename) (file-name-nondirectory filename) |
| 1040 | (function dired-add-entry) filename marker-char)) | 1040 | (function dired-add-entry) filename marker-char)) |
| 1041 | 1041 | ||
| 1042 | (defvar dired-omit-mode) | ||
| 1043 | (declare-function dired-omit-regexp "dired-x" ()) | ||
| 1044 | (defvar dired-omit-localp) | ||
| 1045 | |||
| 1042 | (defun dired-add-entry (filename &optional marker-char relative) | 1046 | (defun dired-add-entry (filename &optional marker-char relative) |
| 1043 | ;; Add a new entry for FILENAME, optionally marking it | 1047 | "Add a new dired entry for FILENAME. |
| 1044 | ;; with MARKER-CHAR (a character, else dired-marker-char is used). | 1048 | Optionally mark it with MARKER-CHAR (a character, else uses |
| 1045 | ;; Note that this adds the entry `out of order' if files sorted by | 1049 | `dired-marker-char'). Note that this adds the entry `out of order' |
| 1046 | ;; time, etc. | 1050 | if files are sorted by time, etc. |
| 1047 | ;; At least this version inserts in the right subdirectory (if present). | 1051 | Skips files that match `dired-trivial-filenames'. |
| 1048 | ;; And it skips "." or ".." (see `dired-trivial-filenames'). | 1052 | Exposes hidden subdirectories if a file is added there. |
| 1049 | ;; Hidden subdirs are exposed if a file is added there. | 1053 | |
| 1050 | (setq filename (directory-file-name filename)) | 1054 | If `dired-x' is loaded and `dired-omit-mode' is enabled, skips |
| 1051 | ;; Entry is always for files, even if they happen to also be directories | 1055 | files matching `dired-omit-regexp'." |
| 1052 | (let* ((opoint (point)) | 1056 | (if (or (not (featurep 'dired-x)) |
| 1053 | (cur-dir (dired-current-directory)) | 1057 | (not dired-omit-mode) |
| 1054 | (orig-file-name filename) | 1058 | ;; Avoid calling ls for files that are going to be omitted anyway. |
| 1055 | (directory (if relative cur-dir (file-name-directory filename))) | 1059 | (let ((omit-re (dired-omit-regexp))) |
| 1056 | reason) | 1060 | (or (string= omit-re "") |
| 1057 | (setq filename | 1061 | (not (string-match omit-re |
| 1058 | (if relative | 1062 | (cond |
| 1059 | (file-relative-name filename directory) | 1063 | ((eq 'no-dir dired-omit-localp) |
| 1060 | (file-name-nondirectory filename)) | 1064 | filename) |
| 1061 | reason | 1065 | ((eq t dired-omit-localp) |
| 1062 | (catch 'not-found | 1066 | (dired-make-relative filename)) |
| 1063 | (if (string= directory cur-dir) | 1067 | (t |
| 1064 | (progn | 1068 | (dired-make-absolute |
| 1065 | (skip-chars-forward "^\r\n") | 1069 | filename |
| 1066 | (if (eq (following-char) ?\r) | 1070 | (file-name-directory filename))))))))) |
| 1067 | (dired-unhide-subdir)) | 1071 | ;; Do it! |
| 1068 | ;; We are already where we should be, except when | 1072 | (progn |
| 1069 | ;; point is before the subdir line or its total line. | 1073 | (setq filename (directory-file-name filename)) |
| 1070 | (let ((p (dired-after-subdir-garbage cur-dir))) | 1074 | ;; Entry is always for files, even if they happen to also be directories |
| 1071 | (if (< (point) p) | 1075 | (let* ((opoint (point)) |
| 1072 | (goto-char p)))) | 1076 | (cur-dir (dired-current-directory)) |
| 1073 | ;; else try to find correct place to insert | 1077 | (orig-file-name filename) |
| 1074 | (if (dired-goto-subdir directory) | 1078 | (directory (if relative cur-dir (file-name-directory filename))) |
| 1075 | (progn ;; unhide if necessary | 1079 | reason) |
| 1076 | (if (looking-at "\r") ;; point is at end of subdir line | 1080 | (setq filename |
| 1077 | (dired-unhide-subdir)) | 1081 | (if relative |
| 1078 | ;; found - skip subdir and `total' line | 1082 | (file-relative-name filename directory) |
| 1079 | ;; and uninteresting files like . and .. | 1083 | (file-name-nondirectory filename)) |
| 1080 | ;; This better not moves into the next subdir! | 1084 | reason |
| 1081 | (dired-goto-next-nontrivial-file)) | 1085 | (catch 'not-found |
| 1082 | ;; not found | 1086 | (if (string= directory cur-dir) |
| 1083 | (throw 'not-found "Subdir not found"))) | 1087 | (progn |
| 1084 | (let (buffer-read-only opoint) | 1088 | (skip-chars-forward "^\r\n") |
| 1085 | (beginning-of-line) | 1089 | (if (eq (following-char) ?\r) |
| 1086 | (setq opoint (point)) | 1090 | (dired-unhide-subdir)) |
| 1087 | ;; Don't expand `.'. Show just the file name within directory. | 1091 | ;; We are already where we should be, except when |
| 1088 | (let ((default-directory directory)) | 1092 | ;; point is before the subdir line or its total line. |
| 1089 | (dired-insert-directory directory | 1093 | (let ((p (dired-after-subdir-garbage cur-dir))) |
| 1090 | (concat dired-actual-switches " -d") | 1094 | (if (< (point) p) |
| 1091 | (list filename))) | 1095 | (goto-char p)))) |
| 1092 | (goto-char opoint) | 1096 | ;; else try to find correct place to insert |
| 1093 | ;; Put in desired marker char. | 1097 | (if (dired-goto-subdir directory) |
| 1094 | (when marker-char | 1098 | (progn ;; unhide if necessary |
| 1095 | (let ((dired-marker-char | 1099 | (if (looking-at "\r") |
| 1096 | (if (integerp marker-char) marker-char dired-marker-char))) | 1100 | ;; Point is at end of subdir line. |
| 1097 | (dired-mark nil))) | 1101 | (dired-unhide-subdir)) |
| 1098 | ;; Compensate for a bug in ange-ftp. | 1102 | ;; found - skip subdir and `total' line |
| 1099 | ;; It inserts the file's absolute name, rather than | 1103 | ;; and uninteresting files like . and .. |
| 1100 | ;; the relative one. That may be hard to fix since it | 1104 | ;; This better not move into the next subdir! |
| 1101 | ;; is probably controlled by something in ftp. | 1105 | (dired-goto-next-nontrivial-file)) |
| 1102 | (goto-char opoint) | 1106 | ;; not found |
| 1103 | (let ((inserted-name (dired-get-filename 'verbatim))) | 1107 | (throw 'not-found "Subdir not found"))) |
| 1104 | (if (file-name-directory inserted-name) | 1108 | (let (buffer-read-only opoint) |
| 1105 | (let (props) | 1109 | (beginning-of-line) |
| 1106 | (end-of-line) | 1110 | (setq opoint (point)) |
| 1107 | (forward-char (- (length inserted-name))) | 1111 | ;; Don't expand `.'. |
| 1108 | (setq props (text-properties-at (point))) | 1112 | ;; Show just the file name within directory. |
| 1109 | (delete-char (length inserted-name)) | 1113 | (let ((default-directory directory)) |
| 1110 | (let ((pt (point))) | 1114 | (dired-insert-directory |
| 1111 | (insert filename) | 1115 | directory |
| 1112 | (set-text-properties pt (point) props)) | 1116 | (concat dired-actual-switches " -d") |
| 1113 | (forward-char 1)) | 1117 | (list filename))) |
| 1114 | (forward-line 1))) | 1118 | (goto-char opoint) |
| 1115 | (forward-line -1) | 1119 | ;; Put in desired marker char. |
| 1116 | (if dired-after-readin-hook ;; the subdir-alist is not affected... | 1120 | (when marker-char |
| 1117 | (save-excursion ;; ...so we can run it right now: | 1121 | (let ((dired-marker-char |
| 1118 | (save-restriction | 1122 | (if (integerp marker-char) marker-char |
| 1119 | (beginning-of-line) | 1123 | dired-marker-char))) |
| 1120 | (narrow-to-region (point) (line-beginning-position 2)) | 1124 | (dired-mark nil))) |
| 1121 | (run-hooks 'dired-after-readin-hook)))) | 1125 | ;; Compensate for a bug in ange-ftp. |
| 1122 | (dired-move-to-filename)) | 1126 | ;; It inserts the file's absolute name, rather than |
| 1123 | ;; return nil if all went well | 1127 | ;; the relative one. That may be hard to fix since it |
| 1124 | nil)) | 1128 | ;; is probably controlled by something in ftp. |
| 1125 | (if reason ; don't move away on failure | 1129 | (goto-char opoint) |
| 1126 | (goto-char opoint)) | 1130 | (let ((inserted-name (dired-get-filename 'verbatim))) |
| 1127 | (not reason))) ; return t on success, nil else | 1131 | (if (file-name-directory inserted-name) |
| 1132 | (let (props) | ||
| 1133 | (end-of-line) | ||
| 1134 | (forward-char (- (length inserted-name))) | ||
| 1135 | (setq props (text-properties-at (point))) | ||
| 1136 | (delete-char (length inserted-name)) | ||
| 1137 | (let ((pt (point))) | ||
| 1138 | (insert filename) | ||
| 1139 | (set-text-properties pt (point) props)) | ||
| 1140 | (forward-char 1)) | ||
| 1141 | (forward-line 1))) | ||
| 1142 | (forward-line -1) | ||
| 1143 | (if dired-after-readin-hook | ||
| 1144 | ;; The subdir-alist is not affected... | ||
| 1145 | (save-excursion ; ...so we can run it right now: | ||
| 1146 | (save-restriction | ||
| 1147 | (beginning-of-line) | ||
| 1148 | (narrow-to-region (point) | ||
| 1149 | (line-beginning-position 2)) | ||
| 1150 | (run-hooks 'dired-after-readin-hook)))) | ||
| 1151 | (dired-move-to-filename)) | ||
| 1152 | ;; return nil if all went well | ||
| 1153 | nil)) | ||
| 1154 | (if reason ; don't move away on failure | ||
| 1155 | (goto-char opoint)) | ||
| 1156 | (not reason))) ; return t on success, nil else | ||
| 1157 | ;; Don't do it (dired-omit-mode). | ||
| 1158 | ;; Return t for success (perhaps we should return file-exists-p). | ||
| 1159 | t)) | ||
| 1128 | 1160 | ||
| 1129 | (defun dired-after-subdir-garbage (dir) | 1161 | (defun dired-after-subdir-garbage (dir) |
| 1130 | ;; Return pos of first file line of DIR, skipping header and total | 1162 | ;; Return pos of first file line of DIR, skipping header and total |
diff --git a/lisp/dired-x.el b/lisp/dired-x.el index e591bb5d1d9..0bdf4950a58 100644 --- a/lisp/dired-x.el +++ b/lisp/dired-x.el | |||
| @@ -50,7 +50,7 @@ | |||
| 50 | ;; When loaded this code redefines the following functions of GNU Emacs: | 50 | ;; When loaded this code redefines the following functions of GNU Emacs: |
| 51 | ;; From dired.el: dired-clean-up-after-deletion, dired-find-buffer-nocreate, | 51 | ;; From dired.el: dired-clean-up-after-deletion, dired-find-buffer-nocreate, |
| 52 | ;; and dired-initial-position. | 52 | ;; and dired-initial-position. |
| 53 | ;; From dired-aux.el: dired-add-entry and dired-read-shell-command. | 53 | ;; From dired-aux.el: dired-read-shell-command. |
| 54 | 54 | ||
| 55 | ;; *Please* see the `dired-x' info pages for more details. | 55 | ;; *Please* see the `dired-x' info pages for more details. |
| 56 | 56 | ||
| @@ -589,45 +589,6 @@ Optional fourth argument LOCALP is as in `dired-get-filename'." | |||
| 589 | (and fn (string-match regexp fn)))) | 589 | (and fn (string-match regexp fn)))) |
| 590 | msg))) | 590 | msg))) |
| 591 | 591 | ||
| 592 | ;; Compiler does not get fset. | ||
| 593 | (declare-function dired-omit-old-add-entry "dired-x") | ||
| 594 | |||
| 595 | ;; REDEFINE. | ||
| 596 | ;; Redefine dired-aux.el's version of `dired-add-entry' | ||
| 597 | ;; Save old defun if not already done: | ||
| 598 | (or (fboundp 'dired-omit-old-add-entry) | ||
| 599 | (fset 'dired-omit-old-add-entry (symbol-function 'dired-add-entry))) | ||
| 600 | |||
| 601 | ;; REDEFINE. | ||
| 602 | (defun dired-omit-new-add-entry (filename &optional marker-char relative) | ||
| 603 | ;; This redefines dired-aux.el's dired-add-entry to avoid calling ls for | ||
| 604 | ;; files that are going to be omitted anyway. | ||
| 605 | (if dired-omit-mode | ||
| 606 | ;; perhaps return t without calling ls | ||
| 607 | (let ((omit-re (dired-omit-regexp))) | ||
| 608 | (if (or (string= omit-re "") | ||
| 609 | (not | ||
| 610 | (string-match omit-re | ||
| 611 | (cond | ||
| 612 | ((eq 'no-dir dired-omit-localp) | ||
| 613 | filename) | ||
| 614 | ((eq t dired-omit-localp) | ||
| 615 | (dired-make-relative filename)) | ||
| 616 | (t | ||
| 617 | (dired-make-absolute | ||
| 618 | filename | ||
| 619 | (file-name-directory filename))))))) | ||
| 620 | ;; if it didn't match, go ahead and add the entry | ||
| 621 | (dired-omit-old-add-entry filename marker-char relative) | ||
| 622 | ;; dired-add-entry returns t for success, perhaps we should | ||
| 623 | ;; return file-exists-p | ||
| 624 | t)) | ||
| 625 | ;; omitting is not turned on at all | ||
| 626 | (dired-omit-old-add-entry filename marker-char relative))) | ||
| 627 | |||
| 628 | ;; Redefine it. | ||
| 629 | (fset 'dired-add-entry 'dired-omit-new-add-entry) | ||
| 630 | |||
| 631 | 592 | ||
| 632 | ;;; VIRTUAL DIRED MODE. | 593 | ;;; VIRTUAL DIRED MODE. |
| 633 | 594 | ||