unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* ido with merged directories.
@ 2006-09-08 19:06 Michaël Cadilhac
  2006-09-09 23:13 ` Kim F. Storm
  0 siblings, 1 reply; 4+ messages in thread
From: Michaël Cadilhac @ 2006-09-08 19:06 UTC (permalink / raw)



[-- Attachment #1.1.1: Type: text/plain, Size: 326 bytes --]


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!


[-- Attachment #1.1.2: ido.patch --]
[-- Type: text/x-patch, Size: 8268 bytes --]

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  <michael.cadilhac@lrde.org>
+ 
+ 	* 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'.
+ 

[-- Attachment #1.1.3: Type: text/plain, Size: 418 bytes --]


(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: micha@amessage.be --'           -- Moustic              -  --'

[-- Attachment #1.2: Type: application/pgp-signature, Size: 188 bytes --]

[-- Attachment #2: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: ido with merged directories.
  2006-09-08 19:06 ido with merged directories Michaël Cadilhac
@ 2006-09-09 23:13 ` Kim F. Storm
  2006-09-10  9:37   ` Michaël Cadilhac
  0 siblings, 1 reply; 4+ messages in thread
From: Kim F. Storm @ 2006-09-09 23:13 UTC (permalink / raw)
  Cc: emacs-devel

michael.cadilhac@lrde.org (Michaël Cadilhac) writes:

> 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").

Yes, and the function ido-name converts such entries to the proper form.
Some of your fixes are thus no-ops.

But it may seem like some other (car ido-matches) need be passed through
ido-name.  It is not obvious which.  

> This triggers many bugs.

Please give me concrete examples.

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

Indeed.  I'll check each occurrence.

Thanks.

-- 
Kim F. Storm <storm@cua.dk> http://www.cua.dk

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: ido with merged directories.
  2006-09-09 23:13 ` Kim F. Storm
@ 2006-09-10  9:37   ` Michaël Cadilhac
  2006-09-10 22:18     ` Kim F. Storm
  0 siblings, 1 reply; 4+ messages in thread
From: Michaël Cadilhac @ 2006-09-10  9:37 UTC (permalink / raw)
  Cc: emacs-devel


[-- Attachment #1.1: Type: text/plain, Size: 1328 bytes --]

storm@cua.dk (Kim F. Storm) writes:

> michael.cadilhac@lrde.org (Michaël Cadilhac) writes:
>
>> 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").
>
> Yes, and the function ido-name converts such entries to the proper form.
> Some of your fixes are thus no-ops.

The one of
! 		(ido-name (car ido-matches))))
is, indeed.

>> This triggers many bugs.
>
> Please give me concrete examples.

This is quite difficult, in fact.  Well, I've no from-scratch test
case, but I can trigger bug with the following :
- I have many src/ directories, one in my ~. I enter ``~/dd/src'', the
  ~/dd directory doesn't exist.  Ido proposes « src/^, lib-src/ ».
  I type « src/ », if I add a character, a bug is triggered in
  ido-inhibit.
- I have a src/^, I hit C-e to edit the line.
- Same, I hit M-\s
- Same for ido-delete-file-at-head, ido-push-dir-first, at least.

-- 
 |      Michaël `Micha' Cadilhac   |  Isn't vi that text editor with        |
 |         Epita/LRDE Promo 2007   |   two modes... One that beeps and      |
 | http://www.lrde.org/~cadilh_m   |     one that corrupts your file?       |
 `--  -   JID: micha@amessage.be --'           -- Dan Jacobson         -  --'

[-- Attachment #1.2: Type: application/pgp-signature, Size: 188 bytes --]

[-- Attachment #2: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: ido with merged directories.
  2006-09-10  9:37   ` Michaël Cadilhac
@ 2006-09-10 22:18     ` Kim F. Storm
  0 siblings, 0 replies; 4+ messages in thread
From: Kim F. Storm @ 2006-09-10 22:18 UTC (permalink / raw)
  Cc: emacs-devel

michael.cadilhac@lrde.org (Michaël Cadilhac) writes:

>> Please give me concrete examples.
>
> This is quite difficult, in fact.  Well, I've no from-scratch test
> case, but I can trigger bug with the following :
> - I have many src/ directories, one in my ~. I enter ``~/dd/src'', the
>   ~/dd directory doesn't exist.  Ido proposes « src/^, lib-src/ ».
>   I type « src/ », if I add a character, a bug is triggered in
>   ido-inhibit.
> - I have a src/^, I hit C-e to edit the line.
> - Same, I hit M-\s
> - Same for ido-delete-file-at-head, ido-push-dir-first, at least.

Thanks.

I have installed changes to fix this.  Please see if you can find 
problems after those changes.

-- 
Kim F. Storm <storm@cua.dk> http://www.cua.dk

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2006-09-10 22:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-09-08 19:06 ido with merged directories Michaël Cadilhac
2006-09-09 23:13 ` Kim F. Storm
2006-09-10  9:37   ` Michaël Cadilhac
2006-09-10 22:18     ` Kim F. Storm

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).