unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#17482: args-out-of-range when visiting foo.todo
@ 2014-05-13  6:22 Glenn Morris
  2014-05-13 15:57 ` Stephen Berman
  0 siblings, 1 reply; 19+ messages in thread
From: Glenn Morris @ 2014-05-13  6:22 UTC (permalink / raw)
  To: 17482

Package: emacs
Version: 24.3.91
Severity: important

emacs -Q
C-x C-f /tmp/foo.todo
  -> args-out-of-range error

(.todo is a pretty generic extension for me. I don't want it to open a
specialized Emacs mode. I don't feel strongly about it though.
Perhaps the NEWS file should say that .todo files now open in todo-mode.
They didn't before.)

Debugger entered--Lisp error: (args-out-of-range 1 2)
  narrow-to-region(2 1)
  (let ((name (todo-current-category)) cat-begin cat-end done-start done-sep-start done-end) (widen) (goto-char (point-min)) (re-search-forward (concat "^" (regexp-quote (concat todo-category-beg name)) "$") nil t) (setq cat-begin (1+ (line-end-position))) (setq cat-end (if (re-search-forward (concat "^" (regexp-quote todo-category-beg)) nil t) (match-beginning 0) (point-max))) (setq mode-line-buffer-identification (funcall todo-mode-line-function name)) (narrow-to-region cat-begin cat-end) (todo-prefix-overlays) (goto-char (point-min)) (if (re-search-forward (concat "\n\\(" (regexp-quote todo-category-done) "\\)") nil t) (progn (setq done-start (match-beginning 0)) (setq done-sep-start (match-beginning 1)) (setq done-end (match-end 0))) (error "Category %s is missing todo-category-done string" name)) (if todo-show-done-only (narrow-to-region (1+ done-end) (point-max)) (if (and todo-show-with-done (re-search-forward todo-done-string-start nil t)) (progn (setq done-start cat-end) (let* ((done-sep todo-done-separator) (ov (progn ... ...))) (if ov nil (setq ov (make-overlay done-sep-start done-end)) (overlay-put ov (quote todo) (quote separator)) (overlay-put ov (quote display) done-sep))))) (narrow-to-region (point-min) done-start) (if todo-highlight-item (progn (require (quote hl-line)) (hl-line-mode 1)))))
  todo-category-select()
  (and (member this-command todo-visit-files-commands) (= (- (point-max) (point-min)) (buffer-size)) (member major-mode (quote (todo-mode todo-archive-mode))) (todo-category-select))
  todo-display-as-todo-file()
  run-hooks(find-file-hook)
  after-find-file(t t)
  find-file-noselect-1(#<buffer foo.todo> "/tmp/foo.todo" nil nil "/tmp/foo.todo" nil)
  find-file-noselect("/tmp/foo.todo" nil nil t)
  find-file("/tmp/foo.todo" t)
  call-interactively(find-file nil nil)
  command-execute(find-file)





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

* bug#17482: args-out-of-range when visiting foo.todo
  2014-05-13  6:22 bug#17482: args-out-of-range when visiting foo.todo Glenn Morris
@ 2014-05-13 15:57 ` Stephen Berman
  2014-05-13 16:02   ` Glenn Morris
  2014-05-13 19:40   ` Stefan Monnier
  0 siblings, 2 replies; 19+ messages in thread
From: Stephen Berman @ 2014-05-13 15:57 UTC (permalink / raw)
  To: Glenn Morris; +Cc: 17482

On Tue, 13 May 2014 02:22:35 -0400 Glenn Morris <rgm@gnu.org> wrote:

