From mboxrd@z Thu Jan 1 00:00:00 1970 From: James TD Smith Subject: [PATCH 1/9] Some improvements to the modeline clock display Date: Sat, 20 Sep 2008 22:08:46 +0100 Message-ID: <20080920210846.19759.43871.stgit@nyarlathotep.internal.mohorovi.cc> References: <20080920210101.19759.15959.stgit@nyarlathotep.internal.mohorovi.cc> Mime-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Kh9hC-00041g-ME for emacs-orgmode@gnu.org; Sat, 20 Sep 2008 17:08:50 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Kh9hB-00040l-Dz for emacs-orgmode@gnu.org; Sat, 20 Sep 2008 17:08:50 -0400 Received: from [199.232.76.173] (port=60155 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Kh9hB-00040R-7q for emacs-orgmode@gnu.org; Sat, 20 Sep 2008 17:08:49 -0400 Received: from 81-86-40-42.dsl.pipex.com ([81.86.40.42]:49503 helo=yog-sothoth.mohorovi.cc) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Kh9hA-0001zu-55 for emacs-orgmode@gnu.org; Sat, 20 Sep 2008 17:08:49 -0400 Received: from nyarlathotep.internal.mohorovi.cc (Debian-exim@nyarlathotep.internal.mohorovi.cc [10.0.0.5]) by yog-sothoth.mohorovi.cc (8.14.2/8.14.2) with ESMTP id m8KL8kg6017645 for ; Sat, 20 Sep 2008 22:08:46 +0100 (BST) (envelope-from ahktenzero@mohorovi.cc) Received: from [127.0.0.1] (helo=nyarlathotep.internal.mohorovi.cc ident=ahktenzero) by nyarlathotep.internal.mohorovi.cc with esmtp (Exim 4.69) (envelope-from ) id 1Kh9h8-0005ne-Cu for emacs-orgmode@gnu.org; Sat, 20 Sep 2008 22:08:46 +0100 In-Reply-To: <20080920210101.19759.15959.stgit@nyarlathotep.internal.mohorovi.cc> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org Allow users to specify a maximum length for the modeline clock. Add an option to limit the length of the clock string in the modeline. When the limit is in effect, the full item text is included in the tooltip on the clock string. Make clicking on the clock string now goes to the currently clocked item. --- lisp/ChangeLog | 29 +++++++++++------------------ lisp/org-clock.el | 36 ++++++++++++++++++++++++++---------- 2 files changed, 37 insertions(+), 28 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 3a57ca8..5eb535f 100755 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,13 @@ +2008-09-20 James TD Smith + + * lisp/org-clock.el (org-update-mode-line): Support limiting the + modeline clock string, and display the full todo value in the + tooltip. Set a local keymap so mouse-3 on the clock string goes to + the currently clocked task. + (org-clock-string-limit): Add a custom value for the maximum + length of the clock string in the modeline. + (org-clock-mode-map): Add a keymap for the modeline string + 2008-09-20 Bastien Guerry * org-export-latex.el (org-export-latex-tables): protect exported @@ -215,16 +225,6 @@ * org.el (org-columns-modify-value-for-display-function): New option. - - - - - - - - - - * org-publish.el (org-publish-file): Make sure the directory match for the publishing directory works correctly. @@ -238,13 +238,6 @@ * org.el (org-autoload): Add `org-dblock-write:columnview'. - - - - - - - 2008-07-23 Carsten Dominik * org-exp.el (org-export-region-as-html, org-export-as-html): Make @@ -255,7 +248,7 @@ * org-agenda.el (org-batch-store-agenda-views): Fix parsing bug. -2008-07-20 Juri Linkov +2008-07-20 Juri Linkov * org.el (narrow-map): Bind `org-narrow-to-subtree' to "s" on the new keymap `narrow-map' instead of binding "\C-xns". diff --git a/lisp/org-clock.el b/lisp/org-clock.el index f2f49a8..4d2069c 100644 --- a/lisp/org-clock.el +++ b/lisp/org-clock.el @@ -86,6 +86,10 @@ The function is called with point at the beginning of the headline." :group 'org-clock :type 'function) +(defcustom org-clock-string-limit 0 + "Maximum length of clock strings in the modeline. 0 means no limit" + :group 'org-clock + :type 'integer) ;;; The clock for measuring work time. @@ -107,6 +111,9 @@ of a different task.") (defvar org-clock-interrupted-task (make-marker) "Marker pointing to the task that has been interrupted by the current clock.") +(defvar org-clock-mode-map (make-sparse-keymap)) +(define-key org-clock-mode-map [mode-line mouse-2] 'org-clock-goto) + (defun org-clock-history-push (&optional pos buffer) "Push a marker to the clock history." (setq org-clock-history-length (max 1 (min 35 org-clock-history-length))) @@ -190,15 +197,23 @@ of a different task.") (when (and cat task) (insert (format "[%c] %-15s %s\n" i cat task)) (cons i marker))))) - + (defun org-update-mode-line () (let* ((delta (- (time-to-seconds (current-time)) - (time-to-seconds org-clock-start-time))) + (time-to-seconds org-clock-start-time))) (h (floor delta 3600)) (m (floor (- delta (* 3600 h)) 60))) (setq org-mode-line-string - (propertize (format (concat "-[" org-time-clocksum-format " (%s)]") h m org-clock-heading) - 'help-echo "Org-mode clock is running")) + (propertize (let ((clock-string (format (concat "-[" org-time-clocksum-format " (%s)]") + h m org-clock-heading)) + (help-text "Org-mode clock is running")) + (if (and (> org-clock-string-limit 0) + (> (length clock-string) org-clock-string-limit)) + (propertize (substring clock-string 0 org-clock-string-limit) + 'help-echo (concat help-text ": " org-clock-heading)) + (propertize clock-string 'help-echo help-text))) + 'local-map org-clock-mode-map + 'mouse-face '(face mode-line-highlight))) (force-mode-line-update))) (defvar org-clock-mode-line-entry nil @@ -253,12 +268,13 @@ the clocking selection, associated with the letter `d'." org-clock-in-switch-to-state "\\>")))) (org-todo org-clock-in-switch-to-state)) - (if (and org-clock-heading-function - (functionp org-clock-heading-function)) - (setq org-clock-heading (funcall org-clock-heading-function)) - (if (looking-at org-complex-heading-regexp) - (setq org-clock-heading (match-string 4)) - (setq org-clock-heading "???"))) + (setq org-clock-heading + (cond ((and org-clock-heading-function + (functionp org-clock-heading-function)) + (funcall org-clock-heading-function)) + ((looking-at org-complex-heading-regexp) + (match-string 4)) + (t "???"))) (setq org-clock-heading (propertize org-clock-heading 'face nil)) (org-clock-find-position)