emacs-devel
[Top][All Lists]
Advanced

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

TODO mode small bug, but maybe PC-completion guilty?


From: Michaël Cadilhac
Subject: TODO mode small bug, but maybe PC-completion guilty?
Date: Thu, 04 Jan 2007 13:41:41 +0100
User-agent: Gnus/5.110006 (No Gnus v0.6) Emacs/22.0.92 (gnu/linux)

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:

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 <address@hidden>
--- 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 <address@hidden>
***************
*** 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  <address@hidden>
+ 
+       * 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.
+ 
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:

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  <address@hidden>
+ 
+       * complete.el (PC-do-completion): Delete duplicates in the list of
+       possible completions.
+ 
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: address@hidden'                                   -  --'

Attachment: pgpcknNeU7tp_.pgp
Description: PGP signature


reply via email to

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