* some vc-status updates
@ 2008-01-09 1:31 Tom Tromey
2008-01-09 7:28 ` Dan Nicolaescu
2008-01-18 23:22 ` Dan Nicolaescu
0 siblings, 2 replies; 6+ messages in thread
From: Tom Tromey @ 2008-01-09 1:31 UTC (permalink / raw)
To: emacs-devel
This adds a bunch of functionality to vc-status.
Most of the new stuff actually works :).
A few notes:
* I tried to register a new file with svn, but it failed.
This was reported a few days ago but not fixed.
* vc-diff does not work unless you have a file marked. Maybe
vc-status-marked-files should return the current directory in this
case?
* vc-status-move-to-goal-column is a hack
BTW ewoc is pretty nice. I think I will switch package.el to use it.
Mostly this was an experiment, to see how easy it would be to turn
vc-status into a pcvs replacement. It doesn't look super hard, I
guess, though there is still a good amount to do. In particular:
* Asynchronous operation
* Updates. Can you do a full-directory update in VC? Or do we need
another new backend method?
* A new backend method for "ignore".
* Saving buffers should probably update the vc-status buffer.
* Maybe other places checking vc-dired-mode should check for
vc-status-mode.
Tom
2008-01-09 Tom Tromey <tromey@redhat.com>
* vc.el (vc-status-headers): Rename from
vc-status-insert-headers. Just return header.
(vc-status-move-to-goal-column): New function.
(vc-status-mode-map): Define more keys.
(vc-status-mode): Use vc-status-refresh. Now 'special.
(vc-status-refresh): New function.
(vc-status-next-line): Likewise.
(vc-status-previous-line): Likewise.
(vc-status-mark-file): Use vc-status-next-line.
(vc-status-unmark-file): Use vc-status-previous-line.
(vc-status-unmark-file-up): New function.
(vc-status-register): Likewise.
(vc-status-find-file): Likewise.
(vc-status-find-file-other-window): Likewise.
(vc-status-current-file): Likewise.
(vc-ensure-vc-buffer): Understand vc-status mode.
Index: vc.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/vc.el,v
retrieving revision 1.508
diff -u -c -r1.508 vc.el
cvs diff: conflicting specifications of output style
*** vc.el 6 Jan 2008 16:02:38 -0000 1.508
--- vc.el 9 Jan 2008 01:56:25 -0000
***************
*** 1307,1314 ****
(defun vc-ensure-vc-buffer ()
"Make sure that the current buffer visits a version-controlled file."
! (if vc-dired-mode
! (set-buffer (find-file-noselect (dired-get-filename)))
(while (and vc-parent-buffer
(buffer-live-p vc-parent-buffer)
;; Avoid infinite looping when vc-parent-buffer and
--- 1307,1318 ----
(defun vc-ensure-vc-buffer ()
"Make sure that the current buffer visits a version-controlled file."
! (cond
! (vc-dired-mode
! (set-buffer (find-file-noselect (dired-get-filename))))
! ((eq major-mode 'vc-status-mode)
! (set-buffer (find-file-noselect (vc-status-current-file))))
! (t
(while (and vc-parent-buffer
(buffer-live-p vc-parent-buffer)
;; Avoid infinite looping when vc-parent-buffer and
***************
*** 1318,1324 ****
(if (not buffer-file-name)
(error "Buffer %s is not associated with a file" (buffer-name))
(if (not (vc-backend buffer-file-name))
! (error "File %s is not under version control" buffer-file-name)))))
;;; Support for the C-x v v command. This is where all the single-file-oriented
;;; code from before the fileset rewrite lives.
--- 1322,1328 ----
(if (not buffer-file-name)
(error "Buffer %s is not associated with a file" (buffer-name))
(if (not (vc-backend buffer-file-name))
! (error "File %s is not under version control" buffer-file-name))))))
;;; Support for the C-x v v command. This is where all the single-file-oriented
;;; code from before the fileset rewrite lives.
***************
*** 2512,2530 ****
(defvar vc-status nil)
! (defun vc-status-insert-headers (backend dir)
! (insert (format "VC backend :%s\n" backend))
! (insert "Repository : The repository goes here\n")
! (insert (format "Working dir: %s\n\n\n" dir)))
(defun vc-status-printer (fileentry)
"Pretty print FILEENTRY."
(insert
(format "%c %-20s %s"
(if (vc-status-fileinfo->marked fileentry) ?* ? )
(vc-status-fileinfo->state fileentry)
(vc-status-fileinfo->name fileentry))))
(defun vc-status (dir)
"Show the VC status for DIR."
(interactive "DVC status for directory: ")
--- 2518,2543 ----
(defvar vc-status nil)
! (defun vc-status-headers (backend dir)
! (concat
! (format "VC backend : %s\n" backend)
! "Repository : The repository goes here\n"
! (format "Working dir: %s\n" dir)))
(defun vc-status-printer (fileentry)
"Pretty print FILEENTRY."
(insert
+ ;; If you change this, change vc-status-move-to-goal-column.
(format "%c %-20s %s"
(if (vc-status-fileinfo->marked fileentry) ?* ? )
(vc-status-fileinfo->state fileentry)
(vc-status-fileinfo->name fileentry))))
+ (defun vc-status-move-to-goal-column ()
+ (beginning-of-line)
+ ;; Must be in sync with vc-status-printer.
+ (forward-char 25))
+
(defun vc-status (dir)
"Show the VC status for DIR."
(interactive "DVC status for directory: ")
***************
*** 2534,2542 ****
(vc-status-mode))
(defvar vc-status-mode-map
! (let ((map (make-sparse-keymap)))
(define-key map "m" 'vc-status-mark-file)
(define-key map "u" 'vc-status-unmark-file)
map)
"Keymap for VC status")
--- 2547,2576 ----
(vc-status-mode))
(defvar vc-status-mode-map
! (let ((map (make-keymap)))
! (suppress-keymap map)
! ;; Marking.
(define-key map "m" 'vc-status-mark-file)
(define-key map "u" 'vc-status-unmark-file)
+ (define-key map "\C-?" 'vc-status-unmark-file-up)
+ ;; Movement.
+ (define-key map "n" 'vc-status-next-line)
+ (define-key map " " 'vc-status-next-line)
+ (define-key map "\t" 'vc-status-next-line)
+ (define-key map "p" 'vc-status-previous-line)
+ (define-key map [backtab] 'vc-status-previous-line)
+ ;; VC commands.
+ (define-key map "=" 'vc-diff)
+ (define-key map "a" 'vc-status-register)
+ ;; Can't be "g" (as in vc map), so "A" for "Annotate".
+ (define-key map "A" 'vc-annotate)
+ ;; vc-print-log uses the current buffer, not a file.
+ ;; (define-key map "l" 'vc-status-print-log)
+ ;; The remainder.
+ (define-key map "f" 'vc-status-find-file)
+ (define-key map "o" 'vc-status-find-file-other-window)
+ (define-key map "q" 'bury-buffer)
+ (define-key map "g" 'vc-status-refresh)
map)
"Keymap for VC status")
***************
*** 2552,2581 ****
entries)
(erase-buffer)
(set (make-local-variable 'vc-status)
! (ewoc-create #'vc-status-printer))
! (vc-status-insert-headers backend default-directory)
! (setq entries (vc-call-backend backend 'dir-status default-directory))
! (dolist (entry entries)
! (ewoc-enter-last
! vc-status (vc-status-create-fileinfo (cdr entry) (car entry))))))
(defun vc-status-mark-file ()
! "Mark the current file."
(interactive)
(let* ((crt (ewoc-locate vc-status))
(file (ewoc-data crt)))
(setf (vc-status-fileinfo->marked file) t)
(ewoc-invalidate vc-status crt)
! (ewoc-goto-next vc-status 1)))
(defun vc-status-unmark-file ()
! "Mark the current file."
(interactive)
(let* ((crt (ewoc-locate vc-status))
(file (ewoc-data crt)))
(setf (vc-status-fileinfo->marked file) nil)
(ewoc-invalidate vc-status crt)
! (ewoc-goto-next vc-status 1)))
(defun vc-status-marked-files ()
"Return the list of marked files"
--- 2586,2675 ----
entries)
(erase-buffer)
(set (make-local-variable 'vc-status)
! (ewoc-create #'vc-status-printer
! (vc-status-headers backend default-directory)))
! (vc-status-refresh)))
!
! (put 'vc-status-mode 'mode-class 'special)
!
! (defun vc-status-refresh ()
! "Refresh the contents of the VC status buffer."
! (interactive)
! ;; This is not very efficient; ewoc could use a new function here.
! (ewoc-filter vc-status (lambda (node) nil))
! (let ((backend (vc-responsible-backend default-directory)))
! (dolist (entry (vc-call-backend backend 'dir-status default-directory))
! (ewoc-enter-last vc-status
! (vc-status-create-fileinfo (cdr entry) (car entry)))))
! (ewoc-goto-node vc-status (ewoc-nth vc-status 0)))
!
! (defun vc-status-next-line (arg)
! "Go to the next line.
! If a prefix argument is given, move by that many lines."
! (interactive "p")
! (ewoc-goto-next vc-status arg)
! (vc-status-move-to-goal-column))
!
! (defun vc-status-previous-line (arg)
! "Go to the previous line.
! If a prefix argument is given, move by that many lines."
! (interactive "p")
! (ewoc-goto-prev vc-status arg)
! (vc-status-move-to-goal-column))
(defun vc-status-mark-file ()
! "Mark the current file and move to the next line."
(interactive)
(let* ((crt (ewoc-locate vc-status))
(file (ewoc-data crt)))
(setf (vc-status-fileinfo->marked file) t)
(ewoc-invalidate vc-status crt)
! (vc-status-next-line 1)))
(defun vc-status-unmark-file ()
! "Unmark the current file and move to the next line."
(interactive)
(let* ((crt (ewoc-locate vc-status))
(file (ewoc-data crt)))
(setf (vc-status-fileinfo->marked file) nil)
(ewoc-invalidate vc-status crt)
! (vc-status-next-line 1)))
!
! (defun vc-status-unmark-file-up ()
! "Move to the previous line and unmark the file."
! (interactive)
! ;; If we're on the first line, we won't move up, but we will still
! ;; remove the mark. This seems a bit odd but it is what buffer-menu
! ;; does.
! (let* ((prev (ewoc-goto-prev vc-status 1))
! (file (ewoc-data prev)))
! (setf (vc-status-fileinfo->marked file) nil)
! (ewoc-invalidate vc-status prev)
! (vc-status-move-to-goal-column)))
!
! (defun vc-status-register ()
! "Register the marked files, or the current file if no marks."
! (interactive)
! (let ((files (or (vc-status-marked-files)
! (list (vc-status-current-file)))))
! (dolist (file files)
! (vc-register file))))
!
! (defun vc-status-find-file ()
! "Find the file on the current line."
! (interactive)
! (find-file (vc-status-current-file)))
!
! (defun vc-status-find-file-other-window ()
! "Find the file on the current line, in another window."
! (interactive)
! (find-file-other-window (vc-status-current-file)))
!
! (defun vc-status-current-file ()
! (let ((node (ewoc-locate vc-status)))
! (unless node
! (error "No file available."))
! (expand-file-name (vc-status-fileinfo->name (ewoc-data node)))))
(defun vc-status-marked-files ()
"Return the list of marked files"
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: some vc-status updates
2008-01-09 1:31 some vc-status updates Tom Tromey
@ 2008-01-09 7:28 ` Dan Nicolaescu
2008-01-10 2:00 ` Tom Tromey
2008-01-18 23:22 ` Dan Nicolaescu
1 sibling, 1 reply; 6+ messages in thread
From: Dan Nicolaescu @ 2008-01-09 7:28 UTC (permalink / raw)
To: tromey; +Cc: emacs-devel
Tom Tromey <tromey@redhat.com> writes:
> This adds a bunch of functionality to vc-status.
Thanks, I checked this in.
> * vc-diff does not work unless you have a file marked. Maybe
> vc-status-marked-files should return the current directory in this
> case?
Doing the same thing as vc-dired: diff the current files seems like the
most conservative version. I did this.
> Mostly this was an experiment, to see how easy it would be to turn
> vc-status into a pcvs replacement. It doesn't look super hard, I
> guess, though there is still a good amount to do. In particular:
>
> * Asynchronous operation
The backend status call needs to be done with vc-exec-after.
> * Updates. Can you do a full-directory update in VC?
Probably not. But update needs a bit of work anyway: it does not work
for VCSes that only do whole repository updates at a time (hg, git).
> * A new backend method for "ignore".
> * Saving buffers should probably update the vc-status buffer.
PCL-CVS does that. Can that code be "stolen"?
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: some vc-status updates
2008-01-09 7:28 ` Dan Nicolaescu
@ 2008-01-10 2:00 ` Tom Tromey
2008-01-10 4:01 ` Stefan Monnier
2008-01-10 8:04 ` Dan Nicolaescu
0 siblings, 2 replies; 6+ messages in thread
From: Tom Tromey @ 2008-01-10 2:00 UTC (permalink / raw)
To: Dan Nicolaescu; +Cc: emacs-devel
>>>>> "Dan" == Dan Nicolaescu <dann@ics.uci.edu> writes:
Dan> Tom Tromey <tromey@redhat.com> writes:
>> This adds a bunch of functionality to vc-status.
Dan> Thanks, I checked this in.
Thanks. I've appended a couple more simple bindings.
>> * Updates. Can you do a full-directory update in VC?
Dan> Probably not. But update needs a bit of work anyway: it does not work
Dan> for VCSes that only do whole repository updates at a time (hg, git).
We can always error and tell the user that he has to do something
else. Or, we could do a full tree update and just show a subset of
what happens. I don't know which is best.
For DVCs I think we can provide push/pull commands as well.
>> * A new backend method for "ignore".
>> * Saving buffers should probably update the vc-status buffer.
Dan> PCL-CVS does that. Can that code be "stolen"?
Probably. I'm taking all the bindings from pcl-cvs, though not any
implementations yet.
Tom
ChangeLog:
2008-01-10 Tom Tromey <tromey@redhat.com>
* vc.el (vc-status-unmark-all-files): New function.
(vc-status-unmark-all-files): Likewise.
(vc-status-mode-map): Add bindings.
Index: vc.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/vc.el,v
retrieving revision 1.510
diff -u -r1.510 vc.el
--- vc.el 9 Jan 2008 07:21:07 -0000 1.510
+++ vc.el 10 Jan 2008 02:14:21 -0000
@@ -2552,8 +2554,10 @@
(suppress-keymap map)
;; Marking.
(define-key map "m" 'vc-status-mark-file)
+ (define-key map "M" 'vc-status-mark-all-files)
(define-key map "u" 'vc-status-unmark-file)
(define-key map "\C-?" 'vc-status-unmark-file-up)
+ (define-key map "\M-\C-?" 'vc-status-unmark-all-files)
;; Movement.
(define-key map "n" 'vc-status-next-line)
(define-key map " " 'vc-status-next-line)
@@ -2627,6 +2631,16 @@
(ewoc-invalidate vc-status crt)
(vc-status-next-line 1)))
+(defun vc-status-mark-all-files ()
+ "Mark all files."
+ (interactive)
+ (ewoc-map
+ (lambda (file)
+ (unless (vc-status-fileinfo->marked file)
+ (setf (vc-status-fileinfo->marked file) t)
+ t))
+ vc-status))
+
(defun vc-status-unmark-file ()
"Unmark the current file and move to the next line."
(interactive)
@@ -2648,6 +2662,16 @@
(ewoc-invalidate vc-status prev)
(vc-status-move-to-goal-column)))
+(defun vc-status-unmark-all-files ()
+ "Unmark all files."
+ (interactive)
+ (ewoc-map
+ (lambda (file)
+ (when (vc-status-fileinfo->marked file)
+ (setf (vc-status-fileinfo->marked file) nil)
+ t))
+ vc-status))
+
(defun vc-status-register ()
"Register the marked files, or the current file if no marks."
(interactive)
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: some vc-status updates
2008-01-10 2:00 ` Tom Tromey
@ 2008-01-10 4:01 ` Stefan Monnier
2008-01-10 8:04 ` Dan Nicolaescu
1 sibling, 0 replies; 6+ messages in thread
From: Stefan Monnier @ 2008-01-10 4:01 UTC (permalink / raw)
To: Tom Tromey; +Cc: Dan Nicolaescu, emacs-devel
Dan> Probably not. But update needs a bit of work anyway: it does not work
Dan> for VCSes that only do whole repository updates at a time (hg, git).
> We can always error and tell the user that he has to do something
> else. Or, we could do a full tree update and just show a subset of
> what happens. I don't know which is best.
It would be wrong to update files outside of the subtree displayed in
the vc-status buffer. I.e. if the vc-status only displays a subtree and
the backend can only update a whole tree at a time, vc-status should
signal an error explaining it cannot perform the desired operation.
Stefan
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: some vc-status updates
2008-01-10 2:00 ` Tom Tromey
2008-01-10 4:01 ` Stefan Monnier
@ 2008-01-10 8:04 ` Dan Nicolaescu
1 sibling, 0 replies; 6+ messages in thread
From: Dan Nicolaescu @ 2008-01-10 8:04 UTC (permalink / raw)
To: Tom Tromey; +Cc: emacs-devel
Tom Tromey <tromey@redhat.com> writes:
> >>>>> "Dan" == Dan Nicolaescu <dann@ics.uci.edu> writes:
>
> Dan> Tom Tromey <tromey@redhat.com> writes:
> >> This adds a bunch of functionality to vc-status.
>
> Dan> Thanks, I checked this in.
>
> Thanks. I've appended a couple more simple bindings.
Thanks, I checked this in. A menu like vc-dired would also be useful.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: some vc-status updates
2008-01-09 1:31 some vc-status updates Tom Tromey
2008-01-09 7:28 ` Dan Nicolaescu
@ 2008-01-18 23:22 ` Dan Nicolaescu
1 sibling, 0 replies; 6+ messages in thread
From: Dan Nicolaescu @ 2008-01-18 23:22 UTC (permalink / raw)
To: tromey; +Cc: emacs-devel
Tom Tromey <tromey@redhat.com> writes:
> Mostly this was an experiment, to see how easy it would be to turn
> vc-status into a pcvs replacement. It doesn't look super hard, I
> guess, though there is still a good amount to do. In particular:
>
> * Asynchronous operation
vc-status is asynchronous now.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2008-01-18 23:22 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-01-09 1:31 some vc-status updates Tom Tromey
2008-01-09 7:28 ` Dan Nicolaescu
2008-01-10 2:00 ` Tom Tromey
2008-01-10 4:01 ` Stefan Monnier
2008-01-10 8:04 ` Dan Nicolaescu
2008-01-18 23:22 ` Dan Nicolaescu
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.