(declare (indent 2) (debug t))
`(if ,async
(progn
- (make-thread
- ;; We use `vc-mutex' here in order to let all
- ;; `vc-refresh-state' run after the file visiting
- ;; operations.
- (lambda () (with-mutex vc-mutex ,@body))
- (concat "find-file " ,filename))
+ (make-thread (lambda () ,@body) (concat "find-file " ,filename))
(thread-yield))
,@body))
(lambda () (find-file-noselect file))
(concat "find-file-noselect " file)))
files))
- ;; Collect the results.
- (thread-yield)
- (dolist (thread threads result)
- (setq result (cons (thread-join thread) result))))
+ ;; Collect the results. We use `vc-mutex' here in
+ ;; order to let all `vc-refresh-state' threads run
+ ;; after the file visiting operations.
+ (with-mutex vc-mutex
+ (thread-yield)
+ (dolist (thread threads result)
+ (setq result (cons (thread-join thread) result)))))
(mapcar #'find-file-noselect files))))
;; Run it asynchronously.
(make-thread
(lambda ()
- ;; Don't let the vc operations disturb each other. Delay this
- ;; after all find-file* operations have finished.
- (with-mutex vc-mutex
- (vc-file-clearprops buffer-file-name)
- ;; FIXME: Why use a hook? Why pass it buffer-file-name?
- (add-hook 'vc-mode-line-hook 'vc-mode-line nil t)
- (let (backend)
- (cond
- ((setq backend (with-demoted-errors (vc-backend buffer-file-name)))
- ;; Let the backend setup any buffer-local things he needs.
- (vc-call-backend backend 'find-file-hook)
- ;; Compute the state and put it in the mode line.
- (vc-mode-line buffer-file-name backend)
- (unless vc-make-backup-files
- ;; Use this variable, not make-backup-files,
- ;; because this is for things that depend on the file name.
- (set (make-local-variable 'backup-inhibited) t)))
- ((let* ((truename (and buffer-file-truename
- (expand-file-name buffer-file-truename)))
- (link-type (and truename
- (not (equal buffer-file-name truename))
- (vc-backend truename))))
- (cond ((not link-type) nil) ;Nothing to do.
- ((eq vc-follow-symlinks nil)
+ ;; Wait, until the file visitng function tells us so.
+ (with-mutex vc-mutex)
+ (vc-file-clearprops buffer-file-name)
+ ;; FIXME: Why use a hook? Why pass it buffer-file-name?
+ (add-hook 'vc-mode-line-hook 'vc-mode-line nil t)
+ (let (backend)
+ (cond
+ ((setq backend (with-demoted-errors (vc-backend buffer-file-name)))
+ ;; Let the backend setup any buffer-local things he needs.
+ (vc-call-backend backend 'find-file-hook)
+ ;; Compute the state and put it in the mode line.
+ (vc-mode-line buffer-file-name backend)
+ (unless vc-make-backup-files
+ ;; Use this variable, not make-backup-files, because this
+ ;; is for things that depend on the file name.
+ (set (make-local-variable 'backup-inhibited) t)))
+ ((let* ((truename (and buffer-file-truename
+ (expand-file-name buffer-file-truename)))
+ (link-type (and truename
+ (not (equal buffer-file-name truename))
+ (vc-backend truename))))
+ (cond ((not link-type) nil) ;Nothing to do.
+ ((eq vc-follow-symlinks nil)
+ (message
+ "Warning: symbolic link to %s-controlled source file"
+ link-type))
+ ((or (not (eq vc-follow-symlinks 'ask))
+ ;; Assume we cannot ask, default to yes.
+ noninteractive
+ ;; Copied from server-start. Seems like there
+ ;; should be a better way to ask "can we get
+ ;; user input?"...
+ (and (daemonp)
+ (null (cdr (frame-list)))
+ (eq (selected-frame) terminal-frame))
+ ;; If we already visited this file by
+ ;; following the link, don't ask again if we
+ ;; try to visit it again. GUD does that, and
+ ;; repeated questions are painful.
+ (get-file-buffer
+ (abbreviate-file-name
+ (file-chase-links buffer-file-name))))
+
+ (vc-follow-link)
+ (message "Followed link to %s" buffer-file-name)
+ (vc-refresh-state))
+ (t
+ (if (yes-or-no-p
+ (format
+ (concat
+ "Symbolic link to %s-controlled source file; "
+ "follow link? ")
+ link-type))
+ (progn (vc-follow-link)
+ (message
+ "Followed link to %s" buffer-file-name)
+ (vc-refresh-state))
(message
- "Warning: symbolic link to %s-controlled source file"
- link-type))
- ((or (not (eq vc-follow-symlinks 'ask))
- ;; Assume we cannot ask, default to yes.
- noninteractive
- ;; Copied from server-start. Seems like
- ;; there should be a better way to ask "can
- ;; we get user input?"...
- (and (daemonp)
- (null (cdr (frame-list)))
- (eq (selected-frame) terminal-frame))
- ;; If we already visited this file by
- ;; following the link, don't ask again if we
- ;; try to visit it again. GUD does that,
- ;; and repeated questions are painful.
- (get-file-buffer
- (abbreviate-file-name
- (file-chase-links buffer-file-name))))
-
- (vc-follow-link)
- (message "Followed link to %s" buffer-file-name)
- (vc-refresh-state))
- (t
- (if (yes-or-no-p
- (format
- (concat
- "Symbolic link to %s-controlled source file; "
- "follow link? ")
- link-type))
- (progn (vc-follow-link)
- (message
- "Followed link to %s" buffer-file-name)
- (vc-refresh-state))
- (message
- (concat
- "Warning: editing through the link "
- "bypasses version control")))))))))))
+ (concat
+ "Warning: editing through the link "
+ "bypasses version control"))))))))))
;; The thread name.
- (concat "vc-refresh-state " buffer-file-name))
+ (concat "vc-refresh-state " (buffer-name)))
;; Give other threads a chance to run.
(thread-yield)))