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: Tue, 13 May 2014 17:57:04 +0200 Message-ID: <87zjilzn73.fsf@rosalinde.fritz.box> References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1399996711 10220 80.91.229.3 (13 May 2014 15:58:31 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 13 May 2014 15:58:31 +0000 (UTC) Cc: 17482@debbugs.gnu.org To: Glenn Morris Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue May 13 17:58:21 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 1WkF5w-00023Q-Kl for geb-bug-gnu-emacs@m.gmane.org; Tue, 13 May 2014 17:58:20 +0200 Original-Received: from localhost ([::1]:46067 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WkF5w-0007i3-7h for geb-bug-gnu-emacs@m.gmane.org; Tue, 13 May 2014 11:58:20 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:48995) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WkF5l-0007Wg-0R for bug-gnu-emacs@gnu.org; Tue, 13 May 2014 11:58:14 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WkF5f-0006T8-2D for bug-gnu-emacs@gnu.org; Tue, 13 May 2014 11:58:08 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:45065) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WkF5e-0006T1-Pq for bug-gnu-emacs@gnu.org; Tue, 13 May 2014 11:58:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1WkF5e-0000M1-Ig for bug-gnu-emacs@gnu.org; Tue, 13 May 2014 11:58: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 15:58: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.13999966691339 (code B ref 17482); Tue, 13 May 2014 15:58:02 +0000 Original-Received: (at 17482) by debbugs.gnu.org; 13 May 2014 15:57:49 +0000 Original-Received: from localhost ([127.0.0.1]:34183 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WkF5Q-0000LV-5t for submit@debbugs.gnu.org; Tue, 13 May 2014 11:57:48 -0400 Original-Received: from mout.gmx.net ([212.227.17.21]:60184) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WkF5N-0000LH-IQ for 17482@debbugs.gnu.org; Tue, 13 May 2014 11:57:46 -0400 Original-Received: from rosalinde.fritz.box ([89.245.115.4]) by mail.gmx.com (mrgmx102) with ESMTPSA (Nemesis) id 0M8JyQ-1WwykP3WIE-00vtK7; Tue, 13 May 2014 17:57:36 +0200 In-Reply-To: (Glenn Morris's message of "Tue, 13 May 2014 02:22:35 -0400") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.90 (gnu/linux) X-Provags-ID: V03:K0:K3Ce0+SYHoU5CDoySuNW5axJ0lZAFkX8KRasUB7qB4QgKwCNr6T rJbapXy8UbpuI+T1Y+8fX0N7EDGkHyGfAh9T+dVcmebVrhBiG4ftLX6OZcdOsRebGCJ6/iF pji/2jjKBReSBgHuGOKG0inegYbl/l7Clp1PQzArt1ZWRsCQc9LXI+ZjzVTJsH+Ts/dbSW/ 3h3ENpX7/xKsJm6kAXYig== 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:89020 Archived-At: On Tue, 13 May 2014 02:22:35 -0400 Glenn Morris 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)