emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Emacs-diffs] Changes to emacs/lisp/bookmark.el,v


From: martin rudalics
Subject: Re: [Emacs-diffs] Changes to emacs/lisp/bookmark.el,v
Date: Sun, 23 Nov 2008 20:11:45 +0100
User-agent: Thunderbird 2.0.0.16 (Windows/20080708)

> That's the whole point: if several files are committed in one go, the
> log message for each file will be usually taken from several ChangeLog
> entries, sometimes from several different directories (e.g., if C
> files and Lisp files are modified together, or if the documentation is
> changed as well).  Then "cvs log FILENAME" will show a huge pile of
> different entries for each FILENAME in the changeset.  What I want is
> an option to "cvs log" that will show only the entries of the one file
> I'm interested in.  CVS doesn't record that information, so I'm down
> to grepping "cvs log" output, which is unreliable because I don't
> always know what I'm looking for, and because of inconsistencies in
> how the ChangeLog entries are formatted.

How about something in the direction of the attached patch?

martin
*** 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

reply via email to

[Prev in Thread] Current Thread [Next in Thread]