emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r103345: Merge dired-x's dired-add-en


From: Glenn Morris
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r103345: Merge dired-x's dired-add-entry modifications into the main definition.
Date: Fri, 18 Feb 2011 19:53:35 -0800
User-agent: Bazaar (2.0.3)

------------------------------------------------------------
revno: 103345
committer: Glenn Morris <address@hidden>
branch nick: trunk
timestamp: Fri 2011-02-18 19:53:35 -0800
message:
  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.
modified:
  doc/misc/ChangeLog
  doc/misc/dired-x.texi
  lisp/ChangeLog
  lisp/dired-aux.el
  lisp/dired-x.el
=== modified file 'doc/misc/ChangeLog'
--- a/doc/misc/ChangeLog        2011-02-18 07:54:28 +0000
+++ b/doc/misc/ChangeLog        2011-02-19 03:53:35 +0000
@@ -1,3 +1,7 @@
+2011-02-19  Glenn Morris  <address@hidden>
+
+       * dired-x.texi (Technical Details): No longer redefines dired-add-entry.
+
 2011-02-18  Glenn Morris  <address@hidden>
 
        * dired-x.texi (Optional Installation File At Point): Simplify.

=== modified file 'doc/misc/dired-x.texi'
--- a/doc/misc/dired-x.texi     2011-02-18 07:54:28 +0000
+++ b/doc/misc/dired-x.texi     2011-02-19 03:53:35 +0000
@@ -190,14 +190,9 @@
 @end itemize
 
 @noindent
-and the following functions from @file{dired-aux.el}
-
address@hidden @bullet
address@hidden
address@hidden
address@hidden
address@hidden
address@hidden itemize
+and from @file{dired-aux.el} the function @code{dired-read-shell-command}.
+In addition, once @file{dired.el} is loaded, @code{dired-add-entry}
+obeys Dired Omit mode (@pxref{Omitting Files in Dired}), if it is active.
 
 @node Installation, Omitting Files in Dired, Introduction, Top
 @chapter Installation

=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2011-02-19 03:38:45 +0000
+++ b/lisp/ChangeLog    2011-02-19 03:53:35 +0000
@@ -1,5 +1,10 @@
 2011-02-19  Glenn Morris  <address@hidden>
 
+       * dired-x.el (dired-omit-new-add-entry): Merge into dired-add-entry.
+       * 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.
+
        * international/mule-diag.el (list-input-methods-1):
        Indent all lines of multi-line doc-strings.  (Bug#8066)
 

=== modified file 'lisp/dired-aux.el'
--- a/lisp/dired-aux.el 2011-02-12 22:55:28 +0000
+++ b/lisp/dired-aux.el 2011-02-19 03:53:35 +0000
@@ -1039,92 +1039,124 @@
    (file-name-directory filename) (file-name-nondirectory filename)
    (function dired-add-entry) filename marker-char))
 
