From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrii Kolomoiets Subject: [PATCH] org-clock.el: Fix restore of frame-title-format Date: Tue, 28 May 2019 16:57:42 +0300 Message-ID: <85266002-C647-4624-9E50-C73E89151BF3@gmail.com> References: <87woibq7dj.fsf@nicolasgoaziou.fr> Mime-Version: 1.0 (Mac OS X Mail 12.2 \(3445.102.3\)) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([209.51.188.92]:41716) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hVcbx-0004SA-KM for emacs-orgmode@gnu.org; Tue, 28 May 2019 09:57:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hVcbv-000585-NU for emacs-orgmode@gnu.org; Tue, 28 May 2019 09:57:53 -0400 Received: from mail-lf1-x141.google.com ([2a00:1450:4864:20::141]:45045) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hVcbs-00054P-Gi for emacs-orgmode@gnu.org; Tue, 28 May 2019 09:57:51 -0400 Received: by mail-lf1-x141.google.com with SMTP id r15so5194873lfm.11 for ; Tue, 28 May 2019 06:57:45 -0700 (PDT) In-Reply-To: <87woibq7dj.fsf@nicolasgoaziou.fr> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Nicolas Goaziou Cc: emacs-orgmode@gnu.org * lisp/org-clock.el (org-frame-title-format-backup): Use nil as initial = value. (org-clock-in): set `org-frame-title-format-backup' to = `frame-title-format'. (org-clock-restore-frame-title-format): New function. (org-clock-out): Use it. (org-clock-cancel): Use it. The problem was that the `org-frame-title-format-backup' variable is initialized on org-clock.el loading and future changes to = `frame-title-format' is ignored. TINYCHANGE --- lisp/org-clock.el | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/lisp/org-clock.el b/lisp/org-clock.el index 9a8928a49..12b412f7b 100644 --- a/lisp/org-clock.el +++ b/lisp/org-clock.el @@ -41,7 +41,7 @@ (declare-function org-table-goto-line "org-table" (n)) (declare-function org-dynamic-block-define "org" (type func)) -(defvar org-frame-title-format-backup frame-title-format) +(defvar org-frame-title-format-backup nil) (defvar org-state) (defvar org-link-bracket-re) (defvar org-time-stamp-formats) @@ -1359,6 +1359,7 @@ the default behavior." ;; add to frame title (when (or (eq org-clock-clocked-in-display 'frame-title) (eq org-clock-clocked-in-display 'both)) + (setq org-frame-title-format-backup frame-title-format) (setq frame-title-format org-clock-frame-title-format)) (org-clock-update-mode-line) (when org-clock-mode-line-timer @@ -1549,6 +1550,14 @@ line and position cursor in that line." (org-log-states-order-reversed (goto-char (car (last = positions)))) (t (goto-char (car positions)))))))) +(defun org-clock-restore-frame-title-format () + "Restore `frame-title-format' from `org-frame-title-format-backup'. +`frame-title-format' is restored if `org-frame-title-format-backup' is = not nil +and current `frame-title-format' is equal to = `org-clock-frame-title-format'." + (when (and org-frame-title-format-backup + (equal frame-title-format org-clock-frame-title-format)) + (setq frame-title-format org-frame-title-format-backup))) + ;;;###autoload (defun org-clock-out (&optional switch-to-state fail-quietly at-time) "Stop the currently running clock. @@ -1560,7 +1569,7 @@ to, overriding the existing value of = `org-clock-out-switch-to-state'." (when (not (org-clocking-p)) (setq global-mode-string (delq 'org-mode-line-string global-mode-string)) - (setq frame-title-format org-frame-title-format-backup) + (org-clock-restore-frame-title-format) (force-mode-line-update) (if fail-quietly (throw 'exit t) (user-error "No active clock"))) (let ((org-clock-out-switch-to-state @@ -1618,7 +1627,7 @@ to, overriding the existing value of = `org-clock-out-switch-to-state'." (setq org-clock-idle-timer nil)) (setq global-mode-string (delq 'org-mode-line-string global-mode-string)) - (setq frame-title-format org-frame-title-format-backup) + (org-clock-restore-frame-title-format) (when org-clock-out-switch-to-state (save-excursion (org-back-to-heading t) @@ -1718,7 +1727,7 @@ Optional argument N tells to change by that many = units." (when (not (org-clocking-p)) (setq global-mode-string (delq 'org-mode-line-string global-mode-string)) - (setq frame-title-format org-frame-title-format-backup) + (org-clock-restore-frame-title-format) (force-mode-line-update) (error "No active clock")) (save-excursion ; Do not replace this with `with-current-buffer'. @@ -1734,7 +1743,7 @@ Optional argument N tells to change by that many = units." (move-marker org-clock-hd-marker nil) (setq global-mode-string (delq 'org-mode-line-string global-mode-string)) - (setq frame-title-format org-frame-title-format-backup) + (org-clock-restore-frame-title-format) (force-mode-line-update) (message "Clock canceled") (run-hooks 'org-clock-cancel-hook)) -- 2.15.1