*** log-view.el.~1.55.~ 2008-06-16 11:28:44.000000000 +0200 --- log-view.el 2008-11-23 20:06:16.218750000 +0100 *************** *** 137,142 **** --- 137,145 ---- ([backtab] . log-view-msg-prev) ("N" . log-view-file-next) ("P" . log-view-file-prev) + ("o" . log-view-show-object-only) + ("c" . log-view-show-current-only) + ("y" . log-view-show-any) ("\M-n" . log-view-file-next) ("\M-p" . log-view-file-prev)) "Log-View's keymap." *************** *** 171,177 **** ["Next File" log-view-file-next :help "Go to the next count'th file"] ["Previous File" log-view-file-prev ! :help "Go to the previous count'th file"])) (defvar log-view-mode-hook nil "Hook run at the end of `log-view-mode'.") --- 174,187 ---- ["Next File" log-view-file-next :help "Go to the next count'th file"] ["Previous File" log-view-file-prev ! :help "Go to the previous count'th file"] ! "-----" ! ["Show Object Only" log-view-show-object-only ! :help "Show entries for object at point only"] ! ["Show Current Only" log-view-show-current-only ! :help "Show entries for current file only"] ! ["Show Any" log-view-show-any ! :help "Show any entry"])) (defvar log-view-mode-hook nil "Hook run at the end of `log-view-mode'.") *************** *** 532,537 **** --- 542,673 ---- (list log-view-vc-backend nil) to fr))) + + (defun log-view-hide (from to) + "Hide text within FROM and TO." + (when (< from to) + (put-text-property from to 'invisible t))) + + (defun log-view-show-any () + "Show any entry. + Show any entry hidden by a previous `log-view-show-object-only' + or `log-view-show-current-only' command." + (interactive) + (let ((inhibit-read-only t)) + (remove-text-properties (point-min) (point-max) '(invisible nil)))) + + (defun log-view-object-at-point () + "Return name of object at point. + The object at point must be a name preceded by a left paren or a + comma and followed by a right paren or a comma." + (save-excursion + (save-restriction + (narrow-to-region (line-beginning-position) (line-end-position)) + (let ((from (save-excursion + (when (re-search-backward ",[ ]+\\|(" nil t) + (match-end 0)))) + (to (save-excursion + (when (re-search-forward ",\\|)" nil t) + (match-beginning 0))))) + (when (and from to) + (buffer-substring-no-properties from to)))))) + + (defun log-view-show-object-only () + "Show log entries for object at point only." + (interactive) + (let* ((name (log-view-object-at-point)) + (name-rq (when name (regexp-quote name))) + (inhibit-read-only t) + from to) + (unless name + (error "No fun round point")) + ;; Avoid to get the same object for another file. + (log-view-show-current-only) + (save-excursion + (save-restriction + (widen) + (goto-char (point-min)) + (setq from (when (re-search-forward log-view-message-re nil t) + (line-beginning-position))) + (while (< from (point-max)) + (setq to (if (re-search-forward log-view-message-re nil t) + (line-beginning-position) + (point-max))) + (save-excursion + (goto-char from) + (unless (and (re-search-forward name-rq to t) + (string-equal name (log-view-object-at-point))) + (log-view-hide from to))) + (setq from to) + (goto-char to) + (forward-line)))))) + + (defconst log-view-show-entry-re "^[ \t\n]*\\*[ \t]+") + + (defun log-view-show-current-only () + "Show log entries for current file only." + (interactive) + (log-view-show-any) + (let* ((name (file-name-nondirectory (log-view-current-file))) + (name-rq (when name (regexp-quote name))) + (name-re + (when name (concat ".*" name-rq))) + (log-view-show-entry-and-name-re + (when name + (concat log-view-show-entry-re ".*" name-rq))) + (inhibit-read-only t) + from to) + (unless name + (error "Couldn't find file name")) + (save-excursion + (save-restriction + (widen) + (goto-char (point-min)) + (while (< (setq from + (if (re-search-forward log-view-message-re nil 'move) + (line-beginning-position 2) + (point-max))) + (point-max)) + (setq to (if (re-search-forward log-view-message-re nil t) + (line-beginning-position 0) + (point-max))) + (goto-char from) + (let ((before-from (line-beginning-position)) + before-to after-from within-from within-to) + (while (re-search-forward log-view-show-entry-re to t) + (if (looking-at name-re) + ;; Relevant entry. + (setq before-to before-from) + ;; Irrelevant entry. + (setq before-to + (if (re-search-forward + log-view-show-entry-and-name-re to 'move) + (line-beginning-position) + to))) + (log-view-hide before-from before-to) + (setq after-from + (if (re-search-forward log-view-show-entry-re to 'move) + (line-beginning-position) + to)) + (when (< before-to after-from) + (goto-char before-to) + ;; Handle the special case where a common ChangeLog text + ;; is written for entries from different files. + (when (and (re-search-forward ":[ \t\n]+" after-from t) + (setq within-from (match-beginning 0)) + (looking-at log-view-show-entry-re) + (re-search-forward ":[ \t\n]+[^*]" to t) + (setq within-to (match-beginning 0))) + (log-view-hide within-from within-to) + (setq after-from + (if (re-search-forward log-view-show-entry-re to 'move) + (line-beginning-position) + to)))) + (goto-char (setq before-from after-from))) + (when after-from + (log-view-hide after-from to))) + (goto-char to)))))) + (provide 'log-view) ;; arch-tag: 0d64220b-ce7e-4f62-9c2a-6b04c2f81f4f