aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2019-02-18 09:43:59 -0500
committerStefan Monnier2019-02-18 09:43:59 -0500
commit2ede38ce4bf336c573450c61a2e9a41fb7ebe1be (patch)
tree2d4a9ddfc202cbc9859a1818a325409f58a71b07
parent2eecaa28972320a1b8886ac8cde353c2a2f4aa44 (diff)
downloademacs-2ede38ce4bf336c573450c61a2e9a41fb7ebe1be.tar.gz
emacs-2ede38ce4bf336c573450c61a2e9a41fb7ebe1be.zip
* lisp/vc/smerge-mode.el (smerge-change-buffer-confirm): New var
(smerge-vc-next-conflict): Obey it. Save buffer before going to the next. Don't emit message when vc-find-conflicted-file can't find other conflicted file. * lisp/vc/vc-hooks.el: Use lexical-binding. * lisp/vc/vc.el: Remove redundant :groups. (vc-find-conflicted-file): Autoload.
-rw-r--r--lisp/vc/smerge-mode.el38
-rw-r--r--lisp/vc/vc-hooks.el20
-rw-r--r--lisp/vc/vc.el45
3 files changed, 55 insertions, 48 deletions
diff --git a/lisp/vc/smerge-mode.el b/lisp/vc/smerge-mode.el
index ffca78ba8a3..02cee44a3ae 100644
--- a/lisp/vc/smerge-mode.el
+++ b/lisp/vc/smerge-mode.el
@@ -1432,19 +1432,39 @@ If no conflict maker is found, turn off `smerge-mode'."
1432 (smerge-next)) 1432 (smerge-next))
1433 (error (smerge-auto-leave)))) 1433 (error (smerge-auto-leave))))
1434 1434
1435(require 'vc) 1435(defcustom smerge-change-buffer-confirm t
1436 "If non-nil, request confirmation before moving to another buffer."
1437 :type 'boolean)
1436 1438
1437(defun smerge-vc-next-conflict () 1439(defun smerge-vc-next-conflict ()
1438 "Tries to go to next conflict in current file, otherwise tries 1440 "Go to next conflict, possibly in another file.
1439to open next conflicted file version-control-system wise" 1441First tries to go to the next conflict in the current buffer, and if not
1442found, uses VC to try and find the next file with conflict."
1440 (interactive) 1443 (interactive)
1441 (let ((buffer (current-buffer))) 1444 (let ((buffer (current-buffer)))
1442 (when (not (smerge-goto-next-conflict)) 1445 (condition-case nil
1443 (vc-find-conflicted-file) 1446 ;; FIXME: Try again from BOB before moving to the next file.
1444 (if (eq buffer (current-buffer)) 1447 (smerge-next)
1445 (message "No conflicts found") 1448 (error
1446 (goto-char 0) 1449 (if (and (or smerge-change-buffer-confirm
1447 (smerge-goto-next-conflict))))) 1450 (and (buffer-modified-p) buffer-file-name))
1451 (not (or (eq last-command this-command)
1452 (eq ?\r last-command-event)))) ;Called via M-x!?
1453 ;; FIXME: Don't emit this message if `vc-find-conflicted-file' won't
1454 ;; go to another file anyway (because there are no more conflicted
1455 ;; files).
1456 (message (if (buffer-modified-p)
1457 "No more conflicts here. Repeat to save and go to next buffer"
1458 "No more conflicts here. Repeat to go to next buffer"))
1459 (if (and (buffer-modified-p) buffer-file-name)
1460 (save-buffer))
1461 (vc-find-conflicted-file)
1462 (if (eq buffer (current-buffer))
1463 ;; Do nothing: presumably `vc-find-conflicted-file' already
1464 ;; emitted a message explaining there aren't any more conflicts.
1465 nil
1466 (goto-char (point-min))
1467 (smerge-next)))))))
1448 1468
1449(provide 'smerge-mode) 1469(provide 'smerge-mode)
1450 1470
diff --git a/lisp/vc/vc-hooks.el b/lisp/vc/vc-hooks.el
index 42622818fce..7dd7346fe8f 100644
--- a/lisp/vc/vc-hooks.el
+++ b/lisp/vc/vc-hooks.el
@@ -1,4 +1,4 @@
1;;; vc-hooks.el --- resident support for version-control 1;;; vc-hooks.el --- resident support for version-control -*- lexical-binding:t -*-
2 2
3;; Copyright (C) 1992-1996, 1998-2019 Free Software Foundation, Inc. 3;; Copyright (C) 1992-1996, 1998-2019 Free Software Foundation, Inc.
4 4
@@ -173,9 +173,9 @@ Otherwise, not displayed."
173(make-variable-buffer-local 'vc-mode) 173(make-variable-buffer-local 'vc-mode)
174(put 'vc-mode 'permanent-local t) 174(put 'vc-mode 'permanent-local t)
175 175
176;;; We signal this error when we try to do something a VC backend 176;; We signal this error when we try to do something a VC backend
177;;; doesn't support. Two arguments: the method that's not supported 177;; doesn't support. Two arguments: the method that's not supported
178;;; and the backend 178;; and the backend
179(define-error 'vc-not-supported "VC method not implemented for backend") 179(define-error 'vc-not-supported "VC method not implemented for backend")
180 180
181(defun vc-mode (&optional _arg) 181(defun vc-mode (&optional _arg)
@@ -243,12 +243,12 @@ if that doesn't exist either, return nil."
243 "Call for BACKEND the implementation of FUNCTION-NAME with the given ARGS. 243 "Call for BACKEND the implementation of FUNCTION-NAME with the given ARGS.
244Calls 244Calls
245 245
246 (apply \\='vc-BACKEND-FUN ARGS) 246 (apply #\\='vc-BACKEND-FUN ARGS)
247 247
248if vc-BACKEND-FUN exists (after trying to find it in vc-BACKEND.el) 248if vc-BACKEND-FUN exists (after trying to find it in vc-BACKEND.el)
249and else calls 249and else calls
250 250
251 (apply \\='vc-default-FUN BACKEND ARGS) 251 (apply #\\='vc-default-FUN BACKEND ARGS)
252 252
253It is usually called via the `vc-call' macro." 253It is usually called via the `vc-call' macro."
254 (let ((f (assoc function-name (get backend 'vc-functions)))) 254 (let ((f (assoc function-name (get backend 'vc-functions))))
@@ -603,7 +603,7 @@ a regexp for matching all such backup files, regardless of the version."
603 "Delete all existing automatic version backups for FILE." 603 "Delete all existing automatic version backups for FILE."
604 (condition-case nil 604 (condition-case nil
605 (mapc 605 (mapc
606 'delete-file 606 #'delete-file
607 (directory-files (or (file-name-directory file) default-directory) t 607 (directory-files (or (file-name-directory file) default-directory) t
608 (vc-version-backup-file-name file nil nil t))) 608 (vc-version-backup-file-name file nil nil t)))
609 ;; Don't fail when the directory doesn't exist. 609 ;; Don't fail when the directory doesn't exist.
@@ -811,7 +811,7 @@ In the latter case, VC mode is deactivated for this buffer."
811 (when buffer-file-name 811 (when buffer-file-name
812 (vc-file-clearprops buffer-file-name) 812 (vc-file-clearprops buffer-file-name)
813 ;; FIXME: Why use a hook? Why pass it buffer-file-name? 813 ;; FIXME: Why use a hook? Why pass it buffer-file-name?
814 (add-hook 'vc-mode-line-hook 'vc-mode-line nil t) 814 (add-hook 'vc-mode-line-hook #'vc-mode-line nil t)
815 (let (backend) 815 (let (backend)
816 (cond 816 (cond
817 ((setq backend (with-demoted-errors (vc-backend buffer-file-name))) 817 ((setq backend (with-demoted-errors (vc-backend buffer-file-name)))
@@ -862,13 +862,13 @@ In the latter case, VC mode is deactivated for this buffer."
862 ))))))))) 862 )))))))))
863 863
864(add-hook 'find-file-hook #'vc-refresh-state) 864(add-hook 'find-file-hook #'vc-refresh-state)
865(define-obsolete-function-alias 'vc-find-file-hook 'vc-refresh-state "25.1") 865(define-obsolete-function-alias 'vc-find-file-hook #'vc-refresh-state "25.1")
866 866
867(defun vc-kill-buffer-hook () 867(defun vc-kill-buffer-hook ()
868 "Discard VC info about a file when we kill its buffer." 868 "Discard VC info about a file when we kill its buffer."
869 (when buffer-file-name (vc-file-clearprops buffer-file-name))) 869 (when buffer-file-name (vc-file-clearprops buffer-file-name)))
870 870
871(add-hook 'kill-buffer-hook 'vc-kill-buffer-hook) 871(add-hook 'kill-buffer-hook #'vc-kill-buffer-hook)
872 872
873;; Now arrange for (autoloaded) bindings of the main package. 873;; Now arrange for (autoloaded) bindings of the main package.
874;; Bindings for this have to go in the global map, as we'll often 874;; Bindings for this have to go in the global map, as we'll often
diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el
index a5c866d7503..aae21ec45a4 100644
--- a/lisp/vc/vc.el
+++ b/lisp/vc/vc.el
@@ -736,8 +736,7 @@ These are passed to the checkin program by \\[vc-checkin]."
736 (string :tag "Argument String") 736 (string :tag "Argument String")
737 (repeat :tag "Argument List" 737 (repeat :tag "Argument List"
738 :value ("") 738 :value ("")
739 string)) 739 string)))
740 :group 'vc)
741 740
742(defcustom vc-checkout-switches nil 741(defcustom vc-checkout-switches nil
743 "A string or list of strings specifying extra switches for checkout. 742 "A string or list of strings specifying extra switches for checkout.
@@ -746,8 +745,7 @@ These are passed to the checkout program by \\[vc-checkout]."
746 (string :tag "Argument String") 745 (string :tag "Argument String")
747 (repeat :tag "Argument List" 746 (repeat :tag "Argument List"
748 :value ("") 747 :value ("")
749 string)) 748 string)))
750 :group 'vc)
751 749
752(defcustom vc-register-switches nil 750(defcustom vc-register-switches nil
753 "A string or list of strings; extra switches for registering a file. 751 "A string or list of strings; extra switches for registering a file.
@@ -756,8 +754,7 @@ These are passed to the checkin program by \\[vc-register]."
756 (string :tag "Argument String") 754 (string :tag "Argument String")
757 (repeat :tag "Argument List" 755 (repeat :tag "Argument List"
758 :value ("") 756 :value ("")
759 string)) 757 string)))
760 :group 'vc)
761 758
762(defcustom vc-diff-switches nil 759(defcustom vc-diff-switches nil
763 "A string or list of strings specifying switches for diff under VC. 760 "A string or list of strings specifying switches for diff under VC.
@@ -772,7 +769,6 @@ not specific to any particular backend."
772 (const :tag "None" t) 769 (const :tag "None" t)
773 (string :tag "Argument String") 770 (string :tag "Argument String")
774 (repeat :tag "Argument List" :value ("") string)) 771 (repeat :tag "Argument List" :value ("") string))
775 :group 'vc
776 :version "21.1") 772 :version "21.1")
777 773
778(defcustom vc-annotate-switches nil 774(defcustom vc-annotate-switches nil
@@ -792,15 +788,13 @@ for the backend you use."
792 (const :tag "None" t) 788 (const :tag "None" t)
793 (string :tag "Argument String") 789 (string :tag "Argument String")
794 (repeat :tag "Argument List" :value ("") string)) 790 (repeat :tag "Argument List" :value ("") string))
795 :group 'vc
796 :version "25.1") 791 :version "25.1")
797 792
798(defcustom vc-log-show-limit 2000 793(defcustom vc-log-show-limit 2000
799 "Limit the number of items shown by the VC log commands. 794 "Limit the number of items shown by the VC log commands.
800Zero means unlimited. 795Zero means unlimited.
801Not all VC backends are able to support this feature." 796Not all VC backends are able to support this feature."
802 :type 'integer 797 :type 'integer)
803 :group 'vc)
804 798
805(defcustom vc-allow-async-revert nil 799(defcustom vc-allow-async-revert nil
806 "Specifies whether the diff during \\[vc-revert] may be asynchronous. 800 "Specifies whether the diff during \\[vc-revert] may be asynchronous.
@@ -808,7 +802,6 @@ Enabling this option means that you can confirm a revert operation even
808if the local changes in the file have not been found and displayed yet." 802if the local changes in the file have not been found and displayed yet."
809 :type '(choice (const :tag "No" nil) 803 :type '(choice (const :tag "No" nil)
810 (const :tag "Yes" t)) 804 (const :tag "Yes" t))
811 :group 'vc
812 :version "22.1") 805 :version "22.1")
813 806
814;;;###autoload 807;;;###autoload
@@ -816,7 +809,6 @@ if the local changes in the file have not been found and displayed yet."
816 "Normal hook (list of functions) run after checking out a file. 809 "Normal hook (list of functions) run after checking out a file.
817See `run-hooks'." 810See `run-hooks'."
818 :type 'hook 811 :type 'hook
819 :group 'vc
820 :version "21.1") 812 :version "21.1")
821 813
822;;;###autoload 814;;;###autoload
@@ -824,26 +816,22 @@ See `run-hooks'."
824 "Normal hook (list of functions) run after commit or file checkin. 816 "Normal hook (list of functions) run after commit or file checkin.
825See also `log-edit-done-hook'." 817See also `log-edit-done-hook'."
826 :type 'hook 818 :type 'hook
827 :options '(log-edit-comment-to-change-log) 819 :options '(log-edit-comment-to-change-log))
828 :group 'vc)
829 820
830;;;###autoload 821;;;###autoload
831(defcustom vc-before-checkin-hook nil 822(defcustom vc-before-checkin-hook nil
832 "Normal hook (list of functions) run before a commit or a file checkin. 823 "Normal hook (list of functions) run before a commit or a file checkin.
833See `run-hooks'." 824See `run-hooks'."
834 :type 'hook 825 :type 'hook)
835 :group 'vc)
836 826
837(defcustom vc-retrieve-tag-hook nil 827(defcustom vc-retrieve-tag-hook nil
838 "Normal hook (list of functions) run after retrieving a tag." 828 "Normal hook (list of functions) run after retrieving a tag."
839 :type 'hook 829 :type 'hook
840 :group 'vc
841 :version "27.1") 830 :version "27.1")
842 831
843(defcustom vc-revert-show-diff t 832(defcustom vc-revert-show-diff t
844 "If non-nil, `vc-revert' shows a `vc-diff' buffer before querying." 833 "If non-nil, `vc-revert' shows a `vc-diff' buffer before querying."
845 :type 'boolean 834 :type 'boolean
846 :group 'vc
847 :version "24.1") 835 :version "24.1")
848 836
849;; Header-insertion hair 837;; Header-insertion hair
@@ -856,8 +844,7 @@ A %s in the template is replaced with the first string associated with
856the file's version control type in `vc-BACKEND-header'." 844the file's version control type in `vc-BACKEND-header'."
857 :type '(repeat (cons :format "%v" 845 :type '(repeat (cons :format "%v"
858 (regexp :tag "File Type") 846 (regexp :tag "File Type")
859 (string :tag "Header String"))) 847 (string :tag "Header String"))))
860 :group 'vc)
861 848
862(defcustom vc-comment-alist 849(defcustom vc-comment-alist
863 '((nroff-mode ".\\\"" "")) 850 '((nroff-mode ".\\\"" ""))
@@ -868,13 +855,11 @@ is sensitive to blank lines."
868 :type '(repeat (list :format "%v" 855 :type '(repeat (list :format "%v"
869 (symbol :tag "Mode") 856 (symbol :tag "Mode")
870 (string :tag "Comment Start") 857 (string :tag "Comment Start")
871 (string :tag "Comment End"))) 858 (string :tag "Comment End"))))
872 :group 'vc)
873 859
874(defcustom vc-find-revision-no-save nil 860(defcustom vc-find-revision-no-save nil
875 "If non-nil, `vc-find-revision' doesn't write the created buffer to file." 861 "If non-nil, `vc-find-revision' doesn't write the created buffer to file."
876 :type 'boolean 862 :type 'boolean
877 :group 'vc
878 :version "27.1") 863 :version "27.1")
879 864
880 865
@@ -940,7 +925,7 @@ use."
940 ;; 'create-repo method. 925 ;; 'create-repo method.
941 (completing-read 926 (completing-read
942 (format "%s is not in a version controlled directory.\nUse VC backend: " file) 927 (format "%s is not in a version controlled directory.\nUse VC backend: " file)
943 (mapcar 'symbol-name possible-backends) nil t))) 928 (mapcar #'symbol-name possible-backends) nil t)))
944 (repo-dir 929 (repo-dir
945 (let ((def-dir (file-name-directory file))) 930 (let ((def-dir (file-name-directory file)))
946 ;; read the directory where to create the 931 ;; read the directory where to create the
@@ -1109,7 +1094,7 @@ BEWARE: this function may change the current buffer."
1109 1094
1110(defun vc-read-backend (prompt) 1095(defun vc-read-backend (prompt)
1111 (intern 1096 (intern
1112 (completing-read prompt (mapcar 'symbol-name vc-handled-backends) 1097 (completing-read prompt (mapcar #'symbol-name vc-handled-backends)
1113 nil 'require-match))) 1098 nil 'require-match)))
1114 1099
1115;; Here's the major entry point. 1100;; Here's the major entry point.
@@ -1367,7 +1352,7 @@ first backend that could register the file is used."
1367 (set-buffer-modified-p t)) 1352 (set-buffer-modified-p t))
1368 (vc-buffer-sync))))) 1353 (vc-buffer-sync)))))
1369 (message "Registering %s... " files) 1354 (message "Registering %s... " files)
1370 (mapc 'vc-file-clearprops files) 1355 (mapc #'vc-file-clearprops files)
1371 (vc-call-backend backend 'register files comment) 1356 (vc-call-backend backend 'register files comment)
1372 (mapc 1357 (mapc
1373 (lambda (file) 1358 (lambda (file)
@@ -1569,7 +1554,7 @@ Runs the normal hooks `vc-before-checkin-hook' and `vc-checkin-hook'."
1569 ;; not a well-defined concept for filesets. 1554 ;; not a well-defined concept for filesets.
1570 (progn 1555 (progn
1571 (vc-call-backend backend 'checkin files comment rev) 1556 (vc-call-backend backend 'checkin files comment rev)
1572 (mapc 'vc-delete-automatic-version-backups files)) 1557 (mapc #'vc-delete-automatic-version-backups files))
1573 `((vc-state . up-to-date) 1558 `((vc-state . up-to-date)
1574 (vc-checkout-time . ,(file-attribute-modification-time 1559 (vc-checkout-time . ,(file-attribute-modification-time
1575 (file-attributes file))) 1560 (file-attributes file)))
@@ -1727,7 +1712,7 @@ Return t if the buffer had changes, nil otherwise."
1727 (error "No revisions of %s exist" file) 1712 (error "No revisions of %s exist" file)
1728 ;; We regard this as "changed". 1713 ;; We regard this as "changed".
1729 ;; Diff it against /dev/null. 1714 ;; Diff it against /dev/null.
1730 (apply 'vc-do-command buffer 1715 (apply #'vc-do-command buffer
1731 (if async 'async 1) "diff" file 1716 (if async 'async 1) "diff" file
1732 (append (vc-switches nil 'diff) '("/dev/null")))))) 1717 (append (vc-switches nil 'diff) '("/dev/null"))))))
1733 (setq files (nreverse filtered)))) 1718 (setq files (nreverse filtered))))
@@ -2172,6 +2157,7 @@ changes from the current branch."
2172;; `default-next-file' variable for its default file (M-n), and 2157;; `default-next-file' variable for its default file (M-n), and
2173;; we could then set it upon mark-resolve, so C-x C-s C-x C-f M-n would 2158;; we could then set it upon mark-resolve, so C-x C-s C-x C-f M-n would
2174;; automatically offer the next conflicted file. 2159;; automatically offer the next conflicted file.
2160;;;###autoload
2175(defun vc-find-conflicted-file () 2161(defun vc-find-conflicted-file ()
2176 "Visit the next conflicted file in the current project." 2162 "Visit the next conflicted file in the current project."
2177 (interactive) 2163 (interactive)
@@ -2772,7 +2758,8 @@ If called interactively, read FILE, defaulting to the current
2772buffer's file name if it's under version control." 2758buffer's file name if it's under version control."
2773 (interactive (list (read-file-name "VC delete file: " nil 2759 (interactive (list (read-file-name "VC delete file: " nil
2774 (when (vc-backend buffer-file-name) 2760 (when (vc-backend buffer-file-name)
2775 buffer-file-name) t))) 2761 buffer-file-name)
2762 t)))
2776 (setq file (expand-file-name file)) 2763 (setq file (expand-file-name file))
2777 (let ((buf (get-file-buffer file)) 2764 (let ((buf (get-file-buffer file))
2778 (backend (vc-backend file))) 2765 (backend (vc-backend file)))