Don't install gnu-emacs-user-config.
[elisp/liece.git] / lisp / liece-misc.el
index 4820e9a..d69f011 100644 (file)
@@ -30,8 +30,6 @@
 ;;; Code:
 
 (eval-and-compile
-  (require 'broken)
-  (require 'pccl)
   (require 'invisible)
   (require 'liece-inlines)
   (require 'liece-coding))
         (concat "[" ,hostname "]")
        ,hostname)))
 
-(defmacro liece-current-nickname ()
-  "Our current nickname."
-  'liece-real-nickname)
+(defun liece-current-nickname ()
+  "Return the current nickname."
+  liece-real-nickname)
 
-(defmacro liece-current-channel ()
-  "Out current channel."
-  'liece-current-channel)
+(defun liece-current-channel ()
+  "Return the current channel."
+  liece-current-channel)
 
-(defmacro liece-current-channels ()
-  "Out current channels."
-  'liece-current-channels)
+(defun liece-current-channels ()
+  "Return the current channels."
+  liece-current-channels)
 
-(defmacro liece-current-chat-partner ()
-  "Out current chat partner."
-  'liece-current-chat-partner)
+(defun liece-current-chat-partner ()
+  "Return the current chat partner."
+  liece-current-chat-partner)
 
-(defmacro liece-current-chat-partners ()
-  "Out current chat partners."
-  'liece-current-chat-partners)
+(defun liece-current-chat-partners ()
+  "Return the current chat partners."
+  liece-current-chat-partners)
 
 (defmacro liece-scroll-if-visible (window)
   `(if ,window (set-window-point ,window (point-max))))
               (setq who (cdr who)))))))
      found))
 
-(defmacro liece-time-difference (t0 t1)
-  "Difference in seconds between T0 and T1.
-Both T0 and T1 are in the encoded time format."
-  `(abs (+ (* (- (car ,t1) (car ,t0)) 65536)
-          (- (cadr ,t1)) (cadr ,t0))))
-
-(defmacro liece-time-add (t0 t1)
-  "Add T0 seconds to time T1.
-t0 is in `three integer lists'-format  returned by `current-time' function."
-  `(list (+ (car ,t0) (/ (+ (cadr ,t0) ,t1) 65536))
-        (% (+ (cadr ,t0) ,t1) 65536)
-        0))
-
+;;; stolen (and renamed) from time-date.el.
+(defun liece-subtract-time (t1 t2)
+  "Subtract two internal times."
+  (let ((borrow (< (cadr t1) (cadr t2))))
+    (list (- (car t1) (car t2) (if borrow 1 0))
+         (- (+ (if borrow 65536 0) (cadr t1)) (cadr t2)))))
+
+(defun liece-time-difference (t1 t2)
+  "Return the differnce between two internal times in seconds."
+  (let ((sub (liece-subtract-time t1 t2)))
+    (+ (* (car sub) 65536) (cadr sub))))
+
+(defun liece-time-elapsed (time seconds)
+  "Add SECONDS to TIME."
+  (list (+ (car time) (/ (+ (cadr time) seconds) 65536))
+       (% (+ (cadr time) seconds) 65536)
+       (nth 2 time)))
+
+;;; stolen (and renamed) from time-date.el.
 (defun liece-seconds-to-time (seconds)
   "Convert SECONDS (a floating point number) to an Emacs time structure."
   (list (floor seconds 65536)
        (floor (mod seconds 65536))
        (floor (* (- seconds (ffloor seconds)) 1000000))))
 
-(defmacro liece-generate-hex-timestamp (&optional time)
+(defun liece-generate-hex-timestamp (&optional time)
   "Generate timestamp string as hexadecimal.
 If optional argument TIME is nil, calculate timestamp using current time."
-  `(let ((time (or ,time (current-time))))
-     (format "%04x%04x" (car time) (cadr time))))
+  (or time
+      (setq time (current-time)))
+  (format "%04x%04x" (car time) (cadr time)))
 
 (defmacro liece-hex-timestamp-valid (timestamp limit)
   "Is TIMESTAMP valid within LIMIT?"