unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: martin rudalics <rudalics@gmx.at>
To: Eli Zaretskii <eliz@gnu.org>
Cc: Karl Fogel <kfogel@red-bean.com>,
	schwab@suse.de, cyd@stupidchicken.com, miles@gnu.org,
	emacs-devel@gnu.org
Subject: Re: [Emacs-diffs] Changes to emacs/lisp/bookmark.el,v
Date: Sun, 23 Nov 2008 20:11:45 +0100	[thread overview]
Message-ID: <4929AAF1.7060109@gmx.at> (raw)
In-Reply-To: <uk5axjodm.fsf@gnu.org>

[-- Attachment #1: Type: text/plain, Size: 833 bytes --]

 > 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

[-- Attachment #2: log-view.diff --]
[-- Type: text/plain, Size: 5866 bytes --]

*** 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	other threads:[~2008-11-23 19:11 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <E1KvFgL-00034A-Gp@cvs.savannah.gnu.org>
2008-11-19  7:50 ` [Emacs-diffs] Changes to emacs/lisp/bookmark.el,v Karl Fogel
2008-11-19 19:17   ` Reviewing changes (was: [Emacs-diffs] Changes to emacs/lisp/bookmark.el, v) Eli Zaretskii
2008-11-19 22:06     ` Reviewing changes Karl Fogel
2008-11-19 22:12       ` Eli Zaretskii
2008-11-19 22:26         ` Thomas Lord
2008-11-20  5:21         ` Karl Fogel
2008-11-20  0:43       ` Stephen J. Turnbull
2008-11-20  6:37         ` Karl Fogel
2008-11-20  8:31           ` Stephen J. Turnbull
2008-11-20  2:13       ` Stefan Monnier
2008-11-20  4:17         ` Eli Zaretskii
2008-11-20  6:22           ` Karl Fogel
2008-11-20 14:30           ` Stefan Monnier
2008-11-20 20:19             ` Eli Zaretskii
2008-11-21  4:01               ` Stefan Monnier
2008-11-21  4:08                 ` mail
2008-11-21 11:28                 ` Eli Zaretskii
2008-11-21 14:32                   ` Stefan Monnier
2008-11-21 15:14                     ` Eli Zaretskii
2008-11-21 19:14                       ` Stefan Monnier
2008-11-20 10:25       ` Yavor Doganov
2008-11-21  4:05         ` Stefan Monnier
2008-11-20  5:39   ` [Emacs-diffs] Changes to emacs/lisp/bookmark.el,v Miles Bader
2008-11-20  9:37     ` Andreas Schwab
2008-11-20 10:09       ` Miles Bader
2008-11-20 20:22         ` Eli Zaretskii
2008-11-20 20:32           ` Juanma Barranquero
2008-11-20 20:44             ` Eli Zaretskii
2008-11-21  5:38           ` Karl Fogel
2008-11-21 11:43             ` Eli Zaretskii
2008-11-23 19:11               ` martin rudalics [this message]
2008-11-24 20:20                 ` Eli Zaretskii
2008-11-25 15:23                   ` Karl Fogel
2008-11-25 16:25                     ` martin rudalics
2008-11-25 16:25                   ` martin rudalics
2008-11-25 21:07                     ` Eli Zaretskii
2008-11-26  2:17                       ` Stephen J. Turnbull
2008-11-27 13:41                       ` martin rudalics
2008-11-27 16:35                         ` Stefan Monnier
2008-11-25 21:44                     ` Stefan Monnier
2008-11-21 19:29   ` Stefan Monnier
     [not found] <E1L2i1k-0000XC-CX@cvs.savannah.gnu.org>
     [not found] ` <f7ccd24b0811191458o3e2ad7d3v2370385de7dbb748@mail.gmail.com>
     [not found]   ` <87bpwbdkza.fsf@red-bean.com>
     [not found]     ` <f7ccd24b0811200035p91e01d3ideef573f393eb71c@mail.gmail.com>
2008-11-21  5:30       ` Karl Fogel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4929AAF1.7060109@gmx.at \
    --to=rudalics@gmx.at \
    --cc=cyd@stupidchicken.com \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=kfogel@red-bean.com \
    --cc=miles@gnu.org \
    --cc=schwab@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).