GNU bug report logs - #7158
24.0.50; Incorrect handling of variable 'display-time-mail-function'

Previous Next

Package: emacs;

Reported by: Detlev Zundel <dzu <at> denx.de>

Date: Mon, 4 Oct 2010 16:30:03 UTC

Severity: minor

Tags: fixed, patch

Found in version 24.0.50

Fixed in version 24.1

Done: Lars Magne Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 7158 in the body.
You can then email your comments to 7158 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#7158; Package emacs. (Mon, 04 Oct 2010 16:30:03 GMT) Full text and rfc822 format available.

Acknowledgement sent to Detlev Zundel <dzu <at> denx.de>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Mon, 04 Oct 2010 16:30:03 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Detlev Zundel <dzu <at> denx.de>
To: bug-gnu-emacs <at> gnu.org
Subject: 24.0.50; Incorrect handling of variable 'display-time-mail-function'
Date: Mon, 04 Oct 2010 17:20:55 +0200
[Message part 1 (text/plain, inline)]
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

[time.el.patch (text/x-diff, inline)]
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))))

Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#7158; Package emacs. (Tue, 05 Oct 2010 08:16:01 GMT) Full text and rfc822 format available.

Message #8 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Detlev Zundel <dzu <at> denx.de>
To: bug-gnu-emacs <at> gnu.org
Subject: Re: 24.0.50;
	Incorrect handling of variable 'display-time-mail-function'
Date: Tue, 05 Oct 2010 10:18:30 +0200
[Message part 1 (text/plain, inline)]
Detlev Zundel <dzu <at> 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)
[time.el-2.patch (text/x-diff, inline)]
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))))

Added tag(s) patch. Request was from Lars Magne Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Thu, 14 Jul 2011 14:27:01 GMT) Full text and rfc822 format available.

Added tag(s) fixed. Request was from Lars Magne Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Thu, 14 Jul 2011 14:32:03 GMT) Full text and rfc822 format available.

bug marked as fixed in version 24.1, send any further explanations to 7158 <at> debbugs.gnu.org and Detlev Zundel <dzu <at> denx.de> Request was from Lars Magne Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Thu, 14 Jul 2011 14:32:03 GMT) Full text and rfc822 format available.

Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#7158; Package emacs. (Thu, 14 Jul 2011 14:33:03 GMT) Full text and rfc822 format available.

Message #17 received at 7158 <at> debbugs.gnu.org (full text, mbox):

From: Lars Magne Ingebrigtsen <larsi <at> gnus.org>
To: Detlev Zundel <dzu <at> denx.de>
Cc: 7158 <at> debbugs.gnu.org
Subject: Re: 24.0.50;
	Incorrect handling of variable 'display-time-mail-function'
Date: Thu, 14 Jul 2011 16:31:23 +0200
Detlev Zundel <dzu <at> 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/




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Fri, 12 Aug 2011 11:24:06 GMT) Full text and rfc822 format available.

This bug report was last modified 12 years and 283 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.