emacs-devel
[Top][All Lists]
Advanced

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

Re: limit the number of log entries displayed by C-x v l


From: Bob Rogers
Subject: Re: limit the number of log entries displayed by C-x v l
Date: Sun, 22 Nov 2009 22:49:20 -0500

   From: Stefan Monnier <address@hidden>
   Date: Sun, 22 Nov 2009 21:29:15 -0500

   >> They can't even do "log+diff", and some of the main contributors have
   >> already seen this suggestion back when I asked for it for Arch.
   >> Nobody's ever seemed to understand how useful it would be.

   > Bzr does have `log -p' (as does Git and Hg of course), which shows the
   > log and diff at the same time.

   Thanks for proving me wrong. ;-)
   So maybe there is hope for the feature of which I've been dreaming.

           Stefan

Here's a non-backend-specific hack for C-n and C-p in vc-annotate-mode
that keeps any log-view-mode buffer displayed on the same frame in sync
to the same revision.  A post-command-hook solution might be more
thorough, though (handling C-s, e.g.), but is this in the direction of
what you had in mind?

                                        -- Bob Rogers
                                           http://www.rgrjr.com/

------------------------------------------------------------------------
(defun vc-annotate-find-visible-log-buffer-window
       (file &optional start-window last-window)
  ;; Look for a window on the current frame that contains a
  ;; log-view-mode buffer that is looking at file.
  (or start-window (setq start-window (selected-window)
                         last-window start-window))
  (let ((window (next-window last-window)))
    (if (not (eq window start-window))
        ;; See if window contains a log buffer.
        (or (save-excursion
              (set-buffer (window-buffer window))
              (and (eq major-mode 'log-view-mode)
                   (condition-case ()
                       ;; This shouldn't fail in a log-view-mode
                       ;; buffer, but just in case.
                       (equal (log-view-current-file) file)
                     (error nil))
                   window))
            (vc-annotate-find-visible-log-buffer-window file start-window
                                                        window)))))

(defun vc-annotate-next-line (&optional arg)
  "Next line in an annotation buffer, keeping any visible log in sync."
  (interactive "^p")
  (line-move-1 (or arg 1))
  (if (not (equal major-mode 'vc-annotate-mode))
      (error "Cannot be invoked outside of a vc annotate buffer."))
  (let* ((backend vc-annotate-backend)
         (rev-at-line (vc-annotate-extract-revision-at-line))
         (revision (car rev-at-line))
         (file (cdr rev-at-line))
         (log-buffer-window
           (and rev-at-line
                (vc-annotate-find-visible-log-buffer-window file))))
    (if log-buffer-window
        (let ((original-window (selected-window)))
          (select-window log-buffer-window)
          (vc-call-backend backend 'show-log-entry revision)
          (select-window original-window)))))

(defun vc-annotate-previous-line (&optional arg)
  "Previous line in an annotation buffer, keeping any visible log in sync."
  (interactive "^p")
  (vc-annotate-next-line (- (or arg 1))))

(define-key vc-annotate-mode-map "\C-n" 'vc-annotate-next-line)
(define-key vc-annotate-mode-map "\C-p" 'vc-annotate-previous-line)




reply via email to

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