emacs-devel
[Top][All Lists]
Advanced

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

ido with merged directories.


From: Michaël Cadilhac
Subject: ido with merged directories.
Date: Fri, 08 Sep 2006 21:06:01 +0200
User-agent: Gnus/5.110006 (No Gnus v0.6) Emacs/22.0.50 (gnu/linux)

ido makes the error of considering that `ido-matches' is always of the
form '("a" "b"  "c"). However, with merged directories,  it could have
the form '(("a" "b") "c").

This triggers many bugs.

I can make a first try of a fix, but it is probably wrong and I think
each modification should be carefully proofread.

Thanks!

Index: lisp/ido.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/ido.el,v
retrieving revision 1.103
diff -c -r1.103 ido.el
*** lisp/ido.el 5 Sep 2006 10:26:35 -0000       1.103
--- lisp/ido.el 8 Sep 2006 18:51:22 -0000
***************
*** 1016,1022 ****
    "Stores the users strings when user hits M-b/M-f.")
  
  (defvar ido-matches nil
!   "List of files currently matching `ido-text'.")
  
  (defvar ido-report-no-match t
    "Report [No Match] when no completions matches `ido-text'.")
--- 1016,1023 ----
    "Stores the users strings when user hits M-b/M-f.")
  
  (defvar ido-matches nil
!   "List of files currently matching `ido-text'.
! The elements could be lists of directories on multiple directory choices.")
  
  (defvar ido-report-no-match t
    "Report [No Match] when no completions matches `ido-text'.")
***************
*** 1286,1291 ****
--- 1287,1298 ----
            (insert (or sep "\n ")))))
      (insert "\n)\n")))
  
+ (defun ido-get-first-match ()
+   ;; Get the first item in `ido-matches', supposed to be non-nil.
+   (if (listp (car ido-matches))
+       (caar ido-matches)
+     (car ido-matches)))
+ 
  (defun ido-save-history ()
    "Save ido history and cache information between sessions."
    (interactive)
***************
*** 2052,2058 ****
                      (null ido-matches))
                  ido-final-text
                ;; else take head of list
!               (ido-name (car ido-matches))))
  
        (cond
         ((memq item '(buffer list))
--- 2059,2065 ----
                      (null ido-matches))
                  ido-final-text
                ;; else take head of list
!               (ido-name (ido-get-first-match))))
  
        (cond
         ((memq item '(buffer list))
***************
*** 2112,2118 ****
  (defun ido-edit-input ()
    "Edit absolute file name entered so far with ido; terminate by RET."
    (interactive)
!   (setq ido-text-init (if ido-matches (car ido-matches) ido-text))
    (setq ido-exit 'edit)
    (exit-minibuffer))
  
--- 2119,2125 ----
  (defun ido-edit-input ()
    "Edit absolute file name entered so far with ido; terminate by RET."
    (interactive)
!   (setq ido-text-init (if ido-matches (ido-get-first-match) ido-text))
    (setq ido-exit 'edit)
    (exit-minibuffer))
  
***************
*** 2426,2438 ****
       ((and (= 1 (length ido-matches))
           (not (and ido-enable-tramp-completion
                     (string-equal ido-current-directory "/")
!                    (string-match "..[@:]\\'" (car ido-matches)))))
        ;; only one choice, so select it.
        (if (not ido-confirm-unique-completion)
          (exit-minibuffer)
        (setq ido-rescan (not ido-enable-prefix))
        (delete-region (minibuffer-prompt-end) (point))
!       (insert (car ido-matches))))
  
       (t ;; else there could be some completions
        (setq res ido-common-match-string)
--- 2433,2445 ----
       ((and (= 1 (length ido-matches))
           (not (and ido-enable-tramp-completion
                     (string-equal ido-current-directory "/")
!                    (string-match "..[@:]\\'" (ido-get-first-match)))))
        ;; only one choice, so select it.
        (if (not ido-confirm-unique-completion)
          (exit-minibuffer)
        (setq ido-rescan (not ido-enable-prefix))
        (delete-region (minibuffer-prompt-end) (point))
!       (insert (ido-get-first-match))))
  
       (t ;; else there could be some completions
        (setq res ido-common-match-string)
***************
*** 2814,2820 ****
    "Use first matching item as input text."
    (interactive)
    (when ido-matches
!     (setq ido-text-init (car ido-matches))
      (setq ido-exit 'refresh)
      (exit-minibuffer)))
  
--- 2821,2827 ----
    "Use first matching item as input text."
    (interactive)
    (when ido-matches
!     (setq ido-text-init (ido-get-first-match))
      (setq ido-exit 'refresh)
      (exit-minibuffer)))
  
***************
*** 2828,2834 ****
    "Move to previous directory in file name, push first match on stack."
    (interactive)
    (if ido-matches
!       (setq ido-text (car ido-matches)))
    (setq ido-exit 'push)
    (exit-minibuffer))
  
--- 2835,2841 ----
    "Move to previous directory in file name, push first match on stack."
    (interactive)
    (if ido-matches
!       (setq ido-text (ido-get-first-match)))
    (setq ido-exit 'push)
    (exit-minibuffer))
  
***************
*** 3745,3751 ****
    "Kill the buffer at the head of `ido-matches'."
    (interactive)
    (let ((enable-recursive-minibuffers t)
!       (buf (car ido-matches)))
      (when buf
        (kill-buffer buf)
        ;; Check if buffer still exists.
--- 3752,3758 ----
    "Kill the buffer at the head of `ido-matches'."
    (interactive)
    (let ((enable-recursive-minibuffers t)
!       (buf (ido-get-first-match)))
      (when buf
        (kill-buffer buf)
        ;; Check if buffer still exists.
***************
*** 3760,3766 ****
    "Delete the file at the head of `ido-matches'."
    (interactive)
    (let ((enable-recursive-minibuffers t)
!       (file (car ido-matches)))
      (if file
        (setq file (concat ido-current-directory file)))
      (when (and file
--- 3767,3773 ----
    "Delete the file at the head of `ido-matches'."
    (interactive)
    (let ((enable-recursive-minibuffers t)
!       (file (ido-get-first-match)))
      (if file
        (setq file (concat ido-current-directory file)))
      (when (and file
***************
*** 3774,3780 ****
          ;; file could not be deleted
          (setq ido-rescan t)
        ;; else file was killed so remove name from list.
!       (setq ido-cur-list (delq (car ido-matches) ido-cur-list))))))
  
  
  ;;; VISIT CHOSEN BUFFER
--- 3781,3787 ----
          ;; file could not be deleted
          (setq ido-rescan t)
        ;; else file was killed so remove name from list.
!       (setq ido-cur-list (delq (ido-get-first-match) ido-cur-list))))))
  
  
  ;;; VISIT CHOSEN BUFFER
***************
*** 4202,4208 ****
            ((= (length contents) 2)
             "/")
            (ido-matches
!            (concat ido-current-directory (car ido-matches)))
            (t
             (concat ido-current-directory (substring contents 0 -1)))))
          (setq ido-text-init (substring contents -1))
--- 4209,4215 ----
            ((= (length contents) 2)
             "/")
            (ido-matches
!            (concat ido-current-directory (ido-get-first-match)))
            (t
             (concat ido-current-directory (substring contents 0 -1)))))
          (setq ido-text-init (substring contents -1))
