X-Git-Url: https://cgit.sxemacs.org/?p=riece;a=blobdiff_plain;f=lisp%2Friece-log.el;h=00b2f658cbea409f872937bccd631ac82029d385;hp=3289a07998ad1a5f17f64e5daa3d16037e20689a;hb=9b9378f2c6bd1babb33348279af5a31d67621466;hpb=4cc66f8d5b60ad2f889baebc5edc2c5a65a00d3f diff --git a/lisp/riece-log.el b/lisp/riece-log.el index 3289a07..00b2f65 100644 --- a/lisp/riece-log.el +++ b/lisp/riece-log.el @@ -89,6 +89,10 @@ If integer, flash back only this line numbers. t means all lines." :group 'riece-highlight-faces) (defvar riece-log-date-face 'riece-log-date-face) +(defvar riece-log-lock-file nil + "Lock file for riece-log. +It is created if there is at least one instance of Emacs running riece-log.") + (defvar riece-log-enabled nil) (defconst riece-log-description @@ -104,7 +108,8 @@ If integer, flash back only this line numbers. t means all lines." (make-directory (file-name-directory file) t)) (write-region (concat (format-time-string "%H:%M") " " (riece-format-message message)) - nil file t 0)))) + nil file t 0 + riece-log-lock-file)))) (defun riece-log-get-file (identity) (expand-file-name @@ -125,10 +130,9 @@ If integer, flash back only this line numbers. t means all lines." (let ((prefix (riece-identity-canonicalize-prefix (riece-identity-prefix identity))) (server (riece-identity-server identity)) - (map (assoc (riece-format-identity identity) riece-log-directory-map)) - name) + (map (assoc (riece-format-identity identity) riece-log-directory-map))) (if map - (setq name (cdr map)) + (expand-file-name (cdr map) riece-log-directory) (expand-file-name (riece-log-encode-file-name prefix) (expand-file-name (concat "." (riece-log-encode-file-name server)) @@ -172,12 +176,16 @@ If integer, flash back only this line numbers. t means all lines." "Insert logs for IDENTITY at most LINES. If LINES is t, insert today's logs entirely." (if (eq lines t) - (let ((file (riece-log-get-file identity))) + (let* (file-name-coding-system + default-file-name-coding-system + (file (riece-log-get-file identity))) (if (file-exists-p file) (insert-file-contents file))) - (let ((files (riece-log-get-files identity)) - (lines (- lines)) - name date point) + (let* (file-name-coding-system + default-file-name-coding-system + (files (riece-log-get-files identity)) + (lines (- lines)) + name date point) (while (and (< lines 0) files) (if (and (file-exists-p (car files)) (string-match (concat (riece-make-interval-regexp "[0-9]" 8) @@ -218,11 +226,14 @@ If LINES is t, insert today's logs entirely." (buffer-string))) (goto-char point) (while (re-search-forward - "^[0-9][0-9]:[0-9][0-9] [<>]\\([^<>]+\\)[<>] " nil t) - (put-text-property (match-beginning 1) (match-end 1) + (concat "^" riece-time-prefix-regexp + "\\(<[^>]+>\\|>[^<]+<\\|([^)]+)\\|{[^}]+}\\|=[^=]+=\\)") + nil t) + (put-text-property (1+ (match-beginning 1)) (1- (match-end 1)) 'riece-identity (riece-make-identity - (riece-match-string-no-properties 1) + (buffer-substring (1+ (match-beginning 1)) + (1- (match-end 1))) (riece-identity-server identity)))) (run-hook-with-args 'riece-after-insert-functions point (goto-char (point-max))) @@ -242,6 +253,13 @@ If LINES is t, insert today's logs entirely." '(riece-button))) (defun riece-log-insinuate () + (make-directory riece-log-directory t) + (setq riece-log-lock-file + (expand-file-name (format "!%d-%s-%d" + (user-uid) + (riece-log-encode-file-name (system-name)) + (emacs-pid)) + riece-log-directory)) ;; 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