From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stephen Berman Newsgroups: gmane.emacs.bugs Subject: bug#17482: args-out-of-range when visiting foo.todo Date: Wed, 14 May 2014 00:33:51 +0200 Message-ID: <87r43xz4ts.fsf@rosalinde.fritz.box> References: <87zjilzn73.fsf@rosalinde.fritz.box> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1400020533 9650 80.91.229.3 (13 May 2014 22:35:33 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 13 May 2014 22:35:33 +0000 (UTC) Cc: 17482@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed May 14 00:35:25 2014 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1WkLI9-0006tH-A5 for geb-bug-gnu-emacs@m.gmane.org; Wed, 14 May 2014 00:35:21 +0200 Original-Received: from localhost ([::1]:48384 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WkLI8-0007y2-SL for geb-bug-gnu-emacs@m.gmane.org; Tue, 13 May 2014 18:35:20 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:57207) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WkLI0-0007xJ-Jl for bug-gnu-emacs@gnu.org; Tue, 13 May 2014 18:35:18 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WkLHr-0005UX-Il for bug-gnu-emacs@gnu.org; Tue, 13 May 2014 18:35:12 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:45372) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WkLHr-0005TT-G4 for bug-gnu-emacs@gnu.org; Tue, 13 May 2014 18:35:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1WkLHq-0005cA-FV for bug-gnu-emacs@gnu.org; Tue, 13 May 2014 18:35:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stephen Berman Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 13 May 2014 22:35:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 17482 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 17482-submit@debbugs.gnu.org id=B17482.140002047421515 (code B ref 17482); Tue, 13 May 2014 22:35:02 +0000 Original-Received: (at 17482) by debbugs.gnu.org; 13 May 2014 22:34:34 +0000 Original-Received: from localhost ([127.0.0.1]:34490 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WkLHN-0005aw-8a for submit@debbugs.gnu.org; Tue, 13 May 2014 18:34:33 -0400 Original-Received: from mout.gmx.net ([212.227.15.18]:59006) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WkLHK-0005aa-FI for 17482@debbugs.gnu.org; Tue, 13 May 2014 18:34:31 -0400 Original-Received: from rosalinde.fritz.box ([89.245.115.4]) by mail.gmx.com (mrgmx002) with ESMTPSA (Nemesis) id 0MV5tl-1WJBsB3Jkb-00YRfe; Wed, 14 May 2014 00:34:23 +0200 In-Reply-To: (Stefan Monnier's message of "Tue, 13 May 2014 15:40:46 -0400") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.90 (gnu/linux) X-Provags-ID: V03:K0:fWtxskCf902/JsSmU3cAG+VS9cY6g6qdzWnXdcuTK7DmeWLHRYu hPfsJ+GUfRCJWrC5O7tvtdtP7ljv6AsFGVptpuOf/lo+5gBgUqa3+vaAHV7yhpBg397G4wj JnSjjP66e/hQyliAQuIMyCbMsFXAv0F04dZA4JsFpFHpVEUJYKZ49xwQMVN7SR+IdTiRinm VHCnVoKFnS4IC1kz82IHA== X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:89049 Archived-At: On Tue, 13 May 2014 15:40:46 -0400 Stefan Monnier 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