emacs-devel
[Top][All Lists]
Advanced

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

Re: insert-directory


From: Luc Teirlinck
Subject: Re: insert-directory
Date: Mon, 24 May 2004 21:16:24 -0500 (CDT)

Actually, my previous patch could not handle `C-u i', and had some
other problems.  I now changed my mind.  I believe that `i' should, by
default, use the "-al" switches, like on MS Windows.  Certain dired
functionality gets problematic if the "-l" switch is not used.  I
would have preferred to use `dired-listing-switches' instead of "-al",
but that yields real problems if dired-listing-switches contains "-F".
As in dired, one can specify one's own switches with `C-u i'.

As a byproduct, all operating systems have once more the same value
for `dired-move-to-filename-regexp'.  It is the value I originally
used for MS Windows.

Everything seems to work a lot better than with my previous patch.

===File ~/locate-diff=======================================
*** locate.el   20 May 2004 17:14:36 -0500      1.22
--- locate.el   24 May 2004 20:53:29 -0500      
***************
*** 281,287 ****
     (define-key locate-mode-map [menu-bar mark directories] 'undefined)
     (define-key locate-mode-map [menu-bar mark symlinks]    'undefined)
  
!    (define-key locate-mode-map [mouse-2]   'locate-mouse-view-file)
     (define-key locate-mode-map "\C-c\C-t"  'locate-tags)
  
     (define-key locate-mode-map "U"       'dired-unmark-all-files)
--- 281,287 ----
     (define-key locate-mode-map [menu-bar mark directories] 'undefined)
     (define-key locate-mode-map [menu-bar mark symlinks]    'undefined)
  
!    (define-key locate-mode-map "i"         'locate-maybe-insert-subdir)
     (define-key locate-mode-map "\C-c\C-t"  'locate-tags)
  
     (define-key locate-mode-map "U"       'dired-unmark-all-files)
***************
*** 325,330 ****
--- 325,346 ----
      (goto-char (posn-point (event-start event)))
      (view-file (locate-get-filename))))
  
+ (defun locate-maybe-insert-subdir (dirname &optional
+                                          switches no-error-if-not-dir-p)
+   "Like `dired-maybe-insert-subdir', but works in `locate-mode'.
+ `locate-mode' needs a special command for this to replace its own
+ binding of `dired-actual-switches' with \"-al\", when called
+ interactively.  As with `dired-maybe-insert-subdir', you can
+ specify your own switches by providing a numeric prefix argument,
+ but you can not specify the \"-F\" switch.  For proper
+ functioning, you should specify the \"-l\" switch."
+   (interactive
+    (list (dired-get-filename)
+        (if current-prefix-arg
+            (read-string "Switches for listing: " "-al")
+          "-al")))
+   (dired-maybe-insert-subdir dirname switches no-error-if-not-dir-p))
+ 
  ;; Define a mode for locate
  ;; Default directory is set to "/" so that dired commands, which
  ;; expect to be in a tree, will work properly
***************
*** 345,353 ****
    (make-local-variable 'dired-move-to-filename-regexp)
    ;; This should support both Unix and Windoze style names
    (setq dired-move-to-filename-regexp
!       (concat "."
                (make-string (1- locate-filename-indentation) ?\ )
!               "\\(/\\|[A-Za-z]:\\)"))
    (make-local-variable 'dired-actual-switches)
    (setq dired-actual-switches "")
    (make-local-variable 'dired-permission-flags-regexp)
--- 361,370 ----
    (make-local-variable 'dired-move-to-filename-regexp)
    ;; This should support both Unix and Windoze style names
    (setq dired-move-to-filename-regexp
!       (concat "^."
                (make-string (1- locate-filename-indentation) ?\ )
!               "\\(/\\|[A-Za-z]:\\)\\|"
!               (default-value 'dired-move-to-filename-regexp)))
    (make-local-variable 'dired-actual-switches)
    (setq dired-actual-switches "")
    (make-local-variable 'dired-permission-flags-regexp)
***************
*** 386,392 ****
        (dired-insert-set-properties (elt pos 0) (elt pos 1)))))
  
  (defun locate-insert-header (search-string)
!   (let ((locate-format-string "Matches for %s")
        (locate-regexp-match
         (concat " *Matches for \\(" (regexp-quote search-string) "\\)"))
        (locate-format-args (list search-string))
--- 403,409 ----
        (dired-insert-set-properties (elt pos 0) (elt pos 1)))))
  
  (defun locate-insert-header (search-string)
!   (let ((locate-format-string " Matches for %s")
        (locate-regexp-match
         (concat " *Matches for \\(" (regexp-quote search-string) "\\)"))
        (locate-format-args (list search-string))
============================================================




reply via email to

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