summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Guerry <bzg@altern.org>2012-05-05 14:21:13 +0200
committerBastien Guerry <bzg@altern.org>2012-05-05 14:21:13 +0200
commit7c513b3047ceff0fb60ce344646838d597c8d122 (patch)
tree4d93ffd510db4bf9593e05be0145a263667a6016
parent005576f0b6b1814f83a991756ae62b41f0035ce6 (diff)
downloadorg-mode-7c513b3047ceff0fb60ce344646838d597c8d122.tar.gz
New option `org-clock-frame-title-format'.
* org-clock.el (org-frame-title-format-backup): New variable to store the value of `frame-title-format' before `org-clock' might replace it by `org-clock-frame-title-format'. (org-clock-frame-title-format): New option. (org-frame-title-string): Delete. (org-clock-update-mode-line): Minor code reformatting. (org-clock-in, org-clock-out, org-clock-cancel): Use `org-clock-frame-title-format'. See http://thread.gmane.org/gmane.emacs.orgmode/55477 Trying to update `frame-title-format' is tricky and error-prone, since users can set up this variable in many different ways. AFAIK there is no equivalent to `global-mode-string' for setting the frame title, we would use it otherwise. The user can still configure `org-clock-frame-title-format' the way he wants.
-rw-r--r--lisp/org-clock.el44
1 files changed, 22 insertions, 22 deletions
diff --git a/lisp/org-clock.el b/lisp/org-clock.el
index 2aa01b5..0e08eb9 100644
--- a/lisp/org-clock.el
+++ b/lisp/org-clock.el
@@ -38,6 +38,7 @@
(declare-function org-pop-to-buffer-same-window "org-compat" (&optional buffer-or-name norecord label))
(defvar org-time-stamp-formats)
(defvar org-ts-what)
+(defvar org-frame-title-format-backup frame-title-format)
(defgroup org-clock nil
"Options concerning clocking working time in Org-mode."
@@ -352,6 +353,19 @@ nil current clock is not displayed"
(const :tag "Both" both)
(const :tag "None" nil)))
+(defcustom org-clock-frame-title-format '(t org-mode-line-string)
+ "The value for `frame-title-format' when clocking in.
+
+When `org-clock-clocked-in-display' is set to 'frame-title
+or 'both, clocking in will replace `frame-title-format' with
+this value. Clocking out will restore `frame-title-format'.
+
+`org-frame-title-string' is a format string using the same
+specifications than `frame-title-format', which see."
+ :version "24.1"
+ :group 'org-clock
+ :type 'sexp)
+
(defvar org-clock-in-prepare-hook nil
"Hook run when preparing the clock.
This hook is run before anything happens to the task that
@@ -374,8 +388,6 @@ to add an effort property.")
(defvar org-mode-line-string "")
(put 'org-mode-line-string 'risky-local-variable t)
-(defvar org-frame-title-string '(" " org-mode-line-string))
-
(defvar org-clock-mode-line-timer nil)
(defvar org-clock-idle-timer nil)
(defvar org-clock-heading) ; defined in org.el
@@ -575,8 +587,7 @@ If not, show simply the clocked time like 01:50."
'help-echo (concat help-text ": " org-clock-heading))
(org-propertize clock-string 'help-echo help-text)))
'local-map org-clock-mode-line-map
- 'mouse-face (if (featurep 'xemacs) 'highlight 'mode-line-highlight)
- ))
+ 'mouse-face (if (featurep 'xemacs) 'highlight 'mode-line-highlight)))
(if (and org-clock-task-overrun org-clock-task-overrun-text)
(setq org-mode-line-string
(concat (org-propertize
@@ -1204,12 +1215,9 @@ the clocking selection, associated with the letter `d'."
(setq global-mode-string
(append global-mode-string '(org-mode-line-string)))))
;; add to frame title
- (when (and (or (eq org-clock-clocked-in-display 'frame-title)
- (eq org-clock-clocked-in-display 'both))
- (listp frame-title-format))
- (or (memq 'org-frame-title-string frame-title-format)
- (setq frame-title-format
- (append frame-title-format '(org-frame-title-string)))))
+ (when (or (eq org-clock-clocked-in-display 'frame-title)
+ (eq org-clock-clocked-in-display 'both))
+ (setq frame-title-format org-clock-frame-title-format))
(org-clock-update-mode-line)
(when org-clock-mode-line-timer
(cancel-timer org-clock-mode-line-timer)
@@ -1366,9 +1374,7 @@ If there is no running clock, throw an error, unless FAIL-QUIETLY is set."
(when (not (org-clocking-p))
(setq global-mode-string
(delq 'org-mode-line-string global-mode-string))
- (when (listp frame-title-format)
- (setq frame-title-format
- (delq 'org-frame-title-string frame-title-format)))
+ (setq frame-title-format org-frame-title-format-backup)
(force-mode-line-update)
(if fail-quietly (throw 'exit t) (error "No active clock")))
(let (ts te s h m remove)
@@ -1413,9 +1419,7 @@ If there is no running clock, throw an error, unless FAIL-QUIETLY is set."
(setq org-clock-idle-timer nil))
(setq global-mode-string
(delq 'org-mode-line-string global-mode-string))
- (when (listp frame-title-format)
- (setq frame-title-format
- (delq 'org-frame-title-string frame-title-format)))
+ (setq frame-title-format org-frame-title-format-backup)
(when org-clock-out-switch-to-state
(save-excursion
(org-back-to-heading t)
@@ -1515,9 +1519,7 @@ UPDOWN tells whether to change 'up or 'down."
(when (not (org-clocking-p))
(setq global-mode-string
(delq 'org-mode-line-string global-mode-string))
- (when (listp frame-title-format)
- (setq frame-title-format
- (delq 'org-frame-title-string frame-title-format)))
+ (setq frame-title-format org-frame-title-format-backup)
(force-mode-line-update)
(error "No active clock"))
(save-excursion ; Do not replace this with `with-current-buffer'.
@@ -1530,9 +1532,7 @@ UPDOWN tells whether to change 'up or 'down."
(move-marker org-clock-hd-marker nil)
(setq global-mode-string
(delq 'org-mode-line-string global-mode-string))
- (when (listp frame-title-format)
- (setq frame-title-format
- (delq 'org-frame-title-string frame-title-format)))
+ (setq frame-title-format org-frame-title-format-backup)
(force-mode-line-update)
(message "Clock canceled")
(run-hooks 'org-clock-cancel-hook))