diff options
| author | Glenn Morris | 2008-03-08 23:18:42 +0000 |
|---|---|---|
| committer | Glenn Morris | 2008-03-08 23:18:42 +0000 |
| commit | fc25001524fcea22287e15e8343f2603a45cd317 (patch) | |
| tree | 24cf3c00858a8aeddea37fd5c35330760a68f797 | |
| parent | 6afe7cdd7dd83d793ccd2c537b1a05da923ccc7f (diff) | |
| download | emacs-fc25001524fcea22287e15e8343f2603a45cd317.tar.gz emacs-fc25001524fcea22287e15e8343f2603a45cd317.zip | |
Add doc-strings to all functions.
(timeclock-workday, timeclock-in, timeclock-completing-read): Doc fixes.
(timeclock-entry-list-length, timeclock-entry-list-projects)
(timeclock-day-list-projects, timeclock-day-list): Use dolist.
| -rw-r--r-- | lisp/ChangeLog | 7 | ||||
| -rw-r--r-- | lisp/calendar/timeclock.el | 85 |
2 files changed, 60 insertions, 32 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 25a2b7bc20c..6aa41858a2e 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -71,7 +71,7 @@ | |||
| 71 | (hebrew-calendar-elapsed-days, hebrew-calendar-long-heshvan-p) | 71 | (hebrew-calendar-elapsed-days, hebrew-calendar-long-heshvan-p) |
| 72 | (hebrew-calendar-short-kislev-p, mark-hebrew-diary-entries) | 72 | (hebrew-calendar-short-kislev-p, mark-hebrew-diary-entries) |
| 73 | (insert-hebrew-diary-entry, insert-monthly-hebrew-diary-entry) | 73 | (insert-hebrew-diary-entry, insert-monthly-hebrew-diary-entry) |
| 74 | (insert-yearly-hebrew-diary-entry, diary-yahrzeit): Doc fixes. | 74 | (insert-yearly-hebrew-diary-entry, diary-yahrzeit): |
| 75 | * calendar/cal-islam.el (islamic-calendar-leap-year-p) | 75 | * calendar/cal-islam.el (islamic-calendar-leap-year-p) |
| 76 | (list-islamic-diary-entries, mark-islamic-diary-entries) | 76 | (list-islamic-diary-entries, mark-islamic-diary-entries) |
| 77 | (insert-islamic-diary-entry, insert-monthly-islamic-diary-entry) | 77 | (insert-islamic-diary-entry, insert-monthly-islamic-diary-entry) |
| @@ -180,6 +180,11 @@ | |||
| 180 | (calendar-sunrise-sunset, diary-sunrise-sunset, diary-sabbath-candles): | 180 | (calendar-sunrise-sunset, diary-sunrise-sunset, diary-sabbath-candles): |
| 181 | Use or. | 181 | Use or. |
| 182 | 182 | ||
| 183 | * calendar/timeclock.el: Add doc-strings to all functions. | ||
| 184 | (timeclock-workday, timeclock-in, timeclock-completing-read): Doc fixes. | ||
| 185 | (timeclock-entry-list-length, timeclock-entry-list-projects) | ||
| 186 | (timeclock-day-list-projects, timeclock-day-list): Use dolist. | ||
| 187 | |||
| 183 | * calendar/todo-mode.el: Remove un-needed eval-when-compile. | 188 | * calendar/todo-mode.el: Remove un-needed eval-when-compile. |
| 184 | 189 | ||
| 185 | * textmodes/org.el (list-diary-entries-hook): Declare for compiler. | 190 | * textmodes/org.el (list-diary-entries-hook): Declare for compiler. |
diff --git a/lisp/calendar/timeclock.el b/lisp/calendar/timeclock.el index a24bbab71fc..fb4a4c1afcd 100644 --- a/lisp/calendar/timeclock.el +++ b/lisp/calendar/timeclock.el | |||
| @@ -90,7 +90,7 @@ | |||
| 90 | :group 'timeclock) | 90 | :group 'timeclock) |
| 91 | 91 | ||
| 92 | (defcustom timeclock-workday (* 8 60 60) | 92 | (defcustom timeclock-workday (* 8 60 60) |
| 93 | "The length of a work period." | 93 | "The length of a work period in seconds." |
| 94 | :type 'integer | 94 | :type 'integer |
| 95 | :group 'timeclock) | 95 | :group 'timeclock) |
| 96 | 96 | ||
| @@ -341,7 +341,7 @@ You must modify via \\[customize] for this variable to have an effect." | |||
| 341 | (defun timeclock-in (&optional arg project find-project) | 341 | (defun timeclock-in (&optional arg project find-project) |
| 342 | "Clock in, recording the current time moment in the timelog. | 342 | "Clock in, recording the current time moment in the timelog. |
| 343 | With a numeric prefix ARG, record the fact that today has only that | 343 | With a numeric prefix ARG, record the fact that today has only that |
| 344 | many hours in it to be worked. If arg is a non-numeric prefix arg | 344 | many hours in it to be worked. If ARG is a non-numeric prefix argument |
| 345 | \(non-nil, but not a number), 0 is assumed (working on a holiday or | 345 | \(non-nil, but not a number), 0 is assumed (working on a holiday or |
| 346 | weekend). *If not called interactively, ARG should be the number of | 346 | weekend). *If not called interactively, ARG should be the number of |
| 347 | _seconds_ worked today*. This feature only has effect the first time | 347 | _seconds_ worked today*. This feature only has effect the first time |
| @@ -594,7 +594,7 @@ relative only to the time worked today, and not to past time." | |||
| 594 | OLD-DEFAULT hours are set for every day that has no number indicated." | 594 | OLD-DEFAULT hours are set for every day that has no number indicated." |
| 595 | (interactive "P") | 595 | (interactive "P") |
| 596 | (if old-default (setq old-default (prefix-numeric-value old-default)) | 596 | (if old-default (setq old-default (prefix-numeric-value old-default)) |
| 597 | (error "timelog-make-hours-explicit requires an explicit argument")) | 597 | (error "`timelog-make-hours-explicit' requires an explicit argument")) |
| 598 | (let ((extant-timelog (find-buffer-visiting timeclock-file)) | 598 | (let ((extant-timelog (find-buffer-visiting timeclock-file)) |
| 599 | current-date) | 599 | current-date) |
| 600 | (with-current-buffer (find-file-noselect timeclock-file t) | 600 | (with-current-buffer (find-file-noselect timeclock-file t) |
| @@ -627,7 +627,9 @@ OLD-DEFAULT hours are set for every day that has no number indicated." | |||
| 627 | (defvar timeclock-last-project nil) | 627 | (defvar timeclock-last-project nil) |
| 628 | 628 | ||
| 629 | (defun timeclock-completing-read (prompt alist &optional default) | 629 | (defun timeclock-completing-read (prompt alist &optional default) |
| 630 | "A version of `completing-read' that works on both Emacs and XEmacs." | 630 | "A version of `completing-read' that works on both Emacs and XEmacs. |
| 631 | PROMPT, ALIST and DEFAULT are used for the PROMPT, COLLECTION and DEF | ||
| 632 | arguments of `completing-read'." | ||
| 631 | (if (featurep 'xemacs) | 633 | (if (featurep 'xemacs) |
| 632 | (let ((str (completing-read prompt alist))) | 634 | (let ((str (completing-read prompt alist))) |
| 633 | (if (or (null str) (= (length str) 0)) | 635 | (if (or (null str) (= (length str) 0)) |
| @@ -745,80 +747,96 @@ This is only provided for coherency when used by | |||
| 745 | timeclock-last-period)) | 747 | timeclock-last-period)) |
| 746 | 748 | ||
| 747 | (defsubst timeclock-entry-length (entry) | 749 | (defsubst timeclock-entry-length (entry) |
| 750 | "Return the length of ENTRY in seconds." | ||
| 748 | (- (timeclock-time-to-seconds (cadr entry)) | 751 | (- (timeclock-time-to-seconds (cadr entry)) |
| 749 | (timeclock-time-to-seconds (car entry)))) | 752 | (timeclock-time-to-seconds (car entry)))) |
| 750 | 753 | ||
| 751 | (defsubst timeclock-entry-begin (entry) | 754 | (defsubst timeclock-entry-begin (entry) |
| 755 | "Return the start time of ENTRY." | ||
| 752 | (car entry)) | 756 | (car entry)) |
| 753 | 757 | ||
| 754 | (defsubst timeclock-entry-end (entry) | 758 | (defsubst timeclock-entry-end (entry) |
| 759 | "Return the end time of ENTRY." | ||
| 755 | (cadr entry)) | 760 | (cadr entry)) |
| 756 | 761 | ||
| 757 | (defsubst timeclock-entry-project (entry) | 762 | (defsubst timeclock-entry-project (entry) |
| 763 | "Return the project of ENTRY." | ||
| 758 | (nth 2 entry)) | 764 | (nth 2 entry)) |
| 759 | 765 | ||
| 760 | (defsubst timeclock-entry-comment (entry) | 766 | (defsubst timeclock-entry-comment (entry) |
| 767 | "Return the comment of ENTRY." | ||
| 761 | (nth 3 entry)) | 768 | (nth 3 entry)) |
| 762 | 769 | ||
| 763 | |||
| 764 | (defsubst timeclock-entry-list-length (entry-list) | 770 | (defsubst timeclock-entry-list-length (entry-list) |
| 771 | "Return the total length of ENTRY-LIST in seconds." | ||
| 765 | (let ((length 0)) | 772 | (let ((length 0)) |
| 766 | (while entry-list | 773 | (dolist (entry entry-list) |
| 767 | (setq length (+ length (timeclock-entry-length (car entry-list)))) | 774 | (setq length (+ length (timeclock-entry-length entry)))) |
| 768 | (setq entry-list (cdr entry-list))) | ||
| 769 | length)) | 775 | length)) |
| 770 | 776 | ||
| 771 | (defsubst timeclock-entry-list-begin (entry-list) | 777 | (defsubst timeclock-entry-list-begin (entry-list) |
| 778 | "Return the start time of the first element of ENTRY-LIST." | ||
| 772 | (timeclock-entry-begin (car entry-list))) | 779 | (timeclock-entry-begin (car entry-list))) |
| 773 | 780 | ||
| 774 | (defsubst timeclock-entry-list-end (entry-list) | 781 | (defsubst timeclock-entry-list-end (entry-list) |
| 782 | "Return the end time of the last element of ENTRY-LIST." | ||
| 775 | (timeclock-entry-end (car (last entry-list)))) | 783 | (timeclock-entry-end (car (last entry-list)))) |
| 776 | 784 | ||
| 777 | (defsubst timeclock-entry-list-span (entry-list) | 785 | (defsubst timeclock-entry-list-span (entry-list) |
| 786 | "Return the total time in seconds spanned by ENTRY-LIST." | ||
| 778 | (- (timeclock-time-to-seconds (timeclock-entry-list-end entry-list)) | 787 | (- (timeclock-time-to-seconds (timeclock-entry-list-end entry-list)) |
| 779 | (timeclock-time-to-seconds (timeclock-entry-list-begin entry-list)))) | 788 | (timeclock-time-to-seconds (timeclock-entry-list-begin entry-list)))) |
| 780 | 789 | ||
| 781 | (defsubst timeclock-entry-list-break (entry-list) | 790 | (defsubst timeclock-entry-list-break (entry-list) |
| 791 | "Return the total break time (span - length) in ENTRY-LIST." | ||
| 782 | (- (timeclock-entry-list-span entry-list) | 792 | (- (timeclock-entry-list-span entry-list) |
| 783 | (timeclock-entry-list-length entry-list))) | 793 | (timeclock-entry-list-length entry-list))) |
| 784 | 794 | ||
| 785 | (defsubst timeclock-entry-list-projects (entry-list) | 795 | (defsubst timeclock-entry-list-projects (entry-list) |
| 786 | (let (projects) | 796 | "Return a list of all the projects in ENTRY-LIST." |
| 787 | (while entry-list | 797 | (let (projects proj) |
| 788 | (let ((project (timeclock-entry-project (car entry-list)))) | 798 | (dolist (entry entry-list) |
| 789 | (if projects | 799 | (setq proj (timeclock-entry-project entry)) |
| 790 | (add-to-list 'projects project) | 800 | (if projects |
| 791 | (setq projects (list project)))) | 801 | (add-to-list 'projects proj) |
| 792 | (setq entry-list (cdr entry-list))) | 802 | (setq projects (list proj)))) |
| 793 | projects)) | 803 | projects)) |
| 794 | 804 | ||
| 795 | |||
| 796 | (defsubst timeclock-day-required (day) | 805 | (defsubst timeclock-day-required (day) |
| 806 | "Return the required length of DAY in seconds, default `timeclock-workday'." | ||
| 797 | (or (car day) timeclock-workday)) | 807 | (or (car day) timeclock-workday)) |
| 798 | 808 | ||
| 799 | (defsubst timeclock-day-length (day) | 809 | (defsubst timeclock-day-length (day) |
| 810 | "Return the actual length of DAY in seconds." | ||
| 800 | (timeclock-entry-list-length (cdr day))) | 811 | (timeclock-entry-list-length (cdr day))) |
| 801 | 812 | ||
| 802 | (defsubst timeclock-day-debt (day) | 813 | (defsubst timeclock-day-debt (day) |
| 814 | "Return the debt (required - actual) associated with DAY, in seconds." | ||
| 803 | (- (timeclock-day-required day) | 815 | (- (timeclock-day-required day) |
| 804 | (timeclock-day-length day))) | 816 | (timeclock-day-length day))) |
| 805 | 817 | ||
| 806 | (defsubst timeclock-day-begin (day) | 818 | (defsubst timeclock-day-begin (day) |
| 819 | "Return the start time of DAY." | ||
| 807 | (timeclock-entry-list-begin (cdr day))) | 820 | (timeclock-entry-list-begin (cdr day))) |
| 808 | 821 | ||
| 809 | (defsubst timeclock-day-end (day) | 822 | (defsubst timeclock-day-end (day) |
| 823 | "Return the end time of DAY." | ||
| 810 | (timeclock-entry-list-end (cdr day))) | 824 | (timeclock-entry-list-end (cdr day))) |
| 811 | 825 | ||
| 812 | (defsubst timeclock-day-span (day) | 826 | (defsubst timeclock-day-span (day) |
| 827 | "Return the span of DAY." | ||
| 813 | (timeclock-entry-list-span (cdr day))) | 828 | (timeclock-entry-list-span (cdr day))) |
| 814 | 829 | ||
| 815 | (defsubst timeclock-day-break (day) | 830 | (defsubst timeclock-day-break (day) |
| 831 | "Return the total break time of DAY." | ||
| 816 | (timeclock-entry-list-break (cdr day))) | 832 | (timeclock-entry-list-break (cdr day))) |
| 817 | 833 | ||
| 818 | (defsubst timeclock-day-projects (day) | 834 | (defsubst timeclock-day-projects (day) |
| 835 | "Return a list of all the projects in DAY." | ||
| 819 | (timeclock-entry-list-projects (cdr day))) | 836 | (timeclock-entry-list-projects (cdr day))) |
| 820 | 837 | ||
| 821 | (defmacro timeclock-day-list-template (func) | 838 | (defmacro timeclock-day-list-template (func) |
| 839 | "Template for summing the result of FUNC on each element of DAY-LIST." | ||
| 822 | `(let ((length 0)) | 840 | `(let ((length 0)) |
| 823 | (while day-list | 841 | (while day-list |
| 824 | (setq length (+ length (,(eval func) (car day-list)))) | 842 | (setq length (+ length (,(eval func) (car day-list)))) |
| @@ -826,57 +844,62 @@ This is only provided for coherency when used by | |||
| 826 | length)) | 844 | length)) |
| 827 | 845 | ||
| 828 | (defun timeclock-day-list-required (day-list) | 846 | (defun timeclock-day-list-required (day-list) |
| 847 | "Return total required length of DAY-LIST, in seconds." | ||
| 829 | (timeclock-day-list-template 'timeclock-day-required)) | 848 | (timeclock-day-list-template 'timeclock-day-required)) |
| 830 | 849 | ||
| 831 | (defun timeclock-day-list-length (day-list) | 850 | (defun timeclock-day-list-length (day-list) |
| 851 | "Return actual length of DAY-LIST, in seconds." | ||
| 832 | (timeclock-day-list-template 'timeclock-day-length)) | 852 | (timeclock-day-list-template 'timeclock-day-length)) |
| 833 | 853 | ||
| 834 | (defun timeclock-day-list-debt (day-list) | 854 | (defun timeclock-day-list-debt (day-list) |
| 855 | "Return total debt (required - actual) of DAY-LIST." | ||
| 835 | (timeclock-day-list-template 'timeclock-day-debt)) | 856 | (timeclock-day-list-template 'timeclock-day-debt)) |
| 836 | 857 | ||
| 837 | (defsubst timeclock-day-list-begin (day-list) | 858 | (defsubst timeclock-day-list-begin (day-list) |
| 859 | "Return the start time of DAY-LIST." | ||
| 838 | (timeclock-day-begin (car day-list))) | 860 | (timeclock-day-begin (car day-list))) |
| 839 | 861 | ||
| 840 | (defsubst timeclock-day-list-end (day-list) | 862 | (defsubst timeclock-day-list-end (day-list) |
| 863 | "Return the end time of DAY-LIST." | ||
| 841 | (timeclock-day-end (car (last day-list)))) | 864 | (timeclock-day-end (car (last day-list)))) |
| 842 | 865 | ||
| 843 | (defun timeclock-day-list-span (day-list) | 866 | (defun timeclock-day-list-span (day-list) |
| 867 | "Return the span of DAY-LIST." | ||
| 844 | (timeclock-day-list-template 'timeclock-day-span)) | 868 | (timeclock-day-list-template 'timeclock-day-span)) |
| 845 | 869 | ||
| 846 | (defun timeclock-day-list-break (day-list) | 870 | (defun timeclock-day-list-break (day-list) |
| 871 | "Return the total break of DAY-LIST." | ||
| 847 | (timeclock-day-list-template 'timeclock-day-break)) | 872 | (timeclock-day-list-template 'timeclock-day-break)) |
| 848 | 873 | ||
| 849 | (defun timeclock-day-list-projects (day-list) | 874 | (defun timeclock-day-list-projects (day-list) |
| 875 | "Return a list of all the projects in DAY-LIST." | ||
| 850 | (let (projects) | 876 | (let (projects) |
| 851 | (while day-list | 877 | (dolist (day day-list) |
| 852 | (let ((projs (timeclock-day-projects (car day-list)))) | 878 | (dolist (proj (timeclock-day-projects day)) |
| 853 | (while projs | 879 | (if projects |
| 854 | (if projects | 880 | (add-to-list 'projects proj) |
| 855 | (add-to-list 'projects (car projs)) | 881 | (setq projects (list proj))))) |
| 856 | (setq projects (list (car projs)))) | ||
| 857 | (setq projs (cdr projs)))) | ||
| 858 | (setq day-list (cdr day-list))) | ||
| 859 | projects)) | 882 | projects)) |
| 860 | 883 | ||
| 861 | |||
| 862 | (defsubst timeclock-current-debt (&optional log-data) | 884 | (defsubst timeclock-current-debt (&optional log-data) |
| 885 | "Return the seconds debt from LOG-DATA, default `timeclock-log-data'." | ||
| 863 | (nth 0 (or log-data (timeclock-log-data)))) | 886 | (nth 0 (or log-data (timeclock-log-data)))) |
| 864 | 887 | ||
| 865 | (defsubst timeclock-day-alist (&optional log-data) | 888 | (defsubst timeclock-day-alist (&optional log-data) |
| 889 | "Return the date alist from LOG-DATA, default `timeclock-log-data'." | ||
| 866 | (nth 1 (or log-data (timeclock-log-data)))) | 890 | (nth 1 (or log-data (timeclock-log-data)))) |
| 867 | 891 | ||
| 868 | (defun timeclock-day-list (&optional log-data) | 892 | (defun timeclock-day-list (&optional log-data) |
| 869 | (let ((alist (timeclock-day-alist log-data)) | 893 | "Return a list of the cdrs of the date alist from LOG-DATA." |
| 870 | day-list) | 894 | (let (day-list) |
| 871 | (while alist | 895 | (dolist (date-list (timeclock-day-alist log-data)) |
| 872 | (setq day-list (cons (cdar alist) day-list) | 896 | (setq day-list (cons (cdr date-list) day-list))) |
| 873 | alist (cdr alist))) | ||
| 874 | day-list)) | 897 | day-list)) |
| 875 | 898 | ||
| 876 | (defsubst timeclock-project-alist (&optional log-data) | 899 | (defsubst timeclock-project-alist (&optional log-data) |
| 900 | "Return the project alist from LOG-DATA, default `timeclock-log-data'." | ||
| 877 | (nth 2 (or log-data (timeclock-log-data)))) | 901 | (nth 2 (or log-data (timeclock-log-data)))) |
| 878 | 902 | ||
| 879 | |||
| 880 | (defun timeclock-log-data (&optional recent-only filename) | 903 | (defun timeclock-log-data (&optional recent-only filename) |
| 881 | "Return the contents of the timelog file, in a useful format. | 904 | "Return the contents of the timelog file, in a useful format. |
| 882 | If the optional argument RECENT-ONLY is non-nil, only show the contents | 905 | If the optional argument RECENT-ONLY is non-nil, only show the contents |