+(defvar dired-omit-mode)
+(declare-function dired-omit-regexp "dired-x" ())
+(defvar dired-omit-localp)
+
 (defun dired-add-entry (filename &optional marker-char relative)
-  ;; Add a new entry for FILENAME, optionally marking it
-  ;; with MARKER-CHAR (a character, else dired-marker-char is used).
-  ;; Note that this adds the entry `out of order' if files sorted by
-  ;; time, etc.
-  ;; At least this version inserts in the right subdirectory (if present).
-  ;; And it skips "." or ".." (see `dired-trivial-filenames').
-  ;; Hidden subdirs are exposed if a file is added there.
-  (setq filename (directory-file-name filename))
-  ;; Entry is always for files, even if they happen to also be directories
-  (let* ((opoint (point))
-        (cur-dir (dired-current-directory))
-        (orig-file-name filename)
-        (directory (if relative cur-dir (file-name-directory filename)))
-        reason)
-    (setq filename
-         (if relative
-             (file-relative-name filename directory)
-           (file-name-nondirectory filename))
-         reason
-         (catch 'not-found
-           (if (string= directory cur-dir)
-               (progn
-                 (skip-chars-forward "^\r\n")
-                 (if (eq (following-char) ?\r)
-                     (dired-unhide-subdir))
-                 ;; We are already where we should be, except when
-                 ;; point is before the subdir line or its total line.
-                 (let ((p (dired-after-subdir-garbage cur-dir)))
-                   (if (< (point) p)
-                       (goto-char p))))
-             ;; else try to find correct place to insert
-             (if (dired-goto-subdir directory)
-                 (progn ;; unhide if necessary
-                   (if (looking-at "\r") ;; point is at end of subdir line
-                       (dired-unhide-subdir))
-                   ;; found - skip subdir and `total' line
-                   ;; and uninteresting files like . and ..
-                   ;; This better not moves into the next subdir!
-                   (dired-goto-next-nontrivial-file))
-               ;; not found
-               (throw 'not-found "Subdir not found")))
-           (let (buffer-read-only opoint)
-             (beginning-of-line)
-             (setq opoint (point))
-             ;; Don't expand `.'.  Show just the file name within directory.
-             (let ((default-directory directory))
-               (dired-insert-directory directory
-                                       (concat dired-actual-switches " -d")
-                                       (list filename)))
-              (goto-char opoint)
-             ;; Put in desired marker char.
-             (when marker-char
-               (let ((dired-marker-char
-                      (if (integerp marker-char) marker-char 
dired-marker-char)))
-                 (dired-mark nil)))
-             ;; Compensate for a bug in ange-ftp.
-             ;; It inserts the file's absolute name, rather than
-             ;; the relative one.  That may be hard to fix since it
-             ;; is probably controlled by something in ftp.
-             (goto-char opoint)
-             (let ((inserted-name (dired-get-filename 'verbatim)))
-               (if (file-name-directory inserted-name)
-                   (let (props)
-                     (end-of-line)
-                     (forward-char (- (length inserted-name)))
-                     (setq props (text-properties-at (point)))
-                     (delete-char (length inserted-name))
-                     (let ((pt (point)))
-                       (insert filename)
-                       (set-text-properties pt (point) props))
-                     (forward-char 1))
-                 (forward-line 1)))
-             (forward-line -1)
-             (if dired-after-readin-hook ;; the subdir-alist is not affected...
-                 (save-excursion ;; ...so we can run it right now:
-                   (save-restriction
-                     (beginning-of-line)
-                     (narrow-to-region (point) (line-beginning-position 2))
-                     (run-hooks 'dired-after-readin-hook))))
-             (dired-move-to-filename))
-           ;; return nil if all went well
-           nil))
-    (if reason ; don't move away on failure
-       (goto-char opoint))
-    (not reason))) ; return t on success, nil else
+  "Add a new dired entry for FILENAME.
+Optionally mark it with MARKER-CHAR (a character, else uses
+`dired-marker-char').  Note that this adds the entry `out of order'
+if files are sorted by time, etc.
+Skips files that match `dired-trivial-filenames'.
+Exposes hidden subdirectories if a file is added there.
+
+If `dired-x' is loaded and `dired-omit-mode' is enabled, skips
+files matching `dired-omit-regexp'."
+  (if (or (not (featurep 'dired-x))
+         (not dired-omit-mode)
+         ;; Avoid calling ls for files that are going to be omitted anyway.
+         (let ((omit-re (dired-omit-regexp)))
+           (or (string= omit-re "")
+               (not (string-match omit-re
+                                  (cond
+                                   ((eq 'no-dir dired-omit-localp)
+                                    filename)
+                                   ((eq t dired-omit-localp)
+                                    (dired-make-relative filename))
+                                   (t
+                                    (dired-make-absolute
+                                     filename
+                                     (file-name-directory filename)))))))))
+      ;; Do it!
+      (progn
+       (setq filename (directory-file-name filename))
+       ;; Entry is always for files, even if they happen to also be directories
+       (let* ((opoint (point))
+              (cur-dir (dired-current-directory))
+              (orig-file-name filename)
+              (directory (if relative cur-dir (file-name-directory filename)))
+              reason)
+         (setq filename
+               (if relative
+                   (file-relative-name filename directory)
+                 (file-name-nondirectory filename))
+               reason
+               (catch 'not-found
+                 (if (string= directory cur-dir)
+                     (progn
+                       (skip-chars-forward "^\r\n")
+                       (if (eq (following-char) ?\r)
+                           (dired-unhide-subdir))
+                       ;; We are already where we should be, except when
+                       ;; point is before the subdir line or its total line.
+                       (let ((p (dired-after-subdir-garbage cur-dir)))
+                         (if (< (point) p)
+                             (goto-char p))))
+                   ;; else try to find correct place to insert
+                   (if (dired-goto-subdir directory)
+                       (progn ;; unhide if necessary
+                         (if (looking-at "\r")
+                             ;; Point is at end of subdir line.
+                             (dired-unhide-subdir))
+                         ;; found - skip subdir and `total' line
+                         ;; and uninteresting files like . and ..
+                         ;; This better not move into the next subdir!
+                         (dired-goto-next-nontrivial-file))
+                     ;; not found
+                     (throw 'not-found "Subdir not found")))
+                 (let (buffer-read-only opoint)
+                   (beginning-of-line)
+                   (setq opoint (point))
+                   ;; Don't expand `.'.
+                   ;; Show just the file name within directory.
+                   (let ((default-directory directory))
+                     (dired-insert-directory
+                      directory
+                      (concat dired-actual-switches " -d")
+                      (list filename)))
+                   (goto-char opoint)
+                   ;; Put in desired marker char.
+                   (when marker-char
+                     (let ((dired-marker-char
+                            (if (integerp marker-char) marker-char
+                              dired-marker-char)))
+                       (dired-mark nil)))
+                   ;; Compensate for a bug in ange-ftp.
+                   ;; It inserts the file's absolute name, rather than
+                   ;; the relative one.  That may be hard to fix since it
+                   ;; is probably controlled by something in ftp.
+                   (goto-char opoint)
+                   (let ((inserted-name (dired-get-filename 'verbatim)))
+                     (if (file-name-directory inserted-name)
+                         (let (props)
+                           (end-of-line)
+                           (forward-char (- (length inserted-name)))
+                           (setq props (text-properties-at (point)))
+                           (delete-char (length inserted-name))
+                           (let ((pt (point)))
+                             (insert filename)
+                             (set-text-properties pt (point) props))
+                           (forward-char 1))
+                       (forward-line 1)))
+                   (forward-line -1)
+                   (if dired-after-readin-hook
+                       ;; The subdir-alist is not affected...
+                       (save-excursion ; ...so we can run it right now:
+                         (save-restriction
+                           (beginning-of-line)
+                           (narrow-to-region (point)
+                                             (line-beginning-position 2))
+                           (run-hooks 'dired-after-readin-hook))))
+                   (dired-move-to-filename))
+                 ;; return nil if all went well
+                 nil))
+         (if reason    ; don't move away on failure
+             (goto-char opoint))
+         (not reason))) ; return t on success, nil else
+    ;; Don't do it (dired-omit-mode).
+    ;; Return t for success (perhaps we should return file-exists-p).
+    t))
 
 (defun dired-after-subdir-garbage (dir)
   ;; Return pos of first file line of DIR, skipping header and total

=== modified file 'lisp/dired-x.el'
--- a/lisp/dired-x.el   2011-02-18 07:48:40 +0000
+++ b/lisp/dired-x.el   2011-02-19 03:53:35 +0000
@@ -50,7 +50,7 @@
 ;; When loaded this code redefines the following functions of GNU Emacs:
 ;; From dired.el: dired-clean-up-after-deletion, dired-find-buffer-nocreate,
 ;; and dired-initial-position.
-;; From dired-aux.el: dired-add-entry and dired-read-shell-command.
+;; From dired-aux.el: dired-read-shell-command.
 
 ;; *Please* see the `dired-x' info pages for more details.
 
@@ -589,45 +589,6 @@
         (and fn (string-match regexp fn))))
      msg)))
 
-;; Compiler does not get fset.
-(declare-function dired-omit-old-add-entry "dired-x")
-
-;; REDEFINE.
-;; Redefine dired-aux.el's version of `dired-add-entry'
-;; Save old defun if not already done:
-(or (fboundp 'dired-omit-old-add-entry)
-    (fset 'dired-omit-old-add-entry (symbol-function 'dired-add-entry)))
-
-;; REDEFINE.
-(defun dired-omit-new-add-entry (filename &optional marker-char relative)
-  ;; This redefines dired-aux.el's dired-add-entry to avoid calling ls for
-  ;; files that are going to be omitted anyway.
-  (if dired-omit-mode
-      ;; perhaps return t without calling ls
-      (let ((omit-re (dired-omit-regexp)))
-        (if (or (string= omit-re "")
-                (not
-                 (string-match omit-re
-                               (cond
-                                ((eq 'no-dir dired-omit-localp)
-                                 filename)
-                                ((eq t dired-omit-localp)
-                                 (dired-make-relative filename))
-                                (t
-                                 (dired-make-absolute
-                                  filename
-                                  (file-name-directory filename)))))))
-            ;; if it didn't match, go ahead and add the entry
-            (dired-omit-old-add-entry filename marker-char relative)
-          ;; dired-add-entry returns t for success, perhaps we should
-          ;; return file-exists-p
-          t))
-    ;; omitting is not turned on at all
-    (dired-omit-old-add-entry filename marker-char relative)))
-
-;; Redefine it.
-(fset 'dired-add-entry 'dired-omit-new-add-entry)
-
 
 ;;; VIRTUAL DIRED MODE.
 


reply via email to

[Prev in Thread] Current Thread [Next in Thread]