X-Git-Url: https://cgit.sxemacs.org/?p=riece;a=blobdiff_plain;f=lisp%2Friece-log.el;h=dd997e6386ffdc67220cf822e31e04c935ab3706;hp=caa1e9cf1221ceaba4017af49d96a47be254f115;hb=4fce7363d6da9b827c5bce98540c4f4756f93f91;hpb=72c9efc77044504c7a2ffbb7f34a6c2f2f263130 diff --git a/lisp/riece-log.el b/lisp/riece-log.el index caa1e9c..dd997e6 100644 --- a/lisp/riece-log.el +++ b/lisp/riece-log.el @@ -30,7 +30,8 @@ ;;; Code: -(eval-when-compile (require 'riece-message)) +(eval-when-compile (require 'riece-message) + (require 'riece-button)) (defgroup riece-log nil "Save irc log" @@ -60,6 +61,11 @@ If integer, flash back only this line numbers. t means all lines." :type 'symbol :group 'riece-log) +(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) (let ((open-bracket (funcall riece-message-make-open-bracket-function message)) @@ -82,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) @@ -113,23 +120,42 @@ If integer, flash back only this line numbers. t means all lines." (let (buffer-read-only) (goto-char (point-max)) (insert string) + (goto-char (point-min)) + (while (re-search-forward + "^[0-9][0-9]:[0-9][0-9] [<>]\\([^<>]+\\)[<>] " nil t) + (put-text-property (match-beginning 1) (match-end 1) + 'riece-identity + (riece-make-identity + (riece-match-string-no-properties 1) + (riece-identity-server identity)))) + (if (memq 'riece-button riece-addons) + (riece-button-update-buffer)) (goto-char (point-max)) (set-window-point (get-buffer-window (current-buffer)) (point)))))))) (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)