-(or (fboundp 'dired-other-frame)
- (defun dired-other-frame (dirname &optional switches)
- "\"Edit\" directory DIRNAME. Like `dired' but makes a new frame."
- (interactive (dired-read-dir-and-switches "in other frame "))
- (switch-to-buffer-other-frame (dired-noselect dirname switches)))
- )
+(condition-case nil
+ (require 'timer)
+ (error
+ (require 'itimer)
+ (defun-maybe run-at-time (time repeat function &rest args)
+ (start-itimer (make-temp-name "rat")
+ `(lambda ()
+ (,function ,@args))
+ time repeat))
+ (defalias 'cancel-timer 'delete-itimer)
+ (defun with-timeout-handler (tag)
+ (throw tag 'timeout))
+ (defmacro-maybe with-timeout (list &rest body)
+ (let ((seconds (car list))
+ (timeout-forms (cdr list)))
+ `(let ((with-timeout-tag (cons nil nil))
+ with-timeout-value with-timeout-timer)
+ (if (catch with-timeout-tag
+ (progn
+ (setq with-timeout-timer
+ (run-at-time ,seconds nil
+ 'with-timeout-handler
+ with-timeout-tag))
+ (setq with-timeout-value (progn . ,body))
+ nil))
+ (progn . ,timeout-forms)
+ (cancel-timer with-timeout-timer)
+ with-timeout-value))))))