bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#17482: args-out-of-range when visiting foo.todo


From: Stephen Berman
Subject: bug#17482: args-out-of-range when visiting foo.todo
Date: Wed, 14 May 2014 00:33:51 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.90 (gnu/linux)

On Tue, 13 May 2014 15:40:46 -0400 Stefan Monnier <monnier@IRO.UMontreal.CA> 
wrote:

>> -(add-to-list 'auto-mode-alist '("\\.todo\\'" . todo-mode))
>> +(add-to-list 'auto-mode-alist '("\\.todo\\'" . todo-maybe-todo-mode))
>
> I don't think it's really an improvement.
>
> The better solution is to change todo-mode so that it doesn't burp when
> used in a file that doesn't follow the expected conventions of
> todo-mode.  Make it fail more gracefully.

Are you saying todo-mode.el should keep using auto-mode-alist in the
standard way?  If so, then there are basically two cases to handle:

(i) Trying to create a file foo.todo within Emacs but outside of Todo
mode, e.g. with `M-x find-file foo.todo'.  It's no problem to make this
raise an error and tell the user to add a new file in Todo mode, as part
of my patch did; is that failing gracefully enough?

(ii) Trying to visit a file foo.todo that was created outside of Emacs.
There are several subcases to consider here:

(a) The file resides in `todo-directory', was created before loading
todo-mode and happens to be a valid Todo file: then I think there is no
problem.

(b) The file happens to be a valid Todo file but was either created
after loading todo-mode or resides outside of `todo-directory': then
using todo-mode commands confined to that file or accessing other todo
files in `todo-directory' should work all right, but that file cannot be
accessed or referenced from other todo files, which will likely result
in disrupting workflow at least, and possibly raising errors.

(c) The file format is not valid: this could (depending on the nature of
the ill-formedness) raise the todo-mode error "Invalid or missing
todo-categories sexp" and any further attempt to use Todo mode commands
may be no-ops or raise args-out-of-range or other errors.  Certain kinds
of ill-formedness can be repaired (there already is the command
todo-repair-categories-sexp), but since such a file could contain
anything, I don't see a way to add a reliable general repair mechanism,
so the only recourse is to repair the file by hand or delete it.

I don't see any way to make todo-mode always fail gracefully in cases
(iib) and (iic), but at least my patch avoids the need for such failure
when the file is outside of `todo-directory'.  (I don't have a good
suggestion for when the file resides in `todo-directory' and is invalid
or valid but created after loading todo-mode, other than to say "Don't
do that", which I think is not unreasonable advice.)

Moreover, with hindsight I think Glenn's desire to visit a file foo.todo
without putting it in Todo mode is quite reasonable, and I don't see how
to allow this if todo-mode uses auto-mode-alist in the standard way; do
you?

Steve Berman





reply via email to

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