> Package: emacs
> Version: 24.3.91
> Severity: important
>
> emacs -Q
> C-x C-f /tmp/foo.todo
>   -> args-out-of-range error
>
> (.todo is a pretty generic extension for me. I don't want it to open a
> specialized Emacs mode. I don't feel strongly about it though.
> Perhaps the NEWS file should say that .todo files now open in todo-mode.
> They didn't before.)

Perhaps it was presumptuous of me to appropriate the .todo extension for
Todo mode.  I'm not aware of any policy about this, and I do see that a
number of modes add an extension to auto-mode-alist unconditionally,
while others merely suggest doing that in the user's init file.
However, I've come up with the following fix, which keeps automatic
recognition of Todo mode files located in `todo-directory', which is
where all Todo mode files are stored, but allows you to create and visit
foo.todo in the default major mode anywhere else.  If this works for you
and it's not an unacceptable abuse of auto-mode-alist, I'll commit it to
emacs-24.  Thanks for the report.

Steve Berman

=== modified file 'lisp/calendar/todo-mode.el'
*** lisp/calendar/todo-mode.el	2014-05-09 07:50:42 +0000
--- lisp/calendar/todo-mode.el	2014-05-13 15:37:39 +0000
***************
*** 6401,6411 ****
  
  (defun todo-display-as-todo-file ()
    "Show todo files correctly when visited from outside of Todo mode.
! Added to `find-file-hook' in Todo mode and Todo Archive mode."
!   (and (member this-command todo-visit-files-commands)
!        (= (- (point-max) (point-min)) (buffer-size))
!        (member major-mode '(todo-mode todo-archive-mode))
!        (todo-category-select)))
  
  (defun todo-add-to-buffer-list ()
    "Add name of just visited todo file to `todo-file-buffers'.
--- 6401,6425 ----
  
  (defun todo-display-as-todo-file ()
    "Show todo files correctly when visited from outside of Todo mode.
! Added to `find-file-hook' in Todo mode, Todo Archive mode and
! Todo Filtered Items mode.
! 
! This is intended only for visiting an existing todo, archive, or
! filtered items file, and signals an error if you try to create a
! new one using, e.g., `find-file'."
!   (if (equal (file-truename todo-directory)
! 	     (file-name-directory (file-truename (buffer-file-name))))
!       (when (member this-command todo-visit-files-commands)
! 	(if (> (buffer-size) 0)
! 	    (and (= (- (point-max) (point-min)) (buffer-size))
! 		 (memq major-mode '(todo-mode todo-archive-mode))
! 		 (todo-category-select))
! 	  (kill-buffer)
! 	  (user-error "To add a new todo file, type %s in Todo mode"
! 		      (substitute-command-keys "\\[todo-add-file]"))))
!     (kill-all-local-variables)
!     (setq buffer-read-only nil)
!     (set-buffer-major-mode (current-buffer))))
  
  (defun todo-add-to-buffer-list ()
    "Add name of just visited todo file to `todo-file-buffers'.
***************
*** 6454,6459 ****
--- 6468,6474 ----
    "Make some settings that apply to multiple Todo modes."
    (add-to-invisibility-spec 'todo)
    (setq buffer-read-only t)
+   (add-hook 'find-file-hook 'todo-display-as-todo-file nil t)
    (when (and (boundp 'desktop-save-mode) desktop-save-mode)
      (setq-local desktop-save-buffer 'todo-desktop-save-buffer))
    (when (boundp 'hl-line-range-function)
***************
*** 6466,6473 ****
  (defun todo-modes-set-3 ()
    "Make some settings that apply to multiple Todo modes."
    (setq-local todo-categories (todo-set-categories))
!   (setq-local todo-category-number 1)
!   (add-hook 'find-file-hook 'todo-display-as-todo-file nil t))
  
  (put 'todo-mode 'mode-class 'special)
  
--- 6481,6487 ----
  (defun todo-modes-set-3 ()
    "Make some settings that apply to multiple Todo modes."
    (setq-local todo-categories (todo-set-categories))
!   (setq-local todo-category-number 1))
  
  (put 'todo-mode 'mode-class 'special)
  
***************
*** 6555,6566 ****
    (todo-modes-set-1)
    (todo-modes-set-2))
  
  ;;;###autoload
! (add-to-list 'auto-mode-alist '("\\.todo\\'" . todo-mode))
  ;;;###autoload
! (add-to-list 'auto-mode-alist '("\\.toda\\'" . todo-archive-mode))
  ;;;###autoload
! (add-to-list 'auto-mode-alist '("\\.tod[tyr]\\'" . todo-filtered-items-mode))
  
  ;; -----------------------------------------------------------------------------
  (provide 'todo-mode)
--- 6569,6607 ----
    (todo-modes-set-1)
    (todo-modes-set-2))
  
+ ;; All Todo mode files reside in `todo-directory', but maybe the user
+ ;; wants to be able to have files with these extensions in other modes
+ ;; elsewhere (bug#17482).  So we conditionalize automatic major mode
+ ;; selection on the file's location.
+ 
+ ;;;###autoload
+ (defun todo-maybe-todo-mode ()
+   (if (equal (file-truename todo-directory)
+ 	     (file-name-directory (file-truename (buffer-file-name))))
+       (todo-mode)
+     (set-buffer-major-mode (current-buffer))))
+ 
+ ;;;###autoload
+ (defun todo-maybe-todo-archive-mode ()
+   (if (equal (file-truename todo-directory)
+ 	     (file-name-directory (file-truename (buffer-file-name))))
+       (todo-archive-mode)
+     (set-buffer-major-mode (current-buffer))))
+ 
+ ;;;###autoload
+ (defun todo-maybe-todo-filtered-items-mode ()
+   (if (equal (file-truename todo-directory)
+ 	     (file-name-directory (file-truename (buffer-file-name))))
+       (todo-filtered-items-mode)
+     (set-buffer-major-mode (current-buffer))))
+ 
  ;;;###autoload
! (add-to-list 'auto-mode-alist '("\\.todo\\'" . todo-maybe-todo-mode))
  ;;;###autoload
! (add-to-list 'auto-mode-alist '("\\.toda\\'" . todo-maybe-todo-archive-mode))
  ;;;###autoload
! (add-to-list 'auto-mode-alist
! 	     '("\\.tod[tyr]\\'" . todo-maybe-todo-filtered-items-mode))
  
  ;; -----------------------------------------------------------------------------
  (provide 'todo-mode)






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

* bug#17482: args-out-of-range when visiting foo.todo
  2014-05-13 15:57 ` Stephen Berman
@ 2014-05-13 16:02   ` Glenn Morris
  2014-05-13 16:26     ` Stephen Berman
  2014-05-13 19:40   ` Stefan Monnier
  1 sibling, 1 reply; 19+ messages in thread
From: Glenn Morris @ 2014-05-13 16:02 UTC (permalink / raw)
  To: Stephen Berman; +Cc: 17482

Stephen Berman wrote:

> Perhaps it was presumptuous of me to appropriate the .todo extension for
> Todo mode.  I'm not aware of any policy about this, and I do see that a
> number of modes add an extension to auto-mode-alist unconditionally,
> while others merely suggest doing that in the user's init file.
> However, I've come up with the following fix, which keeps automatic
> recognition of Todo mode files located in `todo-directory', which is
> where all Todo mode files are stored, but allows you to create and visit
> foo.todo in the default major mode anywhere else.  If this works for you
> and it's not an unacceptable abuse of auto-mode-alist, I'll commit it to
> emacs-24.  Thanks for the report.

Thanks. I'm not sure you need to go to that trouble.
As I said, I don't feel strongly about it.
It's something I'd be happy to just change in my .emacs.
Maybe wait and see if anyone else has a strong opinion, otherwise
leave as-is.

The args-out-of-range thing was what I actually wanted to report! :)





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

* bug#17482: args-out-of-range when visiting foo.todo
  2014-05-13 16:02   ` Glenn Morris
@ 2014-05-13 16:26     ` Stephen Berman
  0 siblings, 0 replies; 19+ messages in thread
From: Stephen Berman @ 2014-05-13 16:26 UTC (permalink / raw)
  To: Glenn Morris; +Cc: 17482

On Tue, 13 May 2014 12:02:51 -0400 Glenn Morris <rgm@gnu.org> wrote:

> Stephen Berman wrote:
>
>> Perhaps it was presumptuous of me to appropriate the .todo extension for
>> Todo mode.  I'm not aware of any policy about this, and I do see that a
>> number of modes add an extension to auto-mode-alist unconditionally,
>> while others merely suggest doing that in the user's init file.
>> However, I've come up with the following fix, which keeps automatic
>> recognition of Todo mode files located in `todo-directory', which is
>> where all Todo mode files are stored, but allows you to create and visit
>> foo.todo in the default major mode anywhere else.  If this works for you
>> and it's not an unacceptable abuse of auto-mode-alist, I'll commit it to
>> emacs-24.  Thanks for the report.
>
> Thanks. I'm not sure you need to go to that trouble.
> As I said, I don't feel strongly about it.
> It's something I'd be happy to just change in my .emacs.
> Maybe wait and see if anyone else has a strong opinion, otherwise
> leave as-is.
>
> The args-out-of-range thing was what I actually wanted to report! :)

Well, that error arose precisely because you tried to visit a file in
Todo mode (because of auto-mode-alist) that was not in todo-directory,
which lead to certain variables not getting set that should have been,
resulting in the error.  This was a situation I did not foresee (that
someone would want to have a *.todo file but not use Todo mode --
cheeky!).  I actually think this is the least invasive fix that would
avoid this problem.  If I untie the extensions from auto-mode-alist, I
think it will require quite a bit more alteration of todo-mode.el.  So,
if there are no serious objections, I'd just as soon apply this patch.

Steve Berman





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

* bug#17482: args-out-of-range when visiting foo.todo
  2014-05-13 15:57 ` Stephen Berman
  2014-05-13 16:02   ` Glenn Morris
@ 2014-05-13 19:40   ` Stefan Monnier
  2014-05-13 22:33     ` Stephen Berman
  1 sibling, 1 reply; 19+ messages in thread
From: Stefan Monnier @ 2014-05-13 19:40 UTC (permalink / raw)
  To: Stephen Berman; +Cc: 17482

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


        Stefan





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

* bug#17482: args-out-of-range when visiting foo.todo
  2014-05-13 19:40   ` Stefan Monnier
@ 2014-05-13 22:33     ` Stephen Berman
  2014-05-14  3:22       ` Stefan Monnier
  0 siblings, 1 reply; 19+ messages in thread
From: Stephen Berman @ 2014-05-13 22:33 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 17482

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





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

* bug#17482: args-out-of-range when visiting foo.todo
  2014-05-13 22:33     ` Stephen Berman
@ 2014-05-14  3:22       ` Stefan Monnier
  2014-05-14 15:10         ` Stephen Berman
  0 siblings, 1 reply; 19+ messages in thread
From: Stefan Monnier @ 2014-05-14  3:22 UTC (permalink / raw)
  To: Stephen Berman; +Cc: 17482

> Are you saying todo-mode.el should keep using auto-mode-alist in the
> standard way?

Yes.

> 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?

Why do you need to signal an error?

For me the driving design should be that code that doesn't use todo-mode
commands should be able to find-file any file with a ".todo" extension,
make changes to it via things like delete-region and insert and then
save the file.  And all this without errors.

As soon as the user actually uses a todo-mode command, you can signal
any error you like, of course.


        Stefan





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

* bug#17482: args-out-of-range when visiting foo.todo
  2014-05-14  3:22       ` Stefan Monnier
@ 2014-05-14 15:10         ` Stephen Berman
  2014-05-14 16:55           ` Stefan Monnier
  0 siblings, 1 reply; 19+ messages in thread
From: Stephen Berman @ 2014-05-14 15:10 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 17482

On Tue, 13 May 2014 23:22:56 -0400 Stefan Monnier <monnier@IRO.UMontreal.CA> wrote:

>> Are you saying todo-mode.el should keep using auto-mode-alist in the
>> standard way?
>
> Yes.
>
>> 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?
>
> Why do you need to signal an error?
>
> For me the driving design should be that code that doesn't use todo-mode
> commands should be able to find-file any file with a ".todo" extension,
> make changes to it via things like delete-region and insert and then
> save the file.  And all this without errors.
>
> As soon as the user actually uses a todo-mode command, you can signal
> any error you like, of course.

Unfortunately, I didn't pay heed to your design goals while implementing
todo-mode (I wasn't aware of them).  But there's a fairly easy way to
accommodate them, and as a side effect avoid the bug Glenn reported and
also accommodate his wish to do `M-x find-file foo.todo' without putting
the file in Todo mode: by simply foregoing use of auto-mode-alist.
Really, it was misguided of me to want to use it, because by design and
intent all Todo files reside in `todo-directory', so on the one hand
auto-mode-alist isn't necessary, and on the other hand any file foo.todo
located elsewhere but put in Todo mode can be problematic.

If I make this change, it will also require abandoning one of the
documented features of Todo mode: that visiting a todo file in any way
(or rather, any way listed by `todo-visit-files-commands') will
automatically display it correctly in Todo mode, i.e., read-only and
narrowed to the selected category, with internal formatting hidden.  But
that feature conflicts with your design goals, and anyway it's only a
minor convenience at best, and at worst leads to bugs, as Glenn's report
shows.

If you agree with my proposal, I'll start implementing it.  I don't
anticipate any major hurdles, but since a lot of the current code relies
on the effects of using auto-mode-alist, it may take some time for me to
test the changes and make sure everything still works as it should.  But
I think any attempt to retain use of auto-mode-alist and also comply
with your design goals will be much more difficult to work out.

Steve Berman





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

* bug#17482: args-out-of-range when visiting foo.todo
  2014-05-14 15:10         ` Stephen Berman
@ 2014-05-14 16:55           ` Stefan Monnier
  2014-05-14 17:46             ` Glenn Morris
  0 siblings, 1 reply; 19+ messages in thread
From: Stefan Monnier @ 2014-05-14 16:55 UTC (permalink / raw)
  To: Stephen Berman; +Cc: 17482

> Unfortunately, I didn't pay heed to your design goals while implementing
> todo-mode (I wasn't aware of them).  But there's a fairly easy way to
> accommodate them, and as a side effect avoid the bug Glenn reported and
> also accommodate his wish to do `M-x find-file foo.todo' without putting
> the file in Todo mode: by simply foregoing use of auto-mode-alist.
> Really, it was misguided of me to want to use it, because by design and
> intent all Todo files reside in `todo-directory', so on the one hand
> auto-mode-alist isn't necessary, and on the other hand any file foo.todo
> located elsewhere but put in Todo mode can be problematic.

Maybe a quick way to "reach" the design goal is to wrap the body of
todo-mode in a `with-demoted-errors'.


        Stefan





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

* bug#17482: args-out-of-range when visiting foo.todo
  2014-05-14 16:55           ` Stefan Monnier
@ 2014-05-14 17:46             ` Glenn Morris
  2014-05-14 19:57               ` Stephen Berman
  0 siblings, 1 reply; 19+ messages in thread
From: Glenn Morris @ 2014-05-14 17:46 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Stephen Berman, 17482

Stefan Monnier wrote:

> Maybe a quick way to "reach" the design goal is to wrap the body of
> todo-mode in a `with-demoted-errors'.

It's better, but I think it's still not great if I visit blah.todo and
get "args-out-of-range" as a message rather than an error.





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

* bug#17482: args-out-of-range when visiting foo.todo
  2014-05-14 17:46             ` Glenn Morris
@ 2014-05-14 19:57               ` Stephen Berman
  2014-05-14 20:01                 ` Glenn Morris
  2014-05-23 16:59                 ` Stephen Berman
  0 siblings, 2 replies; 19+ messages in thread
From: Stephen Berman @ 2014-05-14 19:57 UTC (permalink / raw)
  To: Glenn Morris; +Cc: 17482

On Wed, 14 May 2014 13:46:33 -0400 Glenn Morris <rgm@gnu.org> wrote:

> Stefan Monnier wrote:
>
>> Maybe a quick way to "reach" the design goal is to wrap the body of
>> todo-mode in a `with-demoted-errors'.
>
> It's better, but I think it's still not great if I visit blah.todo and
> get "args-out-of-range" as a message rather than an error.

I agree.  Moreover, if blah.todo is not empty but not a valid Todo file,
visiting it will raise a different error from a different part of the
code, so it would be necessary to have multiple uses of
`with-demoted-errors'.  And there's still the issue of why *.todo files
not in `todo-directory' should be in Todo mode.  And the only sensible
answer is: they shouldn't be.  So I am convinced that todo-mode should
not use auto-mode-alist: it's not needed and it only causes problems.  I
somehow became blinded by the idea that it's nice to be able to visit a
todo-mode file with `find-file' or from Dired and have it be in
todo-mode and display properly, but this was just a mistake and now I've
seen the light.  So unless there's a really good reason not to, I'll go
ahead and excise the use of auto-mode-alist; I'll post a patch for
review before committing.

Steve Berman





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

* bug#17482: args-out-of-range when visiting foo.todo
  2014-05-14 19:57               ` Stephen Berman
@ 2014-05-14 20:01                 ` Glenn Morris
  2014-05-14 20:34                   ` Stephen Berman
  2014-05-23 16:59                 ` Stephen Berman
  1 sibling, 1 reply; 19+ messages in thread
From: Glenn Morris @ 2014-05-14 20:01 UTC (permalink / raw)
  To: Stephen Berman; +Cc: 17482

Stephen Berman wrote:

> [...] it's nice to be able to visit a todo-mode file with `find-file'
> or from Dired and have it be in todo-mode and display properly

You could use a file-local variable mode: cookie for that
(I speak without having looked at the code at all).





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

* bug#17482: args-out-of-range when visiting foo.todo
  2014-05-14 20:01                 ` Glenn Morris
@ 2014-05-14 20:34                   ` Stephen Berman
  2014-05-14 21:44                     ` Stefan Monnier
  0 siblings, 1 reply; 19+ messages in thread
From: Stephen Berman @ 2014-05-14 20:34 UTC (permalink / raw)
  To: Glenn Morris; +Cc: 17482

On Wed, 14 May 2014 16:01:43 -0400 Glenn Morris <rgm@gnu.org> wrote:

> Stephen Berman wrote:
>
>> [...] it's nice to be able to visit a todo-mode file with `find-file'
>> or from Dired and have it be in todo-mode and display properly
>
> You could use a file-local variable mode: cookie for that
> (I speak without having looked at the code at all).

Yes, that's in fact what the original todo-mode.el does, but I never
really liked it and dropped from my version it long ago, though it is a
convenient way to get that effect.  But it also counteracts Stefan's
"design goal" of being able to use standard Emacs commands on Todo
files.  Although I didn't follow this goal while reimplementing
todo-mode.el, I now think it's justified: Todo mode has its own entry
points and editing commands and there's no real need to give it a
stranglehold on Todo files.  It's conceptually similar to Gnus: you can
visit and edit a mail file as a normal text file, but in Gnus it's in a
special mode with special commands.  And the risk assessment is the
same: you can corrupt a mail file outside of Gnus if you're not careful.

Steve Berman





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

* bug#17482: args-out-of-range when visiting foo.todo
  2014-05-14 20:34                   ` Stephen Berman
@ 2014-05-14 21:44                     ` Stefan Monnier
  2014-05-14 21:58                       ` Stephen Berman
  0 siblings, 1 reply; 19+ messages in thread
From: Stefan Monnier @ 2014-05-14 21:44 UTC (permalink / raw)
  To: Stephen Berman; +Cc: 17482

> convenient way to get that effect.  But it also counteracts Stefan's
> "design goal" of being able to use standard Emacs commands on Todo
> files.

No, that's OK: for files which we know positively to be Todo files, we
can use special processing.


        Stefan





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

* bug#17482: args-out-of-range when visiting foo.todo
  2014-05-14 21:44                     ` Stefan Monnier
@ 2014-05-14 21:58                       ` Stephen Berman
  2014-05-15  2:24                         ` Stefan Monnier
  0 siblings, 1 reply; 19+ messages in thread
From: Stephen Berman @ 2014-05-14 21:58 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 17482

On Wed, 14 May 2014 17:44:36 -0400 Stefan Monnier <monnier@IRO.UMontreal.CA> wrote:

>> convenient way to get that effect.  But it also counteracts Stefan's
>> "design goal" of being able to use standard Emacs commands on Todo
>> files.
>
> No, that's OK: for files which we know positively to be Todo files, we
> can use special processing.

Ok, I understand (that also answers a question I was tempted to ask you
about why SES files don't violate your design goals).  But I would
consider this to be a new feature (which I still have doubts about),
which could be considered for the trunk, but not for emacs-24.  In
contrast, the use of auto-mode-alist is a bug-inducing misfeature and
should be removed before the release.

Steve Berman





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

* bug#17482: args-out-of-range when visiting foo.todo
  2014-05-14 21:58                       ` Stephen Berman
@ 2014-05-15  2:24                         ` Stefan Monnier
  0 siblings, 0 replies; 19+ messages in thread
From: Stefan Monnier @ 2014-05-15  2:24 UTC (permalink / raw)
  To: Stephen Berman; +Cc: 17482

> Ok, I understand (that also answers a question I was tempted to ask you
> about why SES files don't violate your design goals).  But I would
> consider this to be a new feature (which I still have doubts about),
> which could be considered for the trunk, but not for emacs-24.  In
> contrast, the use of auto-mode-alist is a bug-inducing misfeature and
> should be removed before the release.

Sounds OK.


        Stefan





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

* bug#17482: args-out-of-range when visiting foo.todo
  2014-05-14 19:57               ` Stephen Berman
  2014-05-14 20:01                 ` Glenn Morris
@ 2014-05-23 16:59                 ` Stephen Berman
  2014-05-23 17:32                   ` Glenn Morris
  1 sibling, 1 reply; 19+ messages in thread
From: Stephen Berman @ 2014-05-23 16:59 UTC (permalink / raw)
  To: Glenn Morris; +Cc: 17482

On Wed, 14 May 2014 21:57:04 +0200 Stephen Berman <stephen.berman@gmx.net> wrote:

> On Wed, 14 May 2014 13:46:33 -0400 Glenn Morris <rgm@gnu.org> wrote:
>
>> Stefan Monnier wrote:
>>
>>> Maybe a quick way to "reach" the design goal is to wrap the body of
>>> todo-mode in a `with-demoted-errors'.
>>
>> It's better, but I think it's still not great if I visit blah.todo and
>> get "args-out-of-range" as a message rather than an error.
>
> I agree.  Moreover, if blah.todo is not empty but not a valid Todo file,
> visiting it will raise a different error from a different part of the
> code, so it would be necessary to have multiple uses of
> `with-demoted-errors'.  And there's still the issue of why *.todo files
> not in `todo-directory' should be in Todo mode.  And the only sensible
> answer is: they shouldn't be.  So I am convinced that todo-mode should
> not use auto-mode-alist: it's not needed and it only causes problems.  I
> somehow became blinded by the idea that it's nice to be able to visit a
> todo-mode file with `find-file' or from Dired and have it be in
> todo-mode and display properly, but this was just a mistake and now I've
> seen the light.  So unless there's a really good reason not to, I'll go
> ahead and excise the use of auto-mode-alist; I'll post a patch for
> review before committing.
>
> Steve Berman

On Wed, 14 May 2014 22:24:41 -0400 Stefan Monnier <monnier@IRO.UMontreal.CA> wrote:

>> Ok, I understand (that also answers a question I was tempted to ask you
>> about why SES files don't violate your design goals).  But I would
>> consider this to be a new feature (which I still have doubts about),
>> which could be considered for the trunk, but not for emacs-24.  In
>> contrast, the use of auto-mode-alist is a bug-inducing misfeature and
>> should be removed before the release.
>
> Sounds OK.

The required changes to remove the use of auto-mode-alist amount mainly
to calling the appropriate Todo mode function when visting a Todo file,
if it isn't already in that mode, so in view of Stefan's approval of the
plan not to use auto-mode-alist here, I've refrained from posting the
patch and simply committed it.

Glenn, if you want to test and (hopefully) confirm that this bug is
fixed, I'll wait for your response; otherwise, I'll take the liberty of
closing it in a day or two.

Besides fixing this bug, in the process of making and testing the
changes I found a handful of other bugs, which I've already fixed in a
separate changeset (bzr 117142 in emacs-24).

Steve Berman





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

* bug#17482: args-out-of-range when visiting foo.todo
  2014-05-23 16:59                 ` Stephen Berman
@ 2014-05-23 17:32                   ` Glenn Morris
  2014-05-23 19:12                     ` Stephen Berman
  0 siblings, 1 reply; 19+ messages in thread
From: Glenn Morris @ 2014-05-23 17:32 UTC (permalink / raw)
  To: Stephen Berman; +Cc: 17482


Well, I visited foo.todo and no longer saw an error, so works for me,
thanks.





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

* bug#17482: args-out-of-range when visiting foo.todo
  2014-05-23 17:32                   ` Glenn Morris
@ 2014-05-23 19:12                     ` Stephen Berman
  0 siblings, 0 replies; 19+ messages in thread
From: Stephen Berman @ 2014-05-23 19:12 UTC (permalink / raw)
  To: Glenn Morris; +Cc: 17482-done

On Fri, 23 May 2014 13:32:48 -0400 Glenn Morris <rgm@gnu.org> wrote:

> Well, I visited foo.todo and no longer saw an error, so works for me,
> thanks.

Thanks for confirming; closing.

Steve Berman





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

end of thread, other threads:[~2014-05-23 19:12 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-13  6:22 bug#17482: args-out-of-range when visiting foo.todo Glenn Morris
2014-05-13 15:57 ` Stephen Berman
2014-05-13 16:02   ` Glenn Morris
2014-05-13 16:26     ` Stephen Berman
2014-05-13 19:40   ` Stefan Monnier
2014-05-13 22:33     ` Stephen Berman
2014-05-14  3:22       ` Stefan Monnier
2014-05-14 15:10         ` Stephen Berman
2014-05-14 16:55           ` Stefan Monnier
2014-05-14 17:46             ` Glenn Morris
2014-05-14 19:57               ` Stephen Berman
2014-05-14 20:01                 ` Glenn Morris
2014-05-14 20:34                   ` Stephen Berman
2014-05-14 21:44                     ` Stefan Monnier
2014-05-14 21:58                       ` Stephen Berman
2014-05-15  2:24                         ` Stefan Monnier
2014-05-23 16:59                 ` Stephen Berman
2014-05-23 17:32                   ` Glenn Morris
2014-05-23 19:12                     ` Stephen Berman

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