emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] Changes to emacs/lisp/vc.el,v


From: Dan Nicolaescu
Subject: [Emacs-diffs] Changes to emacs/lisp/vc.el,v
Date: Mon, 21 Apr 2008 05:11:58 +0000

CVSROOT:        /cvsroot/emacs
Module name:    emacs
Changes by:     Dan Nicolaescu <dann>   08/04/21 05:11:56

Index: vc.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/vc.el,v
retrieving revision 1.586
retrieving revision 1.587
diff -u -b -r1.586 -r1.587
--- vc.el       18 Apr 2008 14:24:50 -0000      1.586
+++ vc.el       21 Apr 2008 05:11:56 -0000      1.587
@@ -668,7 +668,7 @@
   (require 'dired)      ; for dired-map-over-marks macro
   (require 'dired-aux))        ; for dired-kill-{line,tree}
 
-(if (not (assoc 'vc-parent-buffer minor-mode-alist))
+(unless (assoc 'vc-parent-buffer minor-mode-alist)
     (setq minor-mode-alist
          (cons '(vc-parent-buffer vc-parent-buffer-name)
                minor-mode-alist)))
@@ -1078,7 +1078,7 @@
     ;; Impatient users sometime kill "slow" buffers; check liveness
     ;; to avoid "error in process sentinel: Selecting deleted buffer".
     (when (buffer-live-p buf)
-      (if previous (funcall previous p s))
+      (when previous (funcall previous p s))
       (with-current-buffer buf
         (setq mode-line-process
               (let ((status (process-status p)))
@@ -1099,7 +1099,7 @@
                 ;; difficult to achieve.
                 (vc-exec-after cmd))))
           ;; But sometimes the sentinels really want to move point.
-          (if vc-sentinel-movepoint
+          (when vc-sentinel-movepoint
               (let ((win (get-buffer-window (current-buffer) 0)))
                 (if (not win)
                     (goto-char vc-sentinel-movepoint)
@@ -1126,7 +1126,7 @@
      ;; anyway. -- cyd
      ((or (null proc) (eq (process-status proc) 'exit))
       ;; Make sure we've read the process's output before going further.
-      (if proc (accept-process-output proc))
+      (when proc (accept-process-output proc))
       (eval code))
      ;; If a process is running, add CODE to the sentinel
      ((eq (process-status proc) 'run)
@@ -1212,7 +1212,7 @@
                             (mapconcat 'identity vc-path path-separator))
                     process-environment))
              (w32-quote-process-args t))
-         (if (and (eq okstatus 'async) (file-remote-p default-directory))
+         (when (and (eq okstatus 'async) (file-remote-p default-directory))
              ;; start-process does not support remote execution
              (setq okstatus nil))
          (if (eq okstatus 'async)
@@ -1229,7 +1229,7 @@
                 `(if vc-command-messages
                      (message "Running %s in background... done" 
',full-command))))
            ;; Run synchrously
-           (if vc-command-messages
+           (when vc-command-messages
                (message "Running %s in foreground..." full-command))
            (let ((buffer-undo-list t))
              (setq status (apply 'process-file command nil t nil squeezed)))
@@ -1270,7 +1270,7 @@
        (point-max)
       (save-excursion
        (let ((diff (- (nth 1 context) (buffer-size))))
-         (if (< diff 0) (setq diff (- diff)))
+         (when (< diff 0) (setq diff (- diff)))
          (goto-char (nth 0 context))
          (if (or (search-forward context-string nil t)
                  ;; Can't use search-backward since the match may continue
@@ -1296,7 +1296,7 @@
 Used by `vc-restore-buffer-context' to later restore the context."
   (let ((point-context (vc-position-context (point)))
        ;; Use mark-marker to avoid confusion in transient-mark-mode.
-       (mark-context  (if (eq (marker-buffer (mark-marker)) (current-buffer))
+       (mark-context  (when (eq (marker-buffer (mark-marker)) (current-buffer))
                           (vc-position-context (mark-marker))))
        ;; Make the right thing happen in transient-mark-mode.
        (mark-active nil)
@@ -1359,12 +1359,12 @@
     ;; if necessary, restore point and mark
     (if (not (vc-context-matches-p (point) point-context))
        (let ((new-point (vc-find-position-by-context point-context)))
-         (if new-point (goto-char new-point))))
+         (when new-point (goto-char new-point))))
     (and mark-active
          mark-context
          (not (vc-context-matches-p (mark) mark-context))
          (let ((new-mark (vc-find-position-by-context mark-context)))
-           (if new-mark (set-mark new-mark))))))
+           (when new-mark (set-mark new-mark))))))
 
 ;;; Code for deducing what fileset and backend to assume
 
@@ -1383,7 +1383,7 @@
 which FILE is not yet registered.  If there is no such backend, return
 the first backend under which FILE is not yet registered, but could
 be registered."
-  (if (not vc-handled-backends)
+  (when (not vc-handled-backends)
       (error "No handled backends"))
   (or (and (not (file-directory-p file)) (not register) (vc-backend file))
       (catch 'found
@@ -1413,7 +1413,7 @@
   (let ((flattened '()))
     (dolist (node file-or-dir-list)
       (vc-file-tree-walk
-       node (lambda (f) (if (vc-backend f) (push f flattened)))))
+       node (lambda (f) (when (vc-backend f) (push f flattened)))))
     (nreverse flattened)))
 
 (defun vc-deduce-fileset (&optional allow-directory-wildcard 
allow-unregistered)
@@ -1483,7 +1483,7 @@
       (set-buffer vc-parent-buffer))
     (if (not buffer-file-name)
        (error "Buffer %s is not associated with a file" (buffer-name))
-      (if (not (vc-backend buffer-file-name))
+      (unless (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
@@ -1515,7 +1515,7 @@
 (defun vc-buffer-sync (&optional not-urgent)
   "Make sure the current buffer and its working file are in sync.
 NOT-URGENT means it is ok to continue if the user says not to save."
-  (if (buffer-modified-p)
+  (when (buffer-modified-p)
       (if (or vc-suppress-confirm
              (y-or-n-p (format "Buffer %s modified; save it? " (buffer-name))))
          (save-buffer)
@@ -1705,7 +1705,7 @@
      ;; unlocked-changes
      ((eq state 'unlocked-changes)
       (dolist (file files)
-       (if (not (equal buffer-file-name file))
+       (when (not (equal buffer-file-name file))
            (find-file-other-window file))
        (if (save-window-excursion
              (vc-diff-internal nil (list file) (vc-working-revision file) nil)
@@ -1768,7 +1768,7 @@
     ;; does not exist yet, even though buffer-modified-p is nil.
     (when bname
       (with-current-buffer bname
-       (if (and (not (buffer-modified-p))
+       (when (and (not (buffer-modified-p))
                 (zerop (buffer-size))
                 (not (file-exists-p buffer-file-name)))
            (set-buffer-modified-p t))
@@ -1797,7 +1797,7 @@
 (defun vc-register-with (backend)
   "Register the current file with a specified back end."
   (interactive "SBackend: ")
-  (if (not (member backend vc-handled-backends))
+  (when (not (member backend vc-handled-backends))
       (error "Unknown back end."))
   (let ((vc-handled-backends (list backend)))
     (call-interactively 'vc-register)))
@@ -1931,7 +1931,7 @@
     (if rev
        (setq file-description (format "%s:%s" file rev))
       (setq file-description file))
-    (if (not (yes-or-no-p (format "Steal the lock on %s from %s? "
+    (when (not (yes-or-no-p (format "Steal the lock on %s from %s? "
                                  file-description owner)))
        (error "Steal canceled"))
     (message "Stealing lock on %s..." file)
@@ -1995,7 +1995,7 @@
   ;; Check and record the comment, if any.
   (unless nocomment
     ;; Comment too long?
-    (vc-call-backend (or (if vc-log-fileset (vc-backend vc-log-fileset))
+    (vc-call-backend (or (when vc-log-fileset (vc-backend vc-log-fileset))
                         (vc-responsible-backend default-directory))
                     'logentry-check)
     (run-hooks 'vc-logentry-check-hook))
@@ -2003,7 +2003,7 @@
   ;; But not if it is a vc-dired buffer.
   (with-current-buffer vc-parent-buffer
     (or vc-dired-mode (eq major-mode 'vc-dir-mode) (vc-buffer-sync)))
-  (if (not vc-log-operation)
+  (unless vc-log-operation
       (error "No log operation is pending"))
   ;; save the parameters held in buffer-local variables
   (let ((log-operation vc-log-operation)
@@ -2031,11 +2031,11 @@
                    (bury-buffer)
                    (pop-to-buffer tmp-vc-parent-buffer))))
     ;; Now make sure we see the expanded headers
-    (if log-fileset
+    (when log-fileset
        (mapc
         (lambda (file) (vc-resynch-buffer file vc-keep-workfiles t))
         log-fileset))
-    (if (or vc-dired-mode (eq major-mode 'vc-dir-mode))
+    (when (or vc-dired-mode (eq major-mode 'vc-dir-mode))
       (dired-move-to-filename))
     (run-hooks after-hook 'vc-finish-logentry-hook)))
 
@@ -2066,7 +2066,7 @@
       ;; if we already have this file open,
       ;; use the buffer's coding system
       (let ((buf (find-buffer-visiting file)))
-        (if buf (with-current-buffer buf
+        (when buf (with-current-buffer buf
                   buffer-file-coding-system)))
       ;; otherwise, try to find one based on the file name
       (car (find-operation-coding-system 'insert-file-contents file))
@@ -2075,20 +2075,20 @@
 
 (defun vc-switches (backend op)
   (let ((switches
-        (or (if backend
+        (or (when backend
                 (let ((sym (vc-make-backend-sym
                             backend (intern (concat (symbol-name op)
                                                     "-switches")))))
-                  (if (boundp sym) (symbol-value sym))))
+                  (when (boundp sym) (symbol-value sym))))
             (let ((sym (intern (format "vc-%s-switches" (symbol-name op)))))
-              (if (boundp sym) (symbol-value sym)))
+              (when (boundp sym) (symbol-value sym)))
             (cond
              ((eq op 'diff) diff-switches)))))
     (if (stringp switches) (list switches)
       ;; If not a list, return nil.
       ;; This is so we can set vc-diff-switches to t to override
       ;; any switches in diff-switches.
-      (if (listp switches) switches))))
+      (when (listp switches) switches))))
 
 ;; Old def for compatibility with Emacs-21.[123].
 (defmacro vc-diff-switches-list (backend) `(vc-switches ',backend 'diff))
@@ -2203,7 +2203,7 @@
       (t
        (setq rev1-default (vc-call previous-revision first
                                   (vc-working-revision first)))
-       (if (string= rev1-default "") (setq rev1-default nil))
+       (when (string= rev1-default "") (setq rev1-default nil))
        (setq rev2-default (vc-working-revision first))))
      ;; construct argument list
      (let* ((rev1-prompt (if rev1-default
@@ -2220,8 +2220,8 @@
                      (completing-read rev2-prompt completion-table
                                       nil nil nil nil rev2-default)
                    (read-string rev2-prompt nil nil rev2-default))))
-       (if (string= rev1 "") (setq rev1 nil))
-       (if (string= rev2 "") (setq rev2 nil))
+       (when (string= rev1 "") (setq rev1 nil))
+       (when (string= rev2 "") (setq rev2 nil))
        (list files rev1 rev2))))
   (if (and (not rev1) rev2)
       (error "Not a valid revision range."))
@@ -2250,7 +2250,7 @@
   (if historic
       (call-interactively 'vc-version-diff)
     (let* ((files (vc-deduce-fileset t)))
-      (if buffer-file-name (vc-buffer-sync not-urgent))
+      (when buffer-file-name (vc-buffer-sync not-urgent))
       (vc-diff-internal t files nil nil (interactive-p)))))
 
 
@@ -2320,7 +2320,7 @@
   (save-excursion
     (save-restriction
       (widen)
-      (if (or (not (vc-check-headers))
+      (when (or (not (vc-check-headers))
              (y-or-n-p "Version headers already exist.  Insert another set? "))
           (let* ((delims (cdr (assq major-mode vc-comment-alist)))
                  (comment-start-vc (or (car delims) comment-start "#"))
@@ -2331,9 +2331,9 @@
             (dolist (s hdstrings)
               (insert comment-start-vc "\t" s "\t"
                       comment-end-vc "\n"))
-            (if vc-static-header-alist
+         (when vc-static-header-alist
                 (dolist (f vc-static-header-alist)
-                  (if (string-match (car f) buffer-file-name)
+             (when (string-match (car f) buffer-file-name)
                       (insert (format (cdr f) (car hdstrings)))))))))))
 
 (defun vc-clear-headers (&optional file)
@@ -2659,7 +2659,7 @@
     (when (fboundp 'dired-buffers-for-dir)
       (dolist (buffer (dired-buffers-for-dir dir))
         (with-current-buffer buffer
-          (if vc-dired-mode
+          (when vc-dired-mode
               (push buffer result)))))
     (nreverse result)))
 
@@ -2669,7 +2669,7 @@
     (when buffers
       (mapcar (lambda (buffer)
                (with-current-buffer buffer
-                 (if (dired-goto-file file)
+                 (when (dired-goto-file file)
                      ;; bind vc-dired-terse-mode to nil so that
                      ;; files won't vanish when they are checked in
                      (let ((vc-dired-terse-mode nil))
@@ -2707,7 +2707,7 @@
             (:type list)            ;So we can use `member' on lists of FIs.
             (:constructor
              ;; We could define it as an alias for `list'.
-            vc-dir-create-fileinfo (name state &optional extra marked))
+            vc-dir-create-fileinfo (name state &optional extra marked 
directory))
             (:conc-name vc-dir-fileinfo->))
   name                                  ;Keep it as first, for `member'.
   state
@@ -2717,7 +2717,7 @@
   ;; To keep track of not updated files during a global refresh
   needs-update
   ;; To distinguish files and directories.
-  directoryp)
+  directory)
 
 (defvar vc-ewoc nil)
 
@@ -2741,10 +2741,11 @@
 
 (defun vc-default-status-printer (backend fileentry)
   "Pretty print FILEENTRY."
-  (if (vc-dir-fileinfo->directoryp fileentry)
-      (insert "   Directory: %s" (vc-dir-fileinfo->name fileentry))
     ;; If you change the layout here, change vc-dir-move-to-goal-column.
-    (let ((state (vc-dir-fileinfo->state fileentry)))
+  (let ((state
+        (if (vc-dir-fileinfo->directory fileentry)
+            'DIRECTORY
+          (vc-dir-fileinfo->state fileentry))))
       (insert
        (propertize
        (format "%c" (if (vc-dir-fileinfo->marked fileentry) ?* ? ))
@@ -2760,7 +2761,7 @@
        (propertize
        (format "%s" (vc-dir-fileinfo->name fileentry))
        'face 'font-lock-function-name-face
-       'mouse-face 'highlight)))))
+      'mouse-face 'highlight))))
 
 (defun vc-dir-printer (fileentry)
   (let ((backend (vc-responsible-backend default-directory)))
@@ -3016,6 +3017,12 @@
 
 (put 'vc-dir-mode 'mode-class 'special)
 
+;; t if directories should be shown in vc-dir.
+;; WORK IN PROGRESS!  DO NOT SET this! ONLY set it if you want to help
+;; write code for this feature.  This variable will likely disappear
+;; when the work is done.
+(defvar vc-dir-insert-directories t)
+
 (defun vc-dir-update (entries buffer &optional noinsert)
   "Update BUFFER's ewoc from the list of ENTRIES.
 If NOINSERT, ignore elements on ENTRIES which are not in the ewoc."
@@ -3036,6 +3043,7 @@
                     ((string< dir1 dir2) t)
                     ((not (string= dir1 dir2)) nil)
                     ((string< (car entry1) (car entry2))))))))
+    (if (not vc-dir-insert-directories)
     (let ((entry (car entries))
            (node (ewoc-nth vc-ewoc 0)))
       (while (and entry node)
@@ -3060,7 +3068,75 @@
         ;; We're past the last node, all remaining entries go to the end.
         (while entries
           (ewoc-enter-last vc-ewoc
-                           (apply 'vc-dir-create-fileinfo (pop entries))))))))
+                              (apply 'vc-dir-create-fileinfo (pop entries))))))
+  ;; Insert directory entries in the right places.
+  (let ((entry (car entries))
+       (node (ewoc-nth vc-ewoc 0)))
+    ;; Insert . if it is not present.
+    (unless node
+      (let ((rd (file-relative-name default-directory)))
+       (ewoc-enter-last
+        vc-ewoc (vc-dir-create-fileinfo
+                 rd nil nil nil (expand-file-name default-directory))))
+      (setq node (ewoc-nth vc-ewoc 0)))
+
+    (while (and entry node)
+      (let* ((entryfile (car entry))
+            (entrydir (file-name-directory (expand-file-name entryfile)))
+            (nodedir
+             (or (vc-dir-fileinfo->directory (ewoc-data node))
+                 (file-name-directory
+                      (expand-file-name
+                       (vc-dir-fileinfo->name (ewoc-data node)))))))
+       (cond
+        ;; First try to find the directory.
+        ((string-lessp nodedir entrydir)
+         (setq node (ewoc-next vc-ewoc node)))
+        ((string-equal nodedir entrydir)
+         ;; Found the directory, find the place for the file name.
+         (let ((nodefile (vc-dir-fileinfo->name (ewoc-data node))))
+           (cond
+            ((string-lessp nodefile entryfile)
+             (setq node (ewoc-next vc-ewoc node)))
+             ((string-equal nodefile entryfile)
+              (setf (vc-dir-fileinfo->state (ewoc-data node)) (nth 1 entry))
+              (setf (vc-dir-fileinfo->extra (ewoc-data node)) (nth 2 entry))
+              (setf (vc-dir-fileinfo->needs-update (ewoc-data node)) nil)
+              (ewoc-invalidate vc-ewoc node)
+              (setq entries (cdr entries) entry (car entries))
+              (setq node (ewoc-next vc-ewoc node)))
+             (t
+              (ewoc-enter-before vc-ewoc node
+                                 (apply 'vc-dir-create-fileinfo entry))
+              (setq entries (cdr entries) entry (car entries))))))
+        (t
+         ;; We need to insert a directory node
+         (let ((rd (file-relative-name entrydir)))
+           (ewoc-enter-last
+            vc-ewoc (vc-dir-create-fileinfo rd nil nil nil entrydir)))
+         ;; Now insert the node itself.
+         (ewoc-enter-before vc-ewoc node
+                            (apply 'vc-dir-create-fileinfo entry))
+         (setq entries (cdr entries) entry (car entries))))))
+    ;; We're past the last node, all remaining entries go to the end.
+    (unless (or node noinsert)
+      (let* ((lastnode (ewoc-nth vc-ewoc -1))
+            (lastdir
+             (or (vc-dir-fileinfo->directory (ewoc-data lastnode))
+                 (file-name-directory
+                      (expand-file-name
+                       (vc-dir-fileinfo->name (ewoc-data lastnode)))))))
+       (dolist (entry entries)
+         (let ((entrydir (file-name-directory (expand-file-name (car entry)))))
+           ;; Insert a directory node if needed.
+           (unless (string-equal lastdir entrydir)
+             (setq lastdir entrydir)
+             (let ((rd (file-relative-name entrydir)))
+               (ewoc-enter-last
+                vc-ewoc (vc-dir-create-fileinfo rd nil nil nil entrydir))))
+           ;; Now insert the node itself.
+           (ewoc-enter-last vc-ewoc
+                            (apply 'vc-dir-create-fileinfo entry))))))))))
 
 (defun vc-dir-busy ()
   (and (buffer-live-p vc-dir-process-buffer)
@@ -3385,7 +3461,7 @@
        dir
        (lambda (f)
         (if (not (vc-up-to-date-p f)) (throw 'vc-locked-example f)
-          (if (get-file-buffer f) (setq status 'visited)))))
+          (when (get-file-buffer f) (setq status 'visited)))))
       status)))
 
 ;;;###autoload
@@ -3400,7 +3476,7 @@
          (read-string "New snapshot name: ")
         current-prefix-arg))
   (message "Making %s... " (if branchp "branch" "snapshot"))
-  (if (file-directory-p dir) (setq dir (file-name-as-directory dir)))
+  (when (file-directory-p dir) (setq dir (file-name-as-directory dir)))
   (vc-call-backend (vc-responsible-backend dir)
                   'create-snapshot dir name branchp)
   (message "Making %s... done" (if branchp "branch" "snapshot")))
@@ -3448,7 +3524,7 @@
          (delete-char (- (match-end 0) (match-beginning 0)))
          (forward-line -1))
        (goto-char (point-min))
-       (if (looking-at "[\b\t\n\v\f\r ]+")
+       (when (looking-at "[\b\t\n\v\f\r ]+")
            (delete-char (- (match-end 0) (match-beginning 0))))
        (shrink-window-if-larger-than-buffer)
        ;; move point to the log entry for the working revision
@@ -3467,26 +3543,24 @@
     ;; sure buffer is saved.  If the user says `no', abort since
     ;; we cannot show the changes and ask for confirmation to
     ;; discard them.
-    (if (or (not files) (memq (buffer-file-name) files))
+    (when (or (not files) (memq (buffer-file-name) files))
        (vc-buffer-sync nil))
     (dolist (file files)
       (let ((buf (get-file-buffer file)))
-       (if (and buf (buffer-modified-p buf))
+       (when (and buf (buffer-modified-p buf))
          (error "Please kill or save all modified buffers before reverting.")))
-      (if (vc-up-to-date-p file)
+      (when (vc-up-to-date-p file)
          (unless (yes-or-no-p (format "%s seems up-to-date.  Revert anyway? " 
file))
            (error "Revert canceled"))))
-    (if (vc-diff-internal vc-allow-async-revert files nil nil)
-       (progn
+    (when (vc-diff-internal vc-allow-async-revert files nil nil)
          (unless (yes-or-no-p (format "Discard changes in %s? " (vc-delistify 
files)))
            (error "Revert canceled"))
          (delete-windows-on "*vc-diff*")
-         (kill-buffer "*vc-diff*")))
+      (kill-buffer "*vc-diff*"))
     (dolist (file files)
-      (progn
        (message "Reverting %s..." (vc-delistify files))
        (vc-revert-file file)
-       (message "Reverting %s...done" (vc-delistify files))))))
+      (message "Reverting %s...done" (vc-delistify files)))))
 
 ;;;###autoload
 (defun vc-rollback ()
@@ -3499,20 +3573,20 @@
         (granularity (vc-call-backend backend 'revision-granularity)))
     (unless (vc-find-backend-function backend 'rollback)
       (error "Rollback is not supported in %s" backend))
-    (if (and (not (eq granularity 'repository)) (/= (length files) 1))
+    (when (and (not (eq granularity 'repository)) (/= (length files) 1))
        (error "Rollback requires a singleton fileset or repository 
versioning"))
-    (if (not (vc-call latest-on-branch-p (car files)))
+    (when (not (vc-call latest-on-branch-p (car files)))
        (error "Rollback is only possible at the tip revision."))
     ;; If any of the files is visited by the current buffer, make
     ;; sure buffer is saved.  If the user says `no', abort since
     ;; we cannot show the changes and ask for confirmation to
     ;; discard them.
-    (if (or (not files) (memq (buffer-file-name) files))
+    (when (or (not files) (memq (buffer-file-name) files))
        (vc-buffer-sync nil))
     (dolist (file files)
-      (if (buffer-modified-p (get-file-buffer file))
+      (when (buffer-modified-p (get-file-buffer file))
          (error "Please kill or save all modified buffers before rollback."))
-      (if (not (vc-up-to-date-p file))
+      (when (not (vc-up-to-date-p file))
          (error "Please revert all modified workfiles before rollback.")))
     ;; Accumulate changes associated with the fileset
     (vc-setup-buffer "*vc-diff*")
@@ -3579,7 +3653,7 @@
           backup-file
         ;; there is no automatic backup, but maybe the user made one manually
         (setq backup-file (vc-version-backup-file-name file rev 'manual))
-        (if (file-exists-p backup-file)
+        (when (file-exists-p backup-file)
             backup-file)))))
 
 (defun vc-revert-file (file)
@@ -3705,7 +3779,7 @@
          (mapcar
           (lambda (s) (vc-possible-master s newdir newbase))
           templates)))
-    (if (or (file-symlink-p oldmaster)
+    (when (or (file-symlink-p oldmaster)
            (file-symlink-p (file-name-directory oldmaster)))
        (error "This is unsafe in the presence of symbolic links"))
     (rename-file
@@ -3733,7 +3807,7 @@
              (file-name-nondirectory file)))
     (unless (vc-find-backend-function backend 'delete-file)
       (error "Deleting files under %s is not supported in VC" backend))
-    (if (and buf (buffer-modified-p buf))
+    (when (and buf (buffer-modified-p buf))
        (error "Please save files before deleting them"))
     (unless (y-or-n-p (format "Really want to delete %s? "
                              (file-name-nondirectory file)))
@@ -3748,7 +3822,7 @@
        (unless buf (kill-buffer (current-buffer)))))
     (vc-call delete-file file)
     ;; If the backend hasn't deleted the file itself, let's do it for him.
-    (if (file-exists-p file) (delete-file file))
+    (when (file-exists-p file) (delete-file file))
     ;; Forget what VC knew about the file.
     (vc-file-clearprops file)
     (vc-resynch-buffer file buf t)))
@@ -3758,11 +3832,11 @@
   "Rename file OLD to NEW, and rename its master file likewise."
   (interactive "fVC rename file: \nFRename to: ")
   (let ((oldbuf (get-file-buffer old)))
-    (if (and oldbuf (buffer-modified-p oldbuf))
+    (when (and oldbuf (buffer-modified-p oldbuf))
        (error "Please save files before moving them"))
-    (if (get-file-buffer new)
+    (when (get-file-buffer new)
        (error "Already editing new file name"))
-    (if (file-exists-p new)
+    (when (file-exists-p new)
        (error "New file already exists"))
     (let ((state (vc-state old)))
       (unless (memq state '(up-to-date edited))
@@ -3771,11 +3845,11 @@
     (vc-call rename-file old new)
     (vc-file-clearprops old)
     ;; Move the actual file (unless the backend did it already)
-    (if (file-exists-p old) (rename-file old new))
+    (when (file-exists-p old) (rename-file old new))
     ;; ?? Renaming a file might change its contents due to keyword expansion.
     ;; We should really check out a new copy if the old copy was precisely 
equal
     ;; to some checked-in revision.  However, testing for this is tricky....
-    (if oldbuf
+    (when oldbuf
        (with-current-buffer oldbuf
          (let ((buffer-read-only buffer-read-only))
            (set-visited-file-name new))
@@ -3839,7 +3913,7 @@
 (defun vc-branch-part (rev)
   "Return the branch part of a revision number REV."
   (let ((index (string-match "\\.[0-9]+\\'" rev)))
-    (if index
+    (when index
         (substring rev 0 index))))
 
 (defun vc-minor-part (rev)
@@ -4030,7 +4104,7 @@
                 (vc-up-to-date-p f)
                 (vc-error-occurred
                  (vc-call checkout f nil "")
-                 (if update (vc-resynch-buffer f t t)))))))
+                 (when update (vc-resynch-buffer f t t)))))))
     (let ((result (vc-snapshot-precondition dir)))
       (if (stringp result)
           (error "File %s is locked" result)
@@ -4039,7 +4113,7 @@
          dir
          (lambda (f) (vc-error-occurred
                 (vc-call checkout f nil name)
-                (if update (vc-resynch-buffer f t t)))))))))
+                (when update (vc-resynch-buffer f t t)))))))))
 
 (defun vc-default-revert (backend file contents-done)
   (unless contents-done
@@ -4160,9 +4234,9 @@
       (goto-char (point-min))
       (while (not (eobp))
         (when (setq date (vc-annotate-get-time-set-line-props))
-          (if (> date newest)
+          (when (> date newest)
               (setq newest date))
-          (if (< date oldest)
+          (when (< date oldest)
               (setq oldest date)))
         (forward-line 1)))
     (vc-annotate-display
@@ -4239,7 +4313,7 @@
 BUFFER.  `vc-annotate-display-mode' specifies the highlighting mode to
 use; you may override this using the second optional arg MODE."
   (interactive)
-  (if mode (setq vc-annotate-display-mode mode))
+  (when mode (setq vc-annotate-display-mode mode))
   (pop-to-buffer (or buffer (current-buffer)))
   (cond ((null vc-annotate-display-mode)
          ;; The ratio is global, thus relative to the global color-map.
@@ -4311,7 +4385,7 @@
     ;; If BUF is specified it tells in which buffer we should put the
     ;; annotations.  This is used when switching annotations to another
     ;; revision, so we should update the buffer's name.
-    (if buf (with-current-buffer buf
+    (when buf (with-current-buffer buf
              (rename-buffer temp-buffer-name t)
              ;; In case it had to be uniquified.
              (setq temp-buffer-name (buffer-name))))
@@ -4321,7 +4395,7 @@
       ;; variables before the show-function is called at the exit of
       ;; with-output-to-temp-buffer
       (with-current-buffer temp-buffer-name
-        (if (not (equal major-mode 'vc-annotate-mode))
+        (unless (equal major-mode 'vc-annotate-mode)
             (vc-annotate-mode))
         (set (make-local-variable 'vc-annotate-backend) (vc-backend file))
         (set (make-local-variable 'vc-annotate-parent-file) file)
@@ -4457,7 +4531,7 @@
               (setq newrev (vc-call next-revision
                                     vc-annotate-parent-file newrev))
               (setq revspec (1- revspec)))
-       (if (not newrev)
+       (unless newrev
            (message "Cannot increment %d revisions from revision %s"
                     revspeccopy vc-annotate-parent-rev)))
        ((and (integerp revspec) (< revspec 0))
@@ -4466,7 +4540,7 @@
               (setq newrev (vc-call previous-revision
                                     vc-annotate-parent-file newrev))
               (setq revspec (1+ revspec)))
-       (if (not newrev)
+       (unless newrev
            (message "Cannot decrement %d revisions from revision %s"
                     (- 0 revspeccopy) vc-annotate-parent-rev)))
        ((stringp revspec) (setq newrev revspec))
@@ -4504,7 +4578,7 @@
 difference in days between the time returned and the current time,
 or OFFSET if present."
    (let ((next-time (vc-annotate-get-time-set-line-props)))
-     (if next-time
+     (when next-time
         (- (or offset
                (vc-call-backend vc-annotate-backend 'annotate-current-time))
            next-time))))
@@ -4519,7 +4593,7 @@
   "Highlight `vc-annotate' output in the current buffer.
 RATIO, is the expansion that should be applied to `vc-annotate-color-map'.
 The annotations are relative to the current time, unless overridden by OFFSET."
-  (if (/= ratio 1.0)
+  (when (/= ratio 1.0)
       (set (make-local-variable 'vc-annotate-color-map)
            (mapcar (lambda (elem) (cons (* (car elem) ratio) (cdr elem)))
                    vc-annotate-color-map)))
@@ -4544,7 +4618,7 @@
                (face (or (intern-soft face-name)
                          (let ((tmp-face (make-face (intern face-name))))
                            (set-face-foreground tmp-face (cdr color))
-                           (if vc-annotate-background
+                           (when vc-annotate-background
                                (set-face-background tmp-face
                                                     vc-annotate-background))
                            tmp-face))))        ; Return the face
@@ -4578,7 +4652,7 @@
 
 (defun vc-file-tree-walk-internal (file func args)
   (if (not (file-directory-p file))
-      (if (vc-backend file) (apply func file args))
+      (when (vc-backend file) (apply func file args))
     (message "Traversing directory %s..." (abbreviate-file-name file))
     (let ((dir (file-name-as-directory file)))
       (mapcar




reply via email to

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