diff options
| author | Dave Love | 2000-05-12 10:58:13 +0000 |
|---|---|---|
| committer | Dave Love | 2000-05-12 10:58:13 +0000 |
| commit | 9278c60dae04fd2cd99317a3f8ead8335bab2a5b (patch) | |
| tree | 8b97a5697c3fdb50aa75f73d353075717744451b | |
| parent | 33d0c179f1f0c1db07f2df6e63aa59827f41514b (diff) | |
| download | emacs-9278c60dae04fd2cd99317a3f8ead8335bab2a5b.tar.gz emacs-9278c60dae04fd2cd99317a3f8ead8335bab2a5b.zip | |
Remove some compatibility stuff and CL
dependence. Use line-{beginning,end}-position, not
point-at{b,e}ol. Some doc fixes.
(todo-position): New function. Fix callers of position to use it.
(todo-save-top-priorities, todo-print): Use with-temp-buffer.
| -rw-r--r-- | lisp/ChangeLog | 8 | ||||
| -rw-r--r-- | lisp/calendar/todo-mode.el | 421 |
2 files changed, 75 insertions, 354 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 4f3ec6227bb..98963cf61ca 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,11 @@ | |||
| 1 | 2000-05-12 Dave Love <fx@gnu.org> | ||
| 2 | |||
| 3 | * calendar/todo-mode.el: Remove some compatibility stuff and CL | ||
| 4 | dependence. Use line-{beginning,end}-position, not | ||
| 5 | point-at{b,e}ol. Some doc fixes. | ||
| 6 | (todo-position): New function. Fix callers of position to use it. | ||
| 7 | (todo-save-top-priorities, todo-print): Use with-temp-buffer. | ||
| 8 | |||
| 1 | 2000-05-12 Gerd Moellmann <gerd@gnu.org> | 9 | 2000-05-12 Gerd Moellmann <gerd@gnu.org> |
| 2 | 10 | ||
| 3 | * time.el (display-time-mail-icon): Use `:ascent center'. | 11 | * time.el (display-time-mail-icon): Use `:ascent center'. |
diff --git a/lisp/calendar/todo-mode.el b/lisp/calendar/todo-mode.el index bcf298e9b9a..e4c06cdfb2d 100644 --- a/lisp/calendar/todo-mode.el +++ b/lisp/calendar/todo-mode.el | |||
| @@ -4,7 +4,7 @@ | |||
| 4 | 4 | ||
| 5 | ;; Author: Oliver.Seidel@cl.cam.ac.uk (was valid on Aug 2, 1997) | 5 | ;; Author: Oliver.Seidel@cl.cam.ac.uk (was valid on Aug 2, 1997) |
| 6 | ;; Created: 2 Aug 1997 | 6 | ;; Created: 2 Aug 1997 |
| 7 | ;; Version: $Id: todo-mode.el,v 1.37 1999/03/18 08:53:48 os10000 Exp os10000 $ | 7 | ;; Version: $Id: todo-mode.el,v 1.38 1999/05/12 08:41:32 os10000 Exp $ |
| 8 | ;; Keywords: Categorised TODO list editor, todo-mode | 8 | ;; Keywords: Categorised TODO list editor, todo-mode |
| 9 | 9 | ||
| 10 | ;; This file is part of GNU Emacs. | 10 | ;; This file is part of GNU Emacs. |
| @@ -117,7 +117,7 @@ | |||
| 117 | ;; | 117 | ;; |
| 118 | ;; Which version of todo-mode.el does this documentation refer to? | 118 | ;; Which version of todo-mode.el does this documentation refer to? |
| 119 | ;; | 119 | ;; |
| 120 | ;; $Id: todo-mode.el,v 1.37 1999/03/18 08:53:48 os10000 Exp os10000 $ | 120 | ;; $Id: todo-mode.el,v 1.38 1999/05/12 08:41:32 os10000 Exp $ |
| 121 | ;; | 121 | ;; |
| 122 | ;; Pre-Requisites | 122 | ;; Pre-Requisites |
| 123 | ;; | 123 | ;; |
| @@ -285,260 +285,16 @@ | |||
| 285 | ;; | 285 | ;; |
| 286 | ;; Oliver Seidel | 286 | ;; Oliver Seidel |
| 287 | ;; (Lessingstr. 8, 65760 Eschborn, Federal Republic of Germany) | 287 | ;; (Lessingstr. 8, 65760 Eschborn, Federal Republic of Germany) |
| 288 | ;; | ||
| 289 | |||
| 290 | ;; --------------------------------------------------------------------------- | ||
| 291 | |||
| 292 | ;;; Change Log: | ||
| 293 | |||
| 294 | ;; $Log: todo-mode.el,v $ | ||
| 295 | ;; Revision 1.37 1999/03/18 08:53:48 os10000 | ||
| 296 | ;; Marc Zonzon <Marc.Zonzon@univ-rennes1.fr> on 18.Mar.99 writes that I | ||
| 297 | ;; should remove the single space between ### and autoload. And now I | ||
| 298 | ;; have. | ||
| 299 | ;; | ||
| 300 | ;; Revision 1.36 1999/03/17 11:10:29 os10000 | ||
| 301 | ;; Alastair Burt <alastair.burt@dfki.de> sent in a patch on 17.Mar.98 | ||
| 302 | ;; which removes duplicates from the category list and saves the buffer | ||
| 303 | ;; after category addition. Thanks. | ||
| 304 | ;; | ||
| 305 | ;; Uwe Brauer <oub@sunma4.mat.ucm.es> sent in a request on 3.Apr.98 to | ||
| 306 | ;; implement a "move-between-categories" function. I haven't done that | ||
| 307 | ;; yet. Thanks. | ||
| 308 | ;; | ||
| 309 | ;; "Edward S. Hirgelt" <ehirgelt@directinterfaces.com> fixed a problem | ||
| 310 | ;; with multi-line editing 29.Oct.98. Thanks. | ||
| 311 | ;; | ||
| 312 | ;; tom <tom@pixelpark.com> sent in a replacement for the outmoded | ||
| 313 | ;; time-format that I had been using on 13.Nov.98. Thanks. | ||
| 314 | ;; | ||
| 315 | ;; Jerome Thebert <thebertj@felixstowe.rms.slb.com> sent in a binding to | ||
| 316 | ;; show/hide continuation lines using the space bar on 11.Jan.99. | ||
| 317 | ;; Instead of leaving it as a hook, I integrated it. Thanks. | ||
| 318 | ;; | ||
| 319 | ;; Sorry again to everybody. I sat on your patches for a year. | ||
| 320 | ;; | ||
| 321 | ;; Revision 1.35 1998/09/29 18:20:36 os10000 | ||
| 322 | ;; Alex Schroeder startup description added. | ||
| 323 | ;; | ||
| 324 | ;; Revision 1.34 1998/01/12 11:43:22 os10000 | ||
| 325 | ;; Added patch from Don Hejna <djhejna@oasis.ambit.com>. | ||
| 326 | ;; | ||
| 327 | ;; Revision 1.33 1997/12/04 17:45:22 os10000 | ||
| 328 | ;; Another patch by Michael Cook to fix annotation. | ||
| 329 | ;; | ||
| 330 | ;; Revision 1.32 1997/12/03 12:18:20 os10000 | ||
| 331 | ;; Added category patch by Michael R Cook <mcook@cognex.com>. | ||
| 332 | ;; | ||
| 333 | ;; Revision 1.31 1997/10/28 22:16:24 os10000 | ||
| 334 | ;; Three insertion options: | ||
| 335 | ;; i without prefix: ask for category, do binary insertion | ||
| 336 | ;; i with prefix: do binary insertion in current category | ||
| 337 | ;; uppercase I: insert directly under cursor | ||
| 338 | ;; | ||
| 339 | ;; Revision 1.30 1997/10/28 21:59:48 os10000 | ||
| 340 | ;; Improved documentation, fixed insertion with prefix. | ||
| 341 | ;; | ||
| 342 | ;; Revision 1.29 1997/10/28 21:47:12 os10000 | ||
| 343 | ;; Implemented "insert-under-cursor" as suggested by | ||
| 344 | ;; Kai Grossjohann <grossjohann@ls6.cs.uni-dortmund.de>. | ||
| 345 | ;; | ||
| 346 | ;; Revision 1.28 1997/10/28 21:37:05 os10000 | ||
| 347 | ;; Incorporated simplifying suggestions from | ||
| 348 | ;; Carsten Dominik <dominik@strw.LeidenUniv.nl>. | ||
| 349 | ;; | ||
| 350 | ;; Revision 1.27 1997/10/28 21:26:55 os10000 | ||
| 351 | ;; Patch from Paul Stodghill <stodghil@CS.Cornell.EDU>: | ||
| 352 | ;; The patch below fixes todo-insert-item so that it will | ||
| 353 | ;; insert the item in place, instead of at the top of the | ||
| 354 | ;; buffer, when invoked with a prefix argument. | ||
| 355 | ;; | ||
| 356 | ;; Revision 1.26 1997/10/28 21:14:51 os10000 | ||
| 357 | ;; Improvements sent in by Dave Love <d.love@dl.ac.uk>: | ||
| 358 | ;; todo-mode.el: Doc fixes. Customization. | ||
| 359 | ;; (todo-add-item-non-interactively): New arg -- don't dynamically bind ARG. | ||
| 360 | ;; (todo-insert-item): Use it. | ||
| 361 | ;; | ||
| 362 | ;; Revision 1.25 1997/10/28 20:03:27 os10000 | ||
| 363 | ;; Harald Backer <harald.backer@fou.telenor.no> sent the following: | ||
| 364 | ;; Added `todo-save-top-priorities' and option to automatically save top | ||
| 365 | ;; priorities file when saving todo-file. Changed some default values. | ||
| 366 | ;; Bug fixes. | ||
| 367 | ;; | ||
| 368 | ;; Revision 1.24 1997/10/28 19:41:53 os10000 | ||
| 369 | ;; Added fix from Frank Ridderbusch <ridderbusch.pad@sni.de>, | ||
| 370 | ;; an apostrophe was missing. | ||
| 371 | ;; | ||
| 372 | ;; Revision 1.23 1997/10/24 17:30:54 os10000 | ||
| 373 | ;; Added three suggestions from Carsten | ||
| 374 | ;; Dominik <dominik@strw.LeidenUniv.nl>: | ||
| 375 | ;; | ||
| 376 | ;; - recommend autoloading instead of require | ||
| 377 | ;; - inserting from different buffer didn't work | ||
| 378 | ;; (now fixed -- I pray) | ||
| 379 | ;; - provided public entry point to insert items | ||
| 380 | ;; from normal lisp code | ||
| 381 | ;; | ||
| 382 | ;; Revision 1.22 1997/10/24 16:53:20 os10000 | ||
| 383 | ;; Paul Stodghill <stodghil@CS.Cornell.EDU> writes: | ||
| 384 | ;; | ||
| 385 | ;; When invoked with a prefix, todo-insert-item | ||
| 386 | ;; should not prompt for a category. (He adds: | ||
| 387 | ;; At least that's what I think.) | ||
| 388 | ;; | ||
| 389 | ;; Revision 1.21 1997/10/24 16:51:02 os10000 | ||
| 390 | ;; Rafael Laboissiere <rafael@icp.inpg.fr> writes: | ||
| 391 | ;; | ||
| 392 | ;; I was just annoyed with the fact that there is no way | ||
| 393 | ;; to dynamically control the insertion accuracy. I mean: | ||
| 394 | ;; the variable `todo-insert-threshold' does the job, but | ||
| 395 | ;; it is not very handy if one wants to mix the two | ||
| 396 | ;; behaviors (bisection and "insert right here under the | ||
| 397 | ;; cursor"). | ||
| 398 | ;; | ||
| 399 | ;; Therefore I did a quick hack in the function | ||
| 400 | ;; `todo-insert-item'. Now by giving a prefix argument to | ||
| 401 | ;; the insert command (i.e. by typing "C-u i"), entries | ||
| 402 | ;; are inserted exactly at the line where the cursor is. | ||
| 403 | ;; It would be better to give the value of | ||
| 404 | ;; `todo-insert-threshold' as a numeric argument of | ||
| 405 | ;; `todo-insert-item' (like "M-8 i"), but it's too late | ||
| 406 | ;; now for continuing to hack. | ||
| 407 | ;; | ||
| 408 | ;; Revision 1.20 1997/10/17 15:41:57 os10000 | ||
| 409 | ;; Thanks to Harald Backer <harald.backer@fou.telenor.no>, we now have | ||
| 410 | ;; the following facilities available: | ||
| 411 | ;; | ||
| 412 | ;; Added todo-print, todo-top-priorities and todo-jump with matching | ||
| 413 | ;; variables; Parameterized todo-header, todo-category-beg, | ||
| 414 | ;; todo-category-end and todo-category-sep; Added autoload comments; | ||
| 415 | ;; todo-category-select: Modified regexp to make category names unique; | ||
| 416 | ;; todo-forward-item: Added optional COUNT vaiable; todo-insert-item: | ||
| 417 | ;; Rewrote completing read entry. | ||
| 418 | ;; | ||
| 419 | ;; Also, check out the extended list of things left to be done to this | ||
| 420 | ;; package at the end of the documentation! | ||
| 421 | ;; | ||
| 422 | ;; Revision 1.19 1997/10/16 21:21:16 os10000 | ||
| 423 | ;; Jari Aalto <jari.aalto@poboxes.com> writes: | ||
| 424 | ;; | ||
| 425 | ;; I just downloaded your package and after reading the docs I | ||
| 426 | ;; decided to do some reformatting. Hope you don't mind. Now | ||
| 427 | ;; they are in such a format that the html page can be | ||
| 428 | ;; automatically generated from the source file. As an example, I | ||
| 429 | ;; generated the attached page using the following command: | ||
| 430 | ;; ripdoc.pls < todo-mode.el | t2html.pls -a "Oliver.Seidel" -e \ | ||
| 431 | ;; Oliver.Seidel@cl.cam.ac.uk -simple -base | ||
| 432 | ;; | ||
| 433 | ;; And of course I appreciate it. Jari's stuff can be found at: | ||
| 434 | ;; ftp://cs.uta.fi/pub/ssjaaa/, while I'm making the rev 1.18 page | ||
| 435 | ;; available at http://www.cl.cam.ac.uk/users/os10000/doc/todo-mode.html | ||
| 436 | ;; (That link will be valid until 10/1998 or slightly longer.) | ||
| 437 | ;; | ||
| 438 | ;; Revision 1.18 1997/10/15 17:18:11 os10000 | ||
| 439 | ;; Everything seems to work in Harald Melands Emacs 20.02 and | ||
| 440 | ;; my Emacs 19.34. Beware of the spelling in some of the | ||
| 441 | ;; variable names. I looked up "threshold" in a dictionary | ||
| 442 | ;; and here in Britain this appears to be the way to spell it. | ||
| 443 | ;; | ||
| 444 | ;; Revision 1.17 1997/10/15 14:30:41 os10000 | ||
| 445 | ;; Attempted to reconcile Harald's changes with mine since 1.15. | ||
| 446 | ;; | ||
| 447 | ;; Revision 1.16 1997/10/15 14:00:12 os10000 | ||
| 448 | ;; Fixed 'file-item' and added 20.02 split-string function. | ||
| 449 | ;; | ||
| 450 | ;; Revision 1.15 1997/10/14 22:22:35 os10000 | ||
| 451 | ;; Added string-split (which I stole from ediff-util), changed | ||
| 452 | ;; pop-to-buffer to switch-to-buffer and added message on how | ||
| 453 | ;; to exit the multi-line-edit mode. | ||
| 454 | ;; | ||
| 455 | ;; Revision 1.14 1997/10/09 09:24:50 os10000 | ||
| 456 | ;; Harald Meland <harald.meland@usit.uio.no> asked for | ||
| 457 | ;; the latest version, got 1.13, and returned this. | ||
| 458 | ;; He writes: | ||
| 459 | ;; | ||
| 460 | ;; Thanks a lot for the new version of todo-mode.el. As you will see I | ||
| 461 | ;; have messed it up a bit, hopefully for the better -- I don't like | ||
| 462 | ;; short, cryptic names for variables and functions, so I renamed most of | ||
| 463 | ;; them, and `defalias'ed the old function names. I hope you don't mind | ||
| 464 | ;; too much, I just kinda couldn't stop myself. | ||
| 465 | ;; | ||
| 466 | ;; Additionally, I included some support for multiline entries, cleaned | ||
| 467 | ;; up (IMHO :) a lot of the code, included completion-support for which | ||
| 468 | ;; category to install a new entry in, and possibly some other changes I | ||
| 469 | ;; can't remember :) | ||
| 470 | ;; | ||
| 471 | ;; It's getting rather late, and I have just done some preliminary | ||
| 472 | ;; testing on whether all of this really works, but so far it looks | ||
| 473 | ;; good. | ||
| 474 | ;; | ||
| 475 | ;; Revision 1.13 1997/08/19 14:00:36 seidel | ||
| 476 | ;; - changed name to todo-mode | ||
| 477 | ;; - fixed menu descriptions | ||
| 478 | ;; - fixed "pressing abort while filing" | ||
| 479 | ;; - attempted Emacs Lisp Manual *Tips* section compliance | ||
| 480 | ;; | ||
| 481 | ;; Revision 1.12 1997/08/06 10:56:15 os10000 | ||
| 482 | ;; Fixed header, typos, layout, documentation. | ||
| 483 | ;; | ||
| 484 | ;; Revision 1.11 1997/08/06 09:14:25 os10000 | ||
| 485 | ;; Applied patch from Istvan Marko <istvan@cmdmail.amd.com> | ||
| 486 | ;; to make menus work anywhere. | ||
| 487 | ;; | ||
| 488 | ;; Revision 1.10 1997/08/06 08:56:03 os10000 | ||
| 489 | ;; Acted upon suggestion from Shane Holder <holder@rsn.hp.com>: | ||
| 490 | ;; Cancelling the editing of an entry will not delete it any more. | ||
| 491 | ;; | ||
| 492 | ;; Revision 1.9 1997/08/06 08:12:03 os10000 | ||
| 493 | ;; Improved documentation. Broke some lines to comply with | ||
| 494 | ;; Richard Stallman's email to please keep in sync with the | ||
| 495 | ;; rest of the Emacs distribution files. | ||
| 496 | ;; | ||
| 497 | ;; Revision 1.8 1997/08/05 22:39:04 os10000 | ||
| 498 | ;; Made todo-mode.el available under GPL. | ||
| 499 | ;; | ||
| 500 | ;; Revision 1.7 1997/08/05 22:34:14 os10000 | ||
| 501 | ;; Fixed insertion routine with help from Trey Jackson | ||
| 502 | ;; <trey@cs.berkeley.edu>; added todo-inst-tresh; | ||
| 503 | ;; fixed keyboard layout to remove unwanted keys. | ||
| 504 | ;; | ||
| 505 | ;; Revision 1.6 1997/08/05 16:47:01 os10000 | ||
| 506 | ;; Incorporated menus for XEmacs from Allan.Cochrane@soton.sc.philips.com, | ||
| 507 | ;; fixed TYPO, fixed todo-file-cmd, cleaned up rcs history. | ||
| 508 | ;; | ||
| 509 | ;; Revision 1.5 1997/08/05 14:43:39 os10000 | ||
| 510 | ;; Added improvements from Ron Gut <rgut@aware.com>. | ||
| 511 | ;; Added category management. | ||
| 512 | ;; | ||
| 513 | ;; Revision 1.4 1997/08/04 16:18:45 os10000 | ||
| 514 | ;; Added Raise/Lower item. | ||
| 515 | ;; | ||
| 516 | ;; Revision 1.3 1997/08/03 12:47:26 os10000 | ||
| 517 | ;; Cleaned up variables, prefix and cursor position. | ||
| 518 | ;; | ||
| 519 | ;; Revision 1.2 1997/08/03 12:15:28 os10000 | ||
| 520 | ;; It appears to work. | ||
| 521 | ;; | ||
| 522 | ;; Revision 1.1 1997/08/03 12:15:13 os10000 | ||
| 523 | ;; Initial revision | ||
| 524 | ;; | ||
| 525 | |||
| 526 | ;; --------------------------------------------------------------------------- | ||
| 527 | 288 | ||
| 528 | ;;; Code: | 289 | ;;; Code: |
| 529 | 290 | ||
| 530 | (eval-and-compile ; Removable for installation in | 291 | (eval-when-compile |
| 531 | ; Emacs 20. | 292 | (require 'outline) |
| 532 | (condition-case () | 293 | (require 'calendar) |
| 533 | (require 'custom) | 294 | ;; Calendar dynamic bondage: |
| 534 | (error nil)) | 295 | (defvar date) |
| 535 | (if (and (featurep 'custom) (fboundp 'custom-declare-variable)) | 296 | (defvar entry)) |
| 536 | nil ;; We've got what we needed | 297 | (autoload 'time-stamp-string "time-stamp") |
| 537 | ;; We have the old custom-library, hack around it! | ||
| 538 | (defmacro defgroup (&rest args) | ||
| 539 | nil) | ||
| 540 | (defmacro defcustom (var value doc &rest args) | ||
| 541 | (` (defvar (, var) (, value) (, doc)))))) | ||
| 542 | 298 | ||
| 543 | ;; User-configurable variables: | 299 | ;; User-configurable variables: |
| 544 | 300 | ||
| @@ -651,28 +407,19 @@ For details see the variable `time-stamp-format'." | |||
| 651 | (let ((time-stamp-format todo-time-string-format)) | 407 | (let ((time-stamp-format todo-time-string-format)) |
| 652 | (concat (time-stamp-string) " " todo-initials ": "))) | 408 | (concat (time-stamp-string) " " todo-initials ": "))) |
| 653 | 409 | ||
| 654 | ;; --------------------------------------------------------------------------- | ||
| 655 | |||
| 656 | ;; Get some outside help ... | ||
| 657 | |||
| 658 | (require 'cl) | ||
| 659 | (require 'easymenu) | ||
| 660 | (require 'time-stamp) | ||
| 661 | |||
| 662 | ;; --------------------------------------------------------------------------- | ||
| 663 | |||
| 664 | ;; Set up some helpful context ... | 410 | ;; Set up some helpful context ... |
| 665 | 411 | ||
| 666 | (defvar todo-categories nil "TODO categories.") | 412 | (defvar todo-categories nil |
| 667 | (defvar todo-cats nil | 413 | "TODO categories.") |
| 414 | (defvar todo-cats nil | ||
| 668 | "Old variable for holding the TODO categories. | 415 | "Old variable for holding the TODO categories. |
| 669 | Use `todo-categories' instead.") | 416 | Use `todo-categories' instead.") |
| 670 | (defvar todo-previous-line 0 "Previous line that I asked about.") | 417 | (defvar todo-previous-line 0 |
| 671 | (defvar todo-previous-answer 0 "Previous answer that I got.") | 418 | "Previous line asked about.") |
| 672 | (defvar todo-mode-map nil "TODO mode keymap.") | 419 | (defvar todo-previous-answer 0 |
| 673 | (defvar todo-category-number 0 "TODO category number.") | 420 | "Previous answer got.") |
| 674 | 421 | (defvar todo-category-number 0 | |
| 675 | (defvar todo-tmp-buffer-name "*Tmp*") | 422 | "TODO category number.") |
| 676 | 423 | ||
| 677 | (defvar todo-category-sep (make-string 75 ?-) | 424 | (defvar todo-category-sep (make-string 75 ?-) |
| 678 | "Category separator.") | 425 | "Category separator.") |
| @@ -683,12 +430,9 @@ Use `todo-categories' instead.") | |||
| 683 | (defvar todo-header "-*- mode: todo; " | 430 | (defvar todo-header "-*- mode: todo; " |
| 684 | "Header of todo files.") | 431 | "Header of todo files.") |
| 685 | 432 | ||
| 686 | |||
| 687 | |||
| 688 | ;; --------------------------------------------------------------------------- | 433 | ;; --------------------------------------------------------------------------- |
| 689 | 434 | ||
| 690 | (if todo-mode-map | 435 | (defvar todo-mode-map |
| 691 | nil | ||
| 692 | (let ((map (make-keymap))) | 436 | (let ((map (make-keymap))) |
| 693 | (suppress-keymap map t) | 437 | (suppress-keymap map t) |
| 694 | (define-key map "?" 'todo-help) | 438 | (define-key map "?" 'todo-help) |
| @@ -712,7 +456,20 @@ Use `todo-categories' instead.") | |||
| 712 | (define-key map "s" 'todo-save) | 456 | (define-key map "s" 'todo-save) |
| 713 | (define-key map "S" 'todo-save-top-priorities) | 457 | (define-key map "S" 'todo-save-top-priorities) |
| 714 | (define-key map "t" 'todo-top-priorities) | 458 | (define-key map "t" 'todo-top-priorities) |
| 715 | (setq todo-mode-map map))) | 459 | map) |
| 460 | "TODO mode keymap.") | ||
| 461 | |||
| 462 | (defun todo-position (item list) | ||
| 463 | "Return the position of the element in LIST testing `equal' to ITEM. | ||
| 464 | Return nil if ITEM not found." | ||
| 465 | (let ((pos 0) | ||
| 466 | found) | ||
| 467 | (while list | ||
| 468 | (if (equal item (pop list)) | ||
| 469 | (setq list nil | ||
| 470 | found pos) | ||
| 471 | (setq pos (1+ pos)))) | ||
| 472 | found)) | ||
| 716 | 473 | ||
| 717 | (defun todo-category-select () | 474 | (defun todo-category-select () |
| 718 | "Make TODO mode display the current category correctly." | 475 | "Make TODO mode display the current category correctly." |
| @@ -725,9 +482,9 @@ Use `todo-categories' instead.") | |||
| 725 | (concat "^" | 482 | (concat "^" |
| 726 | (regexp-quote (concat todo-prefix todo-category-beg name)) | 483 | (regexp-quote (concat todo-prefix todo-category-beg name)) |
| 727 | "$")) | 484 | "$")) |
| 728 | (let ((begin (1+ (point-at-eol)))) | 485 | (let ((begin (1+ (line-end-position)))) |
| 729 | (search-forward-regexp (concat "^" todo-category-end)) | 486 | (search-forward-regexp (concat "^" todo-category-end)) |
| 730 | (narrow-to-region begin (point-at-bol)) | 487 | (narrow-to-region begin (line-beginning-position)) |
| 731 | (goto-char (point-min))))) | 488 | (goto-char (point-min))))) |
| 732 | (defalias 'todo-cat-slct 'todo-category-select) | 489 | (defalias 'todo-cat-slct 'todo-category-select) |
| 733 | 490 | ||
| @@ -735,7 +492,8 @@ Use `todo-categories' instead.") | |||
| 735 | (interactive) | 492 | (interactive) |
| 736 | (describe-function 'todo-mode)) | 493 | (describe-function 'todo-mode)) |
| 737 | 494 | ||
| 738 | (defun todo-hide-show-subtree () "Hide or Show subtrees in the TODO list." | 495 | (defun todo-hide-show-subtree () |
| 496 | "Hide or Show subtrees in the TODO list." | ||
| 739 | (interactive) | 497 | (interactive) |
| 740 | (save-excursion | 498 | (save-excursion |
| 741 | (end-of-line) | 499 | (end-of-line) |
| @@ -743,21 +501,24 @@ Use `todo-categories' instead.") | |||
| 743 | (hide-subtree) | 501 | (hide-subtree) |
| 744 | (show-subtree)))) | 502 | (show-subtree)))) |
| 745 | 503 | ||
| 746 | (defun todo-forward-category () "Go forward to TODO list of next category." | 504 | (defun todo-forward-category () |
| 505 | "Go forward to TODO list of next category." | ||
| 747 | (interactive) | 506 | (interactive) |
| 748 | (setq todo-category-number | 507 | (setq todo-category-number |
| 749 | (mod (1+ todo-category-number) (length todo-categories))) | 508 | (mod (1+ todo-category-number) (length todo-categories))) |
| 750 | (todo-category-select)) | 509 | (todo-category-select)) |
| 751 | (defalias 'todo-cmd-forw 'todo-forward-category) | 510 | (defalias 'todo-cmd-forw 'todo-forward-category) |
| 752 | 511 | ||
| 753 | (defun todo-backward-category () "Go back to TODO list of previous category." | 512 | (defun todo-backward-category () |
| 513 | "Go back to TODO list of previous category." | ||
| 754 | (interactive) | 514 | (interactive) |
| 755 | (setq todo-category-number | 515 | (setq todo-category-number |
| 756 | (mod (1- todo-category-number) (length todo-categories))) | 516 | (mod (1- todo-category-number) (length todo-categories))) |
| 757 | (todo-category-select)) | 517 | (todo-category-select)) |
| 758 | (defalias 'todo-cmd-back 'todo-backward-category) | 518 | (defalias 'todo-cmd-back 'todo-backward-category) |
| 759 | 519 | ||
| 760 | (defun todo-backward-item () "Select previous entry of TODO list." | 520 | (defun todo-backward-item () |
| 521 | "Select previous entry of TODO list." | ||
| 761 | (interactive) | 522 | (interactive) |
| 762 | (search-backward-regexp (concat "^" (regexp-quote todo-prefix)) nil t) | 523 | (search-backward-regexp (concat "^" (regexp-quote todo-prefix)) nil t) |
| 763 | (message "")) | 524 | (message "")) |
| @@ -816,7 +577,7 @@ Use `todo-categories' instead.") | |||
| 816 | "Add new category CAT to the TODO list." | 577 | "Add new category CAT to the TODO list." |
| 817 | (interactive "sCategory: ") | 578 | (interactive "sCategory: ") |
| 818 | (save-window-excursion | 579 | (save-window-excursion |
| 819 | (pushnew cat todo-categories) | 580 | (pushnew 'todo-categories cat) |
| 820 | (find-file todo-file-do) | 581 | (find-file todo-file-do) |
| 821 | (widen) | 582 | (widen) |
| 822 | (goto-char (point-min)) | 583 | (goto-char (point-min)) |
| @@ -844,7 +605,7 @@ Use `todo-categories' instead.") | |||
| 844 | (if (string= "" category) | 605 | (if (string= "" category) |
| 845 | (setq category (nth todo-category-number todo-categories))) | 606 | (setq category (nth todo-category-number todo-categories))) |
| 846 | (setq todo-category-number | 607 | (setq todo-category-number |
| 847 | (or (position category todo-categories :test 'equal) | 608 | (or (todo-position category todo-categories) |
| 848 | (todo-add-category category))) | 609 | (todo-add-category category))) |
| 849 | (todo-show) | 610 | (todo-show) |
| 850 | (setq todo-previous-line 0) | 611 | (setq todo-previous-line 0) |
| @@ -1033,7 +794,7 @@ between each category." | |||
| 1033 | (while (re-search-forward ;Find category start | 794 | (while (re-search-forward ;Find category start |
| 1034 | (regexp-quote (concat todo-prefix todo-category-beg)) | 795 | (regexp-quote (concat todo-prefix todo-category-beg)) |
| 1035 | nil t) | 796 | nil t) |
| 1036 | (setq beg (+ (point-at-eol) 1)) ;Start of first entry. | 797 | (setq beg (+ (line-end-position) 1)) ;Start of first entry. |
| 1037 | (re-search-forward cat-end nil t) | 798 | (re-search-forward cat-end nil t) |
| 1038 | (setq end (match-beginning 0)) | 799 | (setq end (match-beginning 0)) |
| 1039 | (replace-match todo-category-break) | 800 | (replace-match todo-category-break) |
| @@ -1053,8 +814,7 @@ between each category." | |||
| 1053 | ;; Else we could have used pop-to-buffer. | 814 | ;; Else we could have used pop-to-buffer. |
| 1054 | (display-buffer todo-print-buffer-name) | 815 | (display-buffer todo-print-buffer-name) |
| 1055 | (message "Type C-x 1 to remove %s window. M-C-v to scroll the help." | 816 | (message "Type C-x 1 to remove %s window. M-C-v to scroll the help." |
| 1056 | todo-print-buffer-name) | 817 | todo-print-buffer-name))) |
| 1057 | )) | ||
| 1058 | 818 | ||
| 1059 | (defun todo-save-top-priorities (&optional nof-priorities) | 819 | (defun todo-save-top-priorities (&optional nof-priorities) |
| 1060 | "Save top priorities for each category in `todo-file-top'. | 820 | "Save top priorities for each category in `todo-file-top'. |
| @@ -1062,38 +822,24 @@ between each category." | |||
| 1062 | Number of entries for each category is given by NOF-PRIORITIES which | 822 | Number of entries for each category is given by NOF-PRIORITIES which |
| 1063 | defaults to `todo-show-priorities'." | 823 | defaults to `todo-show-priorities'." |
| 1064 | (interactive "P") | 824 | (interactive "P") |
| 1065 | (save-window-excursion | 825 | (with-temp-buffer |
| 1066 | (save-excursion | 826 | (todo-top-priorities nof-priorities) |
| 1067 | (save-restriction | 827 | (write-file todo-file-top))) |
| 1068 | (todo-top-priorities nof-priorities) | ||
| 1069 | (set-buffer todo-tmp-buffer-name) | ||
| 1070 | (write-file todo-file-top) | ||
| 1071 | (kill-this-buffer) | ||
| 1072 | )))) | ||
| 1073 | 828 | ||
| 1074 | ;;;###autoload | 829 | ;;;###autoload |
| 1075 | (defun todo-print (&optional category-pr-page) | 830 | (defun todo-print (&optional category-pr-page) |
| 1076 | "Print todo summary using \\\[todo-print-function]. | 831 | "Print todo summary using \\[todo-print-function]. |
| 1077 | If CATEGORY-PR-PAGE is non-nil, a page separator \'^L\' is inserted | 832 | If CATEGORY-PR-PAGE is non-nil, a page separator \'^L\' is inserted |
| 1078 | between each category. | 833 | between each category. |
| 1079 | 834 | ||
| 1080 | Number of entries for each category is given by | 835 | Number of entries for each category is given by |
| 1081 | \'todo-print-priorities\'." | 836 | \'todo-print-priorities\'." |
| 1082 | (interactive "P") | 837 | (interactive "P") |
| 1083 | (if todo-print-function | 838 | (with-temp-buffer |
| 1084 | (progn | 839 | (todo-top-priorities todo-print-priorities |
| 1085 | (save-window-excursion | 840 | category-pr-page) |
| 1086 | (save-excursion | 841 | (funcall todo-print-function) |
| 1087 | (save-restriction | 842 | (message "Todo printing done."))) |
| 1088 | (todo-top-priorities todo-print-priorities | ||
| 1089 | category-pr-page) | ||
| 1090 | (set-buffer todo-tmp-buffer-name) | ||
| 1091 | (and (funcall todo-print-function) | ||
| 1092 | (kill-this-buffer)) | ||
| 1093 | (message "Todo printing done.")) | ||
| 1094 | ))) | ||
| 1095 | (message "todo-print-function undefinded") | ||
| 1096 | )) | ||
| 1097 | 843 | ||
| 1098 | (defun todo-jump-to-category () | 844 | (defun todo-jump-to-category () |
| 1099 | "Jump to a category. Default is previous category." | 845 | "Jump to a category. Default is previous category." |
| @@ -1107,12 +853,13 @@ Number of entries for each category is given by | |||
| 1107 | (if (string= "" category) | 853 | (if (string= "" category) |
| 1108 | (setq category (nth todo-category-number todo-categories))) | 854 | (setq category (nth todo-category-number todo-categories))) |
| 1109 | (setq todo-category-number | 855 | (setq todo-category-number |
| 1110 | (or (position category todo-categories :test 'equal) | 856 | (or (todo-position category todo-categories) |
| 1111 | (todo-add-category category))) | 857 | (todo-add-category category))) |
| 1112 | (todo-show))) | 858 | (todo-show))) |
| 1113 | 859 | ||
| 1114 | (defun todo-line-string () "Return current line in buffer as a string." | 860 | (defun todo-line-string () |
| 1115 | (buffer-substring (point-at-bol) (point-at-eol))) | 861 | "Return current line in buffer as a string." |
| 862 | (buffer-substring (line-beginning-position) (line-end-position))) | ||
| 1116 | 863 | ||
| 1117 | (defun todo-item-string-start () | 864 | (defun todo-item-string-start () |
| 1118 | "Return the start of this TODO list entry as a string." | 865 | "Return the start of this TODO list entry as a string." |
| @@ -1122,7 +869,8 @@ Number of entries for each category is given by | |||
| 1122 | (setq item (concat (substring item 0 56) "..."))) | 869 | (setq item (concat (substring item 0 56) "..."))) |
| 1123 | item)) | 870 | item)) |
| 1124 | 871 | ||
| 1125 | (defun todo-item-start () "Return point at start of current TODO list item." | 872 | (defun todo-item-start () |
| 873 | "Return point at start of current TODO list item." | ||
| 1126 | (save-excursion | 874 | (save-excursion |
| 1127 | (beginning-of-line) | 875 | (beginning-of-line) |
| 1128 | (if (not (looking-at (regexp-quote todo-prefix))) | 876 | (if (not (looking-at (regexp-quote todo-prefix))) |
| @@ -1130,14 +878,16 @@ Number of entries for each category is given by | |||
| 1130 | (concat "^" (regexp-quote todo-prefix)) nil t)) | 878 | (concat "^" (regexp-quote todo-prefix)) nil t)) |
| 1131 | (point))) | 879 | (point))) |
| 1132 | 880 | ||
| 1133 | (defun todo-item-end () "Return point at end of current TODO list item." | 881 | (defun todo-item-end () |
| 882 | "Return point at end of current TODO list item." | ||
| 1134 | (save-excursion | 883 | (save-excursion |
| 1135 | (end-of-line) | 884 | (end-of-line) |
| 1136 | (search-forward-regexp | 885 | (search-forward-regexp |
| 1137 | (concat "^" (regexp-quote todo-prefix)) nil 'goto-end) | 886 | (concat "^" (regexp-quote todo-prefix)) nil 'goto-end) |
| 1138 | (1- (point-at-bol)))) | 887 | (1- (line-beginning-position)))) |
| 1139 | 888 | ||
| 1140 | (defun todo-remove-item () "Delete the current entry from the TODO list." | 889 | (defun todo-remove-item () |
| 890 | "Delete the current entry from the TODO list." | ||
| 1141 | (delete-region (todo-item-start) (1+ (todo-item-end)))) | 891 | (delete-region (todo-item-start) (1+ (todo-item-end)))) |
| 1142 | 892 | ||
| 1143 | (defun todo-item-string () "Return current TODO list entry as a string." | 893 | (defun todo-item-string () "Return current TODO list entry as a string." |
| @@ -1156,43 +906,6 @@ Number of entries for each category is given by | |||
| 1156 | (mapcar (lambda (cat) (cons cat nil)) | 906 | (mapcar (lambda (cat) (cons cat nil)) |
| 1157 | todo-categories)) | 907 | todo-categories)) |
| 1158 | 908 | ||
| 1159 | ;; utility functions: These are available in XEmacs, but not in Emacs 19.34 | ||
| 1160 | |||
| 1161 | (if (not (fboundp 'point-at-bol)) | ||
| 1162 | (defun point-at-bol () "Return value of point at beginning of line." | ||
| 1163 | (save-excursion | ||
| 1164 | (beginning-of-line) | ||
| 1165 | (point)))) | ||
| 1166 | |||
| 1167 | (if (not (fboundp 'point-at-eol)) | ||
| 1168 | (defun point-at-eol () "Return value of point at end of line." | ||
| 1169 | (save-excursion | ||
| 1170 | (end-of-line) | ||
| 1171 | (point)))) | ||
| 1172 | |||
| 1173 | ;; splits at a white space, returns a list | ||
| 1174 | (if (not (fboundp 'split-string)) | ||
| 1175 | (defun split-string (string &optional separators) | ||
| 1176 | "Splits STRING into substrings where there are matches for SEPARATORS. | ||
| 1177 | Each match for SEPARATORS is a splitting point. | ||
| 1178 | The substrings between the splitting points are made into a list | ||
| 1179 | which is returned. | ||
| 1180 | If SEPARATORS is absent, it defaults to \"[ \\f\\t\\n\\r\\v]+\"." | ||
| 1181 | (let ((rexp (or separators "[ \f\t\n\r\v]+")) | ||
| 1182 | (start 0) | ||
| 1183 | (list nil)) | ||
| 1184 | (while (string-match rexp string start) | ||
| 1185 | (or (eq (match-beginning 0) 0) | ||
| 1186 | (setq list | ||
| 1187 | (cons (substring string start (match-beginning 0)) | ||
| 1188 | list))) | ||
| 1189 | (setq start (match-end 0))) | ||
| 1190 | (or (eq start (length string)) | ||
| 1191 | (setq list | ||
| 1192 | (cons (substring string start) | ||
| 1193 | list))) | ||
| 1194 | (nreverse list)))) | ||
| 1195 | |||
| 1196 | ;; --------------------------------------------------------------------------- | 909 | ;; --------------------------------------------------------------------------- |
| 1197 | 910 | ||
| 1198 | (easy-menu-define todo-menu todo-mode-map "Todo Menu" | 911 | (easy-menu-define todo-menu todo-mode-map "Todo Menu" |