emacs-devel
[Top][All Lists]
Advanced

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

files.el


From: Luc Teirlinck
Subject: files.el
Date: Wed, 17 Mar 2004 22:32:07 -0600 (CST)

The function `insert-directory' is supposed to be able to handle both
a second argument that is a string of options _and_ a second argument
that is a list of strings of individual options.  However, it
currently can not, as the ielm run below shows.  The culprit is the
code that tries to treat the "--dired" option specially.  I include a
patch that fixes the problem.  I can install if desired.

ELISP> (set-buffer "*scratch*")
#<buffer *scratch*>
ELISP> (insert-directory "~" "-Al -t" nil t)
nil
ELISP> (insert-directory "~" '("-A" "-l") nil t)
*** Eval error ***  Wrong type argument: stringp, ("-A" "-l")
ELISP> 

===File ~/files.el-diff=====================================
*** files.el.~1.680.~   Thu Mar  4 15:36:49 2004
--- files.el    Wed Mar 17 21:46:59 2004
***************
*** 4205,4218 ****
  (defun insert-directory (file switches &optional wildcard full-directory-p)
    "Insert directory listing for FILE, formatted according to SWITCHES.
  Leaves point after the inserted text.
! SWITCHES may be a string of options, or a list of strings.
  Optional third arg WILDCARD means treat FILE as shell wildcard.
  Optional fourth arg FULL-DIRECTORY-P means file is a directory and
  switches do not contain `d', so that a full listing is expected.
  
  This works by running a directory listing program
  whose name is in the variable `insert-directory-program'.
! If WILDCARD, it also runs the shell specified by `shell-file-name'."
    ;; We need the directory in order to find the right handler.
    (let ((handler (find-file-name-handler (expand-file-name file)
                                         'insert-directory)))
--- 4205,4224 ----
  (defun insert-directory (file switches &optional wildcard full-directory-p)
    "Insert directory listing for FILE, formatted according to SWITCHES.
  Leaves point after the inserted text.
! SWITCHES may be a string of options, or a list of strings
! representing individual options.
  Optional third arg WILDCARD means treat FILE as shell wildcard.
  Optional fourth arg FULL-DIRECTORY-P means file is a directory and
  switches do not contain `d', so that a full listing is expected.
  
  This works by running a directory listing program
  whose name is in the variable `insert-directory-program'.
! If WILDCARD, it also runs the shell specified by `shell-file-name'.
! 
! When SWITCHES contains the long `--dired' option,this function
! treats it specially, for the sake of dired.  However, the
! normally equivalent short `-D' option is just passed on to
! `insert-directory-program', as any other option."
    ;; We need the directory in order to find the right handler.
    (let ((handler (find-file-name-handler (expand-file-name file)
                                         'insert-directory)))
***************
*** 4301,4307 ****
              (access-file file "Reading directory")
              (error "Listing directory failed but `access-file' worked")))
  
!         (when (string-match "--dired\\>" switches)
            (forward-line -2)
              (when (looking-at "//SUBDIRED//")
                (delete-region (point) (progn (forward-line 1) (point)))
--- 4307,4318 ----
              (access-file file "Reading directory")
              (error "Listing directory failed but `access-file' worked")))
  
!         (when (if (stringp switches)
!                   (string-match "--dired\\>" switches)
!                 (catch 'found
!                   (dolist (str switches)
!                     (when (string= "--dired" str)
!                       (throw 'found t)))))
            (forward-line -2)
              (when (looking-at "//SUBDIRED//")
                (delete-region (point) (progn (forward-line 1) (point)))
============================================================




reply via email to

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