unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#7158: 24.0.50; Incorrect handling of variable 'display-time-mail-function'
@ 2010-10-04 15:20 Detlev Zundel
  2010-10-05  8:18 ` Detlev Zundel
  0 siblings, 1 reply; 3+ messages in thread
From: Detlev Zundel @ 2010-10-04 15:20 UTC (permalink / raw)
  To: 7158

[-- Attachment #1: Type: text/plain, Size: 2432 bytes --]

As I understand the documentation, the variable
'display-time-mail-function' should allow to provide a function which
decides whether to display the mail icon in the status area.

Unfortunately the code does not allow this semantic, as the code uses an
or expression over several possibilities (lisp/time.el:407):

        (mail (or (and display-time-mail-function
                       (funcall display-time-mail-function))
                  (and display-time-mail-directory
                       (display-time-mail-check-directory))
                  (and (stringp mail-spool-file)
                       (or (null display-time-server-down-time)
                           ;; If have been down for 20 min, try again.
                           (> (- (nth 1 now) display-time-server-down-time)
                              1200)
                           (and (< (nth 1 now) display-time-server-down-time)
                                (> (- (nth 1 now)
                                      display-time-server-down-time)
                                   -64336)))
                       (let ((start-time (current-time)))
                         (prog1
                             (display-time-file-nonempty-p mail-spool-file)
                           (if (> (- (nth 1 (current-time))
                                     (nth 1 start-time))
                                  20)
                               ;; Record that mail file is not accessible.
                               (setq display-time-server-down-time
                                     (nth 1 (current-time)))
                             ;; Record that mail file is accessible.
                             (setq display-time-server-down-time nil)))))))


So when display-time-mail-function is set but returns nil, then the
following tests will still be evaluated instead of using this negative
result.

As a fix I propose the attached patch.

Thanks
  Detlev


In GNU Emacs 24.0.50.1 (i686-pc-linux-gnu, GTK+ Version 2.18.9)
 of 2010-08-16 on ohwell
Windowing system distributor `The X.Org Foundation', version 11.0.10707000


-- 
... and I will continue to use a  low-level language to indicate how
machines actually compute.  Readers  who only want to see algorithms
that are already packaged in a plug-in way, using a trendy language,
should buy other people's books.
                                         -- Donald Knuth, Fascicle 1


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: time.el.patch --]
[-- Type: text/x-diff, Size: 2413 bytes --]

diff --git a/lisp/time.el b/lisp/time.el
index d512fae..80bb176 100644
--- a/lisp/time.el
+++ b/lisp/time.el
@@ -404,30 +404,31 @@ update which can wait for the next redisplay."
                               (getenv "MAIL")
                               (concat rmail-spool-directory
                                       (user-login-name))))
-	 (mail (or (and display-time-mail-function
-			(funcall display-time-mail-function))
-		   (and display-time-mail-directory
-			(display-time-mail-check-directory))
-		   (and (stringp mail-spool-file)
-			(or (null display-time-server-down-time)
-			    ;; If have been down for 20 min, try again.
-			    (> (- (nth 1 now) display-time-server-down-time)
-			       1200)
-			    (and (< (nth 1 now) display-time-server-down-time)
-				 (> (- (nth 1 now)
-				       display-time-server-down-time)
-				    -64336)))
-			(let ((start-time (current-time)))
-			  (prog1
-			      (display-time-file-nonempty-p mail-spool-file)
-			    (if (> (- (nth 1 (current-time))
-				      (nth 1 start-time))
-				   20)
-				;; Record that mail file is not accessible.
-				(setq display-time-server-down-time
-				      (nth 1 (current-time)))
-			      ;; Record that mail file is accessible.
-			      (setq display-time-server-down-time nil)))))))
+	 (mail (cond (display-time-mail-function
+		      (funcall display-time-mail-function))
+		     (display-time-mail-directory
+		      (display-time-mail-check-directory))
+		     ((stringp mail-spool-fail)
+		      (and
+		       (or (null display-time-server-down-time)
+			   ;; If have been down for 20 min, try again.
+			   (> (- (nth 1 now) display-time-server-down-time)
+			      1200)
+			   (and (< (nth 1 now) display-time-server-down-time)
+				(> (- (nth 1 now)
+				      display-time-server-down-time)
+				   -64336)))
+		       (let ((start-time (current-time)))
+			 (prog1
+			     (display-time-file-nonempty-p mail-spool-file)
+			   (if (> (- (nth 1 (current-time))
+				     (nth 1 start-time))
+				  20)
+			       ;; Record that mail file is not accessible.
+			       (setq display-time-server-down-time
+				     (nth 1 (current-time)))
+			     ;; Record that mail file is accessible.
+			     (setq display-time-server-down-time nil)))))))
          (24-hours (substring time 11 13))
          (hour (string-to-number 24-hours))
          (12-hours (int-to-string (1+ (% (+ hour 11) 12))))

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* bug#7158: 24.0.50; Incorrect handling of variable 'display-time-mail-function'
  2010-10-04 15:20 bug#7158: 24.0.50; Incorrect handling of variable 'display-time-mail-function' Detlev Zundel
@ 2010-10-05  8:18 ` Detlev Zundel
  2011-07-14 14:31   ` Lars Magne Ingebrigtsen
  0 siblings, 1 reply; 3+ messages in thread
From: Detlev Zundel @ 2010-10-05  8:18 UTC (permalink / raw)
  To: bug-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 2467 bytes --]

Detlev Zundel <dzu@denx.de> writes:

