Mercurial > emacs
changeset 37324:570c667b4d1c
(timeclock-completing-read): new function.
(timeclock-ask-for-project, timeclock-ask-for-reason): Call
`timeclock-completing-read', which works under XEmacs as well.
author | John Wiegley <johnw@newartisans.com> |
---|---|
date | Wed, 11 Apr 2001 15:50:01 +0000 |
parents | 11b33211a908 |
children | 56555e5142a2 |
files | lisp/calendar/timeclock.el |
diffstat | 1 files changed, 18 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/calendar/timeclock.el Wed Apr 11 15:49:31 2001 +0000 +++ b/lisp/calendar/timeclock.el Wed Apr 11 15:50:01 2001 +0000 @@ -540,21 +540,31 @@ (defvar timeclock-project-list nil) (defvar timeclock-last-project nil) +(defun timeclock-completing-read (prompt alist &optional default) + "A version of `completing-read' that works on both Emacs and XEmacs." + (if (featurep 'xemacs) + (let ((str (completing-read prompt alist))) + (if (or (null str) (= (length str) 0)) + default + str)) + (completing-read prompt alist nil nil nil nil default))) + (defun timeclock-ask-for-project () "Ask the user for the project they are clocking into." - (completing-read (format "Clock into which project (default \"%s\"): " - (or timeclock-last-project - (car timeclock-project-list))) - (mapcar 'list timeclock-project-list) - nil nil nil nil (or timeclock-last-project - (car timeclock-project-list)))) + (timeclock-completing-read + (format "Clock into which project (default \"%s\"): " + (or timeclock-last-project + (car timeclock-project-list))) + (mapcar 'list timeclock-project-list) + (or timeclock-last-project + (car timeclock-project-list)))) (defvar timeclock-reason-list nil) (defun timeclock-ask-for-reason () "Ask the user for the reason they are clocking out." - (completing-read "Reason for clocking out: " - (mapcar 'list timeclock-reason-list))) + (timeclock-completing-read "Reason for clocking out: " + (mapcar 'list timeclock-reason-list))) (defun timeclock-update-modeline () "Update the `timeclock-mode-string' displayed in the modeline."