unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: "Jan Djärv" <jan.h.d@swipnet.se>
Cc: Glenn Morris <rgm@gnu.org>, emacs-devel@gnu.org
Subject: Re: C-x v l does not move to current log entry
Date: Sat, 15 Sep 2007 18:25:20 -0400	[thread overview]
Message-ID: <jwvtzpvmv4y.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <46EA2D22.9090902@swipnet.se> ("Jan Djärv"'s message of "Fri\, 14 Sep 2007 08\:41\:38 +0200")

> 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")))))))

  reply	other threads:[~2007-09-15 22:25 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-08-01  7:51 C-x v l does not move to current log entry Jan Djärv
2007-08-02 15:45 ` Richard Stallman
2007-08-04  3:08   ` Bob Rogers
2007-08-05  3:06     ` Richard Stallman
2007-08-10  8:09     ` Stefan Monnier
2007-08-12  4:15     ` Richard Stallman
2007-08-12  8:30       ` Jan Djärv
2007-08-12 22:01         ` Stefan Monnier
2007-08-13  6:03           ` Jan Djärv
2007-09-10  6:53 ` Jan Djärv
2007-09-12  8:30   ` Glenn Morris
2007-09-14  6:41     ` Jan Djärv
2007-09-15 22:25       ` Stefan Monnier [this message]
2007-09-16  8:55         ` Jan Djärv

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=jwvtzpvmv4y.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=emacs-devel@gnu.org \
    --cc=jan.h.d@swipnet.se \
    --cc=rgm@gnu.org \
    /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).