unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* TODO mode small bug, but maybe PC-completion guilty?
@ 2007-01-04 12:41 Michaël Cadilhac
  2007-01-06  2:55 ` Richard Stallman
  0 siblings, 1 reply; 2+ messages in thread
From: Michaël Cadilhac @ 2007-01-04 12:41 UTC (permalink / raw)



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

Hi!

Here's a recipe for the bug:
$ rm ~/.todo-do
$ emacs -Q
M-x partial-completion-mode
M-x todo-show
C-x C-b *scratch* RET
M-x todo-show
j Todo TAB TAB TAB

Error: PC-complete: Wrong type argument: sequencep, t

Okey, the problem is simple. `completing-read' is called with ("Todo"
"Todo") or the equivalent alist. PC-do-complete has a match with
"Todo", but it is not the only one, so he wants to find the common
prefix:
(setq prefix (try-completion (PC-chunk-after basestr skip)
                                                  poss)))
Sadly enough, try-completion returns `t'. Gosh.

I think that both files are to be fixed.  First, don't allow duplicates
in todo-mode:


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

Index: lisp/calendar/todo-mode.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/calendar/todo-mode.el,v
retrieving revision 1.57
diff -c -r1.57 todo-mode.el
*** lisp/calendar/todo-mode.el	8 Feb 2006 07:54:11 -0000	1.57
--- lisp/calendar/todo-mode.el	4 Jan 2007 12:06:10 -0000
***************
*** 1,6 ****
  ;;; todo-mode.el --- major mode for editing TODO list files
  
! ;; Copyright (C) 1997, 1999, 2001, 2002, 2003, 2004, 2005, 2006
  ;;   Free Software Foundation, Inc.
  
  ;; Author: Oliver Seidel <os10000@seidel-space.de>
--- 1,6 ----
  ;;; todo-mode.el --- major mode for editing TODO list files
  
! ;; Copyright (C) 1997, 1999, 2001, 2002, 2003, 2004, 2005, 2006, 2007
  ;;   Free Software Foundation, Inc.
  
  ;; Author: Oliver Seidel <os10000@seidel-space.de>
***************
*** 532,555 ****
  (defun todo-add-category (cat)
    "Add new category CAT to the TODO list."
    (interactive "sCategory: ")
!   (save-window-excursion
!     (setq todo-categories (cons cat todo-categories))
!     (find-file todo-file-do)
!     (widen)
!     (goto-char (point-min))
!     (let ((posn (search-forward "-*- mode: todo; " 17 t)))
!       (if (not (null posn)) (goto-char posn))
!       (if (equal posn nil)
!           (progn
!             (insert "-*- mode: todo; \n")
!             (forward-char -1))
!         (kill-line)))
!     (insert (format "todo-categories: %S; -*-" todo-categories))
!     (forward-char 1)
!     (insert (format "%s%s%s\n%s\n%s %s\n"
!                     todo-prefix todo-category-beg cat
!                     todo-category-end
!                     todo-prefix todo-category-sep)))
    0)
  
  ;;;###autoload
--- 532,557 ----
  (defun todo-add-category (cat)
    "Add new category CAT to the TODO list."
    (interactive "sCategory: ")
!   (if (member cat todo-categories)
!       (error "This category already exists")
!     (save-window-excursion
!       (setq todo-categories (cons cat todo-categories))
!       (find-file todo-file-do)
!       (widen)
!       (goto-char (point-min))
!       (let ((posn (search-forward "-*- mode: todo; " 17 t)))
! 	(if (not (null posn)) (goto-char posn))
! 	(if (equal posn nil)
! 	    (progn
! 	      (insert "-*- mode: todo; \n")
! 	      (forward-char -1))
! 	  (kill-line)))
!       (insert (format "todo-categories: %S; -*-" todo-categories))
!       (forward-char 1)
!       (insert (format "%s%s%s\n%s\n%s %s\n"
! 		      todo-prefix todo-category-beg cat
! 		      todo-category-end
! 		      todo-prefix todo-category-sep))))
    0)
  
  ;;;###autoload
***************
*** 952,957 ****
--- 954,961 ----
    (find-file todo-file-do)
    (erase-buffer)
    (todo-mode)
+   (setq todo-categories nil
+ 	todo-cats nil)
    (todo-add-category "Todo"))
  
  (provide 'todo-mode)
Index: lisp/ChangeLog
===================================================================
RCS file: /sources/emacs/emacs/lisp/ChangeLog,v
retrieving revision 1.10526
diff -C0 -r1.10526 ChangeLog
*** lisp/ChangeLog	3 Jan 2007 20:17:09 -0000	1.10526
--- lisp/ChangeLog	4 Jan 2007 12:06:30 -0000
***************
*** 0 ****
--- 1,7 ----
+ 2007-01-04  Michaël Cadilhac  <michael.cadilhac@lrde.org>
+ 
+ 	* calendar/todo-mode.el (todo-add-category): Prevent adding a category
+ 	that already exists.
+ 	(todo-initial-setup): Make sure the setup is empty by setting the
+ 	category lists to nil.
+ 

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


Then, even if the caller of (PC-) completing-read is guilty to have
twice the same thing in his completion list, we may want to not crash
and allow it like the normal completing-read:


[-- Attachment #1.1.4: complete.patch --]
[-- Type: text/x-patch, Size: 1131 bytes --]

Index: lisp/complete.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/complete.el,v
retrieving revision 1.58
diff -c -r1.58 complete.el
*** lisp/complete.el	5 Dec 2006 05:53:57 -0000	1.58
--- lisp/complete.el	4 Jan 2007 12:39:24 -0000
***************
*** 553,558 ****
--- 553,561 ----
  		   (setq poss (cons (car p) poss))))
  	    (setq p (cdr p)))))
  
+       ;; If table had duplicates, they can be here.
+       (delete-dups poss)
+ 
        ;; Handle completion-ignored-extensions
        (and filename
             (not (eq mode 'help))
Index: lisp/ChangeLog
===================================================================
RCS file: /sources/emacs/emacs/lisp/ChangeLog,v
retrieving revision 1.10526
diff -C0 -r1.10526 ChangeLog
*** lisp/ChangeLog	3 Jan 2007 20:17:09 -0000	1.10526
--- lisp/ChangeLog	4 Jan 2007 12:39:45 -0000
***************
*** 0 ****
--- 1,5 ----
+ 2007-01-04  Michaël Cadilhac  <michael.cadilhac@lrde.org>
+ 
+ 	* complete.el (PC-do-completion): Delete duplicates in the list of
+ 	possible completions.
+ 

[-- Attachment #1.1.5: Type: text/plain, Size: 347 bytes --]


Any opinion?

-- 
 |      Michaël `Micha' Cadilhac     |  Mieux vaut se taire                   |
 |         Epita/LRDE Promo 2007     |   Que de parler trop fort.             |
 |  http://michael.cadilhac.name     |           -- As de trèfle              |
 `--JID: michael.cadilhac@gmail.com--'                                   -  --'

[-- 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] 2+ messages in thread

* Re: TODO mode small bug, but maybe PC-completion guilty?
  2007-01-04 12:41 TODO mode small bug, but maybe PC-completion guilty? Michaël Cadilhac
@ 2007-01-06  2:55 ` Richard Stallman
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Stallman @ 2007-01-06  2:55 UTC (permalink / raw)
  Cc: emacs-devel

Please install your patch in complete.el.
As for the patch in todo-mode.el, please install that too
if nobody objects in a few days.

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

end of thread, other threads:[~2007-01-06  2:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-01-04 12:41 TODO mode small bug, but maybe PC-completion guilty? Michaël Cadilhac
2007-01-06  2:55 ` Richard Stallman

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