> As I understand the documentation, the variable
> 'display-time-mail-function' should allow to provide a function which
> decides whether to display the mail icon in the status area.
>
> Unfortunately the code does not allow this semantic, as the code uses an
> or expression over several possibilities (lisp/time.el:407):
>
>         (mail (or (and display-time-mail-function
>                        (funcall display-time-mail-function))
>                   (and display-time-mail-directory
>                        (display-time-mail-check-directory))
>                   (and (stringp mail-spool-file)
>                        (or (null display-time-server-down-time)
>                            ;; If have been down for 20 min, try again.
>                            (> (- (nth 1 now) display-time-server-down-time)
>                               1200)
>                            (and (< (nth 1 now) display-time-server-down-time)
>                                 (> (- (nth 1 now)
>                                       display-time-server-down-time)
>                                    -64336)))
>                        (let ((start-time (current-time)))
>                          (prog1
>                              (display-time-file-nonempty-p mail-spool-file)
>                            (if (> (- (nth 1 (current-time))
>                                      (nth 1 start-time))
>                                   20)
>                                ;; Record that mail file is not accessible.
>                                (setq display-time-server-down-time
>                                      (nth 1 (current-time)))
>                              ;; Record that mail file is accessible.
>                              (setq display-time-server-down-time nil)))))))
>
>
> So when display-time-mail-function is set but returns nil, then the
> following tests will still be evaluated instead of using this negative
> result.
>
> As a fix I propose the attached patch.

This patch is actually erroneous - it has a missing closing parenthesis
and an unrelated typeo.  The attached patch is tested.  Sorry for the
inconvenience.

Cheers
  Detlev

-- 
Ftpd never switches uid and euid, it uses setfsuid(2) instead. The
main reason is that uid switching has been exploited in several
breakins, but the sheer ugliness of uid switching counts too.
                                     -- pure-ftpd(8)

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: time.el-2.patch --]
[-- Type: text/x-diff, Size: 2414 bytes --]

diff --git a/lisp/time.el b/lisp/time.el
index d512fae..2f8eda7 100644
--- a/lisp/time.el
+++ b/lisp/time.el
@@ -404,30 +404,31 @@ update which can wait for the next redisplay."
                               (getenv "MAIL")
                               (concat rmail-spool-directory
                                       (user-login-name))))
-	 (mail (or (and display-time-mail-function
-			(funcall display-time-mail-function))
-		   (and display-time-mail-directory
-			(display-time-mail-check-directory))
-		   (and (stringp mail-spool-file)
-			(or (null display-time-server-down-time)
-			    ;; If have been down for 20 min, try again.
-			    (> (- (nth 1 now) display-time-server-down-time)
-			       1200)
-			    (and (< (nth 1 now) display-time-server-down-time)
-				 (> (- (nth 1 now)
-				       display-time-server-down-time)
-				    -64336)))
-			(let ((start-time (current-time)))
-			  (prog1
-			      (display-time-file-nonempty-p mail-spool-file)
-			    (if (> (- (nth 1 (current-time))
-				      (nth 1 start-time))
-				   20)
-				;; Record that mail file is not accessible.
-				(setq display-time-server-down-time
-				      (nth 1 (current-time)))
-			      ;; Record that mail file is accessible.
-			      (setq display-time-server-down-time nil)))))))
+	 (mail (cond (display-time-mail-function
+		      (funcall display-time-mail-function))
+		     (display-time-mail-directory
+		      (display-time-mail-check-directory))
+		     ((stringp mail-spool-file)
+		      (and
+		       (or (null display-time-server-down-time)
+			   ;; If have been down for 20 min, try again.
+			   (> (- (nth 1 now) display-time-server-down-time)
+			      1200)
+			   (and (< (nth 1 now) display-time-server-down-time)
+				(> (- (nth 1 now)
+				      display-time-server-down-time)
+				   -64336)))
+		       (let ((start-time (current-time)))
+			 (prog1
+			     (display-time-file-nonempty-p mail-spool-file)
+			   (if (> (- (nth 1 (current-time))
+				     (nth 1 start-time))
+				  20)
+			       ;; Record that mail file is not accessible.
+			       (setq display-time-server-down-time
+				     (nth 1 (current-time)))
+			     ;; Record that mail file is accessible.
+			     (setq display-time-server-down-time nil))))))))
          (24-hours (substring time 11 13))
          (hour (string-to-number 24-hours))
          (12-hours (int-to-string (1+ (% (+ hour 11) 12))))

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* bug#7158: 24.0.50; Incorrect handling of variable 'display-time-mail-function'
  2010-10-05  8:18 ` Detlev Zundel
@ 2011-07-14 14:31   ` Lars Magne Ingebrigtsen
  0 siblings, 0 replies; 3+ messages in thread
From: Lars Magne Ingebrigtsen @ 2011-07-14 14:31 UTC (permalink / raw)
  To: Detlev Zundel; +Cc: 7158

Detlev Zundel <dzu@denx.de> writes:

> This patch is actually erroneous - it has a missing closing parenthesis
> and an unrelated typeo.  The attached patch is tested.  Sorry for the
> inconvenience.

Thanks; I've now applied a fix along the lines in the patch to Emacs 24.

-- 
(domestic pets only, the antidote for overdose, milk.)
  bloggy blog http://lars.ingebrigtsen.no/





^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-07-14 14:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-10-04 15:20 bug#7158: 24.0.50; Incorrect handling of variable 'display-time-mail-function' Detlev Zundel
2010-10-05  8:18 ` Detlev Zundel
2011-07-14 14:31   ` Lars Magne Ingebrigtsen

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).