***************
*** 4238,4249 ****
                   ido-matches
                   (or (eq ido-enter-matching-directory 'first)
                       (null (cdr ido-matches)))
!                  (ido-final-slash (car ido-matches))
                   (or try-single-dir-match
                       (eq ido-enter-matching-directory t)))
!         (ido-trace "single match" (car ido-matches))
          (ido-set-current-directory
!          (concat ido-current-directory (car ido-matches)))
          (setq ido-exit 'refresh)
          (exit-minibuffer))
  
--- 4245,4256 ----
                   ido-matches
                   (or (eq ido-enter-matching-directory 'first)
                       (null (cdr ido-matches)))
!                  (ido-final-slash (ido-get-first-match))
                   (or try-single-dir-match
                       (eq ido-enter-matching-directory t)))
!         (ido-trace "single match" (ido-get-first-match))
          (ido-set-current-directory
!          (concat ido-current-directory (ido-get-first-match)))
          (setq ido-exit 'refresh)
          (exit-minibuffer))
  
Index: lisp/ChangeLog
===================================================================
RCS file: /sources/emacs/emacs/lisp/ChangeLog,v
retrieving revision 1.10012
diff -c -0 -r1.10012 ChangeLog
*** lisp/ChangeLog      7 Sep 2006 10:12:39 -0000       1.10012
--- lisp/ChangeLog      8 Sep 2006 18:51:32 -0000
***************
*** 0 ****
--- 1,11 ----
+ 2006-09-08  Michaël Cadilhac  <address@hidden>
+ 
+       * ido.el (ido-get-first-match): New.  Get the first element of
+       `ido-matches', even in case of merged directories.
+       (ido-matches): Document the fact that it can contain list of
+       directories.
+       (ido-read-internal, ido-edit-input, ido-complete)
+       (ido-take-first-match, ido-push-dir-first)
+       (ido-kill-buffer-at-head, ido-delete-file-at-head)
+       (ido-exhibit): Use `ido-get-first-match'.
+ 
(To Kim: Oops, I made a mistake in the mail address of emacs-devel in
the mail I sent you)

-- 
 |      Michaël `Micha' Cadilhac   |  Si les religions etaient aussi tole-  |
 |         Epita/LRDE Promo 2007   |  rantes qu'elles le pretendent, il y   |
 | http://www.lrde.org/~cadilh_m   |  a longtemps qu'il n'y en aurait plus  |
 `--  -   JID: address@hidden --'           -- Moustic              -  --'

Attachment: pgp1cGGiPOghv.pgp
Description: PGP signature


reply via email to

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