* riece-log.el (riece-log-get-directory): Follow the name change
[riece] / lisp / riece-log.el
index 66aa3bd..dd997e6 100644 (file)
@@ -61,9 +61,9 @@ If integer, flash back only this line numbers. t means all lines."
   :type 'symbol
   :group 'riece-log)
 
-(defcustom riece-log-file-name-coding-system file-name-coding-system
-  "*Coding system used to convert pathnames of log files."
-  :type 'symbol
+(defcustom riece-log-open-directory-function 'find-file
+  "*Function for opening a directory."
+  :type 'function
   :group 'riece-log)
 
 (defun riece-log-display-message-function (message)
@@ -74,8 +74,7 @@ If integer, flash back only this line numbers. t means all lines."
        (name
         (funcall riece-message-make-name-function message))
        (file (riece-log-get-file (riece-message-target message)))
-       (coding-system-for-write riece-log-coding-system)
-       (file-name-coding-system riece-log-file-name-coding-system))
+       (coding-system-for-write riece-log-coding-system))
     (unless (file-directory-p (file-name-directory file))
       (make-directory (file-name-directory file) t))
     (write-region (concat (format-time-string "%H:%M") " "
@@ -89,12 +88,13 @@ If integer, flash back only this line numbers. t means all lines."
    (riece-log-get-directory identity)))
 
 (defun riece-log-get-directory (identity)
-  (let ((channel (riece-identity-prefix identity))
+  (let ((channel (riece-identity-canonicalize-prefix
+                 (riece-identity-prefix identity)))
        (server (riece-identity-server identity))
        (map (assoc (riece-format-identity identity) riece-log-directory-map))
        name)
     (cond (map (setq name (cdr map)))
-         ((string-match riece-channel-regexp channel)
+         ((string-match riece-strict-channel-regexp channel)
           (let ((suffix (match-string 2 channel)))
             (setq name (substring channel (match-end 1) (match-beginning 2)))
             (when (and (stringp suffix)
@@ -107,8 +107,7 @@ If integer, flash back only this line numbers. t means all lines."
 
 (defun riece-log-flashback (identity)
   (when riece-log-flashback
-    (let ((file (riece-log-get-file identity))
-         (file-name-coding-system riece-log-file-name-coding-system))
+    (let ((file (riece-log-get-file identity)))
       (when (file-exists-p file)
        (let (string)
          (with-temp-buffer
@@ -137,21 +136,26 @@ If integer, flash back only this line numbers. t means all lines."
 
 (defun riece-log-open-directory (&optional channel)
   (interactive)
-  (if channel
-      (find-file (riece-log-get-directory channel))
-    (find-file riece-log-directory)))
+  (let ((directory (riece-log-get-directory
+                   (or channel riece-current-channel))))
+    (if (file-directory-p directory)
+       (funcall riece-log-open-directory-function directory)
+      (error "No log directory"))))
 
 (defun riece-log-requires ()
   (if (memq 'riece-button riece-addons)
       '(riece-button)))
 
+(defvar riece-command-mode-map)
 (defun riece-log-insinuate ()
   ;; FIXME: Use `riece-after-insert-functions' for trapping change,
   ;; notice, wallops and so on. But must add argument.
   (add-hook 'riece-after-display-message-functions
            'riece-log-display-message-function)
   (add-hook 'riece-channel-buffer-create-functions
-           'riece-log-flashback))
+           'riece-log-flashback)
+  (define-key riece-command-mode-map
+    "\C-cd" 'riece-log-open-directory))
 
 (provide 'riece-log)