* gnus-util.el (gnus-frame-or-window-display-name): Exclude invalid display
[gnus] / lisp / gnus-util.el
index 6b8e96e..dddac92 100644 (file)
@@ -1287,6 +1287,21 @@ CHOICE is a list of the choice char and help message at IDX."
         (when focus-follows-mouse
           (set-mouse-position frame (1- (frame-width frame)) 0)))))
 
+(defun gnus-frame-or-window-display-name (object)
+  "Given a frame or window, return the associated display name.
+Return nil otherwise."
+  (if (featurep 'xemacs)
+      (device-connection (dfw-device object))
+    (if (or (framep object)
+           (and (windowp object)
+                (setq object (window-frame object))))
+       (let ((display (frame-parameter object 'display)))
+         (if (and (stringp display)
+                  ;; Exclude invalid display names.
+                  (string-match "\\`[^:]*:[0-9]+\\(\\.[0-9]+\\)?\\'"
+                                display))
+             display)))))
+
 (provide 'gnus-util)
 
 ;;; gnus-util.el ends here