/[emacs]/emacs/lisp/ido.el
ViewVC logotype

Diff of /emacs/lisp/ido.el

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.22 by kfstorm, Tue Jan 14 21:12:20 2003 UTC revision 1.23 by kfstorm, Tue Jan 14 21:31:47 2003 UTC
# Line 1621  If INITIAL is non-nil, it specifies the Line 1621  If INITIAL is non-nil, it specifies the
1621                   (edit (eq ido-exit 'edit))                   (edit (eq ido-exit 'edit))
1622                   (d ido-current-directory)                   (d ido-current-directory)
1623                   (f ido-text-init)                   (f ido-text-init)
1624                   (path t))                   (new t))
1625              (setq ido-text-init "")              (setq ido-text-init "")
1626              (while path              (while new
1627                (setq path (if edit                (setq new (if edit
1628                               (read-file-name (concat prompt "[EDIT] ") d (concat d f) nil f)                               (read-file-name (concat prompt "[EDIT] ") d (concat d f) nil f)
1629                             f)                             f)
1630                      d (or (file-name-directory path) "/")                      d (or (file-name-directory new) "/")
1631                      f (file-name-nondirectory path)                      f (file-name-nondirectory new)
1632                      edit t)                      edit t)
1633                (if (or                (if (or
1634                     (file-directory-p d)                     (file-directory-p d)
# Line 1642  If INITIAL is non-nil, it specifies the Line 1642  If INITIAL is non-nil, it specifies the
1642                    (progn                    (progn
1643                      (ido-set-current-directory d nil (eq ido-exit 'chdir))                      (ido-set-current-directory d nil (eq ido-exit 'chdir))
1644                      (setq ido-text-init f                      (setq ido-text-init f
1645                            path nil))))))                            new nil))))))
1646           (t           (t
1647            (setq ido-text-init (read-string (concat prompt "[EDIT] ") ido-final-text))))            (setq ido-text-init (read-string (concat prompt "[EDIT] ") ido-final-text))))
1648          nil)          nil)
# Line 1868  If INITIAL is non-nil, it specifies the Line 1868  If INITIAL is non-nil, it specifies the
1868         ((memq method '(dired list-directory))         ((memq method '(dired list-directory))
1869          (if (equal filename ".")          (if (equal filename ".")
1870              (setq filename ""))              (setq filename ""))
1871          (let* ((path (ido-final-slash (concat ido-current-directory filename) t))          (let* ((dirname (ido-final-slash (concat ido-current-directory filename) t))
1872                 (file (substring path 0 -1)))                 (file (substring dirname 0 -1)))
1873            (cond            (cond
1874             ((file-directory-p path)             ((file-directory-p dirname)
1875              (ido-record-command method path)              (ido-record-command method dirname)
1876              (ido-record-work-directory path)              (ido-record-work-directory dirname)
1877              (funcall method path))              (funcall method dirname))
1878             ((file-directory-p ido-current-directory)             ((file-directory-p ido-current-directory)
1879              (cond              (cond
1880               ((file-exists-p file)               ((file-exists-p file)
# Line 1884  If INITIAL is non-nil, it specifies the Line 1884  If INITIAL is non-nil, it specifies the
1884                (if (eq method 'dired)                (if (eq method 'dired)
1885                    (dired-goto-file (expand-file-name file))))                    (dired-goto-file (expand-file-name file))))
1886               ((string-match "[[*?]" filename)               ((string-match "[[*?]" filename)
1887                (setq path (concat ido-current-directory filename))                (setq dirname (concat ido-current-directory filename))
1888                (ido-record-command method path)                (ido-record-command method dirname)
1889                (ido-record-work-directory)                (ido-record-work-directory)
1890                (funcall method path))                (funcall method dirname))
1891               ((y-or-n-p (format "Directory %s does not exist. Create it " filename))               ((y-or-n-p (format "Directory %s does not exist. Create it " filename))
1892                (ido-record-command method path)                (ido-record-command method dirname)
1893                (ido-record-work-directory path)                (ido-record-work-directory dirname)
1894                (make-directory-internal path)                (make-directory-internal dirname)
1895                (funcall method path))                (funcall method dirname))
1896               (t               (t
1897                ;; put make-directory command on history                ;; put make-directory command on history
1898                (ido-record-command 'make-directory path))))                (ido-record-command 'make-directory dirname))))
1899             (t (error "No such directory")))))             (t (error "No such directory")))))
1900    
1901         ((eq method 'write)         ((eq method 'write)
# Line 2305  If no buffer or file exactly matching th Line 2305  If no buffer or file exactly matching th
2305    "Insert file name of current buffer.    "Insert file name of current buffer.
2306  If repeated, insert text from buffer instead."  If repeated, insert text from buffer instead."
2307    (interactive "P")    (interactive "P")
2308    (let* ((path (buffer-file-name ido-entry-buffer))    (let* ((bfname (buffer-file-name ido-entry-buffer))
2309           (name (and path (file-name-nondirectory path))))           (name (and bfname (file-name-nondirectory bfname))))
2310      (when name      (when name
2311        (setq ido-text-init        (setq ido-text-init
2312              (if (or all              (if (or all
2313                      (not (equal (file-name-directory path) ido-current-directory))                      (not (equal (file-name-directory bfname) ido-current-directory))
2314                      (not (string-match "\\.[^.]*\\'" name)))                      (not (string-match "\\.[^.]*\\'" name)))
2315                  name                  name
2316              (substring name 0 (1+ (match-beginning 0)))))              (substring name 0 (1+ (match-beginning 0)))))
# Line 2477  for first matching file." Line 2477  for first matching file."
2477    
2478  (defun ido-wide-find-dirs-or-files (dir file &optional prefix finddir)  (defun ido-wide-find-dirs-or-files (dir file &optional prefix finddir)
2479    ;; As ido-run-find-command, but returns a list of cons pairs ("file" . "dir")    ;; As ido-run-find-command, but returns a list of cons pairs ("file" . "dir")
2480    (let ((paths    (let ((filenames
2481           (split-string           (split-string
2482            (shell-command-to-string            (shell-command-to-string
2483             (concat "find " dir " -name \"" (if prefix "" "*") file "*\" -type " (if finddir "d" "f") " -print"))))             (concat "find " dir " -name \"" (if prefix "" "*") file "*\" -type " (if finddir "d" "f") " -print"))))
2484          path d f          filename d f
2485          res)          res)
2486      (while paths      (while filenames
2487        (setq path (car paths)        (setq filename (car filenames)
2488              paths (cdr paths))              filenames (cdr filenames))
2489        (if (and (string-match "^/" path)        (if (and (string-match "^/" filename)
2490                 (file-exists-p path))                 (file-exists-p filename))
2491            (setq d (file-name-directory path)            (setq d (file-name-directory filename)
2492                  f (file-name-nondirectory path)                  f (file-name-nondirectory filename)
2493                  res (cons (cons (if finddir (ido-final-slash f t) f) d) res))))                  res (cons (cons (if finddir (ido-final-slash f t) f) d) res))))
2494      res))      res))
2495    

Legend:
Removed from v.1.22  
changed lines
  Added in v.1.23

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26