From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: C-x v l does not move to current log entry Date: Sat, 15 Sep 2007 18:25:20 -0400 Message-ID: References: <46B03B75.4000008@swipnet.se> <46E4E9F5.1070701@swipnet.se> <46EA2D22.9090902@swipnet.se> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1189895138 2835 80.91.229.12 (15 Sep 2007 22:25:38 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sat, 15 Sep 2007 22:25:38 +0000 (UTC) Cc: Glenn Morris , emacs-devel@gnu.org To: Jan =?iso-8859-1?Q?Dj=E4rv?= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Sep 16 00:25:35 2007 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1IWg50-0002DR-0a for ged-emacs-devel@m.gmane.org; Sun, 16 Sep 2007 00:25:34 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IWg4y-0008Ur-T2 for ged-emacs-devel@m.gmane.org; Sat, 15 Sep 2007 18:25:32 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1IWg4v-0008Uc-NB for emacs-devel@gnu.org; Sat, 15 Sep 2007 18:25:29 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1IWg4s-0008UQ-6u for emacs-devel@gnu.org; Sat, 15 Sep 2007 18:25:28 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IWg4s-0008UN-0J for emacs-devel@gnu.org; Sat, 15 Sep 2007 18:25:26 -0400 Original-Received: from tomts22.bellnexxia.net ([209.226.175.184] helo=tomts22-srv.bellnexxia.net) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1IWg4n-0002Ln-KT; Sat, 15 Sep 2007 18:25:21 -0400 Original-Received: from pastel.home ([70.55.141.227]) by tomts22-srv.bellnexxia.net (InterMail vM.5.01.06.13 201-253-122-130-113-20050324) with ESMTP id <20070915222520.ICNN18413.tomts22-srv.bellnexxia.net@pastel.home>; Sat, 15 Sep 2007 18:25:20 -0400 Original-Received: by pastel.home (Postfix, from userid 20848) id 1C3A685BF; Sat, 15 Sep 2007 18:25:19 -0400 (EDT) In-Reply-To: <46EA2D22.9090902@swipnet.se> ("Jan =?iso-8859-1?Q?Dj=E4rv=22?= =?iso-8859-1?Q?'s?= message of "Fri\, 14 Sep 2007 08\:41\:38 +0200") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/23.0.50 (gnu/linux) X-Detected-Kernel: Solaris 8 (1) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:79000 Archived-At: > Thanks for pointing this out. What is the reason for this change? It is > very annoying when C-x v l does not move from the top of the buffer. > It cases a lot of manual searching and scrolling. I've just installed the patch below which should help. Stefan Index: lisp/vc.el =================================================================== RCS file: /sources/emacs/emacs/lisp/vc.el,v retrieving revision 1.455 diff -u -r1.455 vc.el --- lisp/vc.el 6 Sep 2007 05:28:07 -0000 1.455 +++ lisp/vc.el 15 Sep 2007 22:24:51 -0000 @@ -975,6 +975,33 @@ (inhibit-read-only t)) (erase-buffer)))) +(defvar vc-sentinel-movepoint) ;Dynamically scoped. + +(defun vc-process-sentinel (p s) + (let ((previous (process-get p 'vc-previous-sentinel))) + (if previous (funcall previous p s)) + (with-current-buffer (process-buffer p) + (let (vc-sentinel-movepoint) + ;; Normally, we want async code such as sentinels to not move point. + (save-excursion + (goto-char (process-mark p)) + (let ((cmds (process-get p 'vc-sentinel-commands))) + (process-put p 'vc-postprocess nil) + (dolist (cmd cmds) + ;; Each sentinel may move point and the next one should be run + ;; at that new point. We could get the same result by having + ;; each sentinel read&set process-mark, but since `cmd' needs + ;; to work both for async and sync processes, this would be + ;; difficult to achieve. + (vc-exec-after cmd)))) + ;; But sometimes the sentinels really want to move point. + (if vc-sentinel-movepoint + (let ((win (get-buffer-window (current-buffer) 0))) + (if (not win) + (goto-char vc-sentinel-movepoint) + (with-selected-window win + (goto-char vc-sentinel-movepoint))))))))) + (defun vc-exec-after (code) "Eval CODE when the current buffer's process is done. If the current buffer has no process, just evaluate CODE. @@ -992,17 +1019,12 @@ (eval code)) ;; If a process is running, add CODE to the sentinel ((eq (process-status proc) 'run) - (let ((sentinel (process-sentinel proc))) - (set-process-sentinel proc - `(lambda (p s) - (with-current-buffer ',(current-buffer) - (save-excursion - (goto-char (process-mark p)) - ,@(append (cdr (cdr (car ;Strip off (save-exc (goto-char...) - (cdr (cdr ;Strip off (with-current-buffer buf - (car (cdr (cdr ;Strip off (lambda (p s) - sentinel)))))))) - (list `(vc-exec-after ',code))))))))) + (let ((previous (process-sentinel proc))) + (unless (eq previous 'vc-process-sentinel) + (process-put proc 'vc-previous-sentinel previous)) + (set-process-sentinel proc 'vc-process-sentinel)) + (process-put proc 'vc-sentinel-commands + (cons code (process-get proc 'vc-sentinel-commands)))) (t (error "Unexpected process state")))) nil) @@ -1087,7 +1109,8 @@ (if vc-command-messages (message "Running %s...OK" full-command))) (vc-exec-after - `(run-hook-with-args 'vc-post-command-functions ',command ',file-or-list ',flags)) + `(run-hook-with-args 'vc-post-command-functions + ',command ',file-or-list ',flags)) status)))) (defun vc-position-context (posn) @@ -2557,6 +2580,7 @@ (vc-call-backend ',(vc-backend file) 'show-log-entry ',focus-rev) + (setq vc-sentinel-movepoint (point)) (set-buffer-modified-p nil))))) (defun vc-default-log-view-mode (backend) (log-view-mode)) @@ -3279,10 +3303,8 @@ ;; moved it elsewhere, but really point here is not the position ;; of the user's cursor :-( (when ,current-line ;(and (bobp)) - (let ((win (get-buffer-window (current-buffer) 0))) - (when win - (with-selected-window win - (goto-line ,current-line))))) + (goto-line ,current-line) + (setq vc-sentinel-movepoint)) (unless (active-minibuffer-window) (message "Annotating... done")))))))