aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2014-11-05 14:59:31 -0500
committerStefan Monnier2014-11-05 14:59:31 -0500
commit8b86268b69acdb63697dbcb9def2582fa1be517f (patch)
tree65f49fa405eb34be68b6b484bb245ee72a3fcd2d
parentcde44c6ff52c33100595834ccbd1f27a55f5769d (diff)
downloademacs-8b86268b69acdb63697dbcb9def2582fa1be517f.tar.gz
emacs-8b86268b69acdb63697dbcb9def2582fa1be517f.zip
* lisp/vc/vc.el (vc-region-history): New command.
(vc-print-log-internal): Use cl-some. * lisp/vc/vc-git.el (vc-git-region-history): New function. (vc-git-region-history-mode-map) (vc-git--log-view-long-font-lock-keywords) (vc-git-region-history-font-lock-keywords): New vars. (vc-git-region-history-font-lock): New function. (vc-git-region-history-mode): New major mode.
-rw-r--r--etc/NEWS2
-rw-r--r--lisp/ChangeLog18
-rw-r--r--lisp/vc/vc-git.el48
-rw-r--r--lisp/vc/vc.el57
4 files changed, 106 insertions, 19 deletions
diff --git a/etc/NEWS b/etc/NEWS
index 6dcf64bede3..68ad5c00c8f 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -125,6 +125,8 @@ Unicode standards.
125 125
126* Changes in Specialized Modes and Packages in Emacs 25.1 126* Changes in Specialized Modes and Packages in Emacs 25.1
127 127
128** VC
129*** The new command vc-region-history shows the log+diff of the active region.
128** Calc 130** Calc
129+++ 131+++
130*** If `quick-calc' is called with a prefix argument, insert the 132*** If `quick-calc' is called with a prefix argument, insert the
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 9b8cf9793cd..a0108305ac3 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,15 @@
12014-11-05 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * vc/vc.el (vc-region-history): New command.
4 (vc-print-log-internal): Use cl-some.
5
6 * vc/vc-git.el (vc-git-region-history): New function.
7 (vc-git-region-history-mode-map)
8 (vc-git--log-view-long-font-lock-keywords)
9 (vc-git-region-history-font-lock-keywords): New vars.
10 (vc-git-region-history-font-lock): New function.
11 (vc-git-region-history-mode): New major mode.
12
12014-11-05 Tassilo Horn <tsdh@gnu.org> 132014-11-05 Tassilo Horn <tsdh@gnu.org>
2 14
3 * net/eww.el (subr-x): Require subr-x at compile-time because eww 15 * net/eww.el (subr-x): Require subr-x at compile-time because eww
@@ -23,9 +35,9 @@
23 35
242014-11-05 Michael Albinus <michael.albinus@gmx.de> 362014-11-05 Michael Albinus <michael.albinus@gmx.de>
25 37
26 * net/tramp-sh.el (tramp-do-copy-or-rename-file-via-buffer): Don't use 38 * net/tramp-sh.el (tramp-do-copy-or-rename-file-via-buffer): Don't use
27 a local copy; setting `inhibit-file-name-handlers' proper might be 39 a local copy; setting `inhibit-file-name-handlers' proper might be
28 more performant. (Bug#18751) 40 more performant. (Bug#18751)
29 41
302014-11-05 Glenn Morris <rgm@gnu.org> 422014-11-05 Glenn Morris <rgm@gnu.org>
31 43
diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el
index afcfd666082..5d7c0ef5c7b 100644
--- a/lisp/vc/vc-git.el
+++ b/lisp/vc/vc-git.el
@@ -869,6 +869,52 @@ If LIMIT is non-nil, show no more than this many entries."
869 "@{upstream}" 869 "@{upstream}"
870 remote-location)))) 870 remote-location))))
871 871
872(defun vc-git-region-history (file buffer lfrom lto)
873 (vc-git-command buffer 'async nil "log" "-p" ;"--follow" ;FIXME: not supported?
874 (format "-L%d,%d:%s" lfrom lto (file-relative-name file))))
875
876(require 'diff-mode)
877
878(defvar vc-git-region-history-mode-map
879 (let ((map (make-composed-keymap
880 nil (make-composed-keymap
881 (list diff-mode-map vc-git-log-view-mode-map)))))
882 map))
883
884(defvar vc-git--log-view-long-font-lock-keywords nil)
885(defvar font-lock-keywords)
886(defvar vc-git-region-history-font-lock-keywords
887 `((vc-git-region-history-font-lock)))
888
889(defun vc-git-region-history-font-lock (limit)
890 (let ((in-diff (save-excursion
891 (beginning-of-line)
892 (or (looking-at "^\\(?:diff\\|commit\\)\\>")
893 (re-search-backward "^\\(?:diff\\|commit\\)\\>" nil t))
894 (eq ?d (char-after (match-beginning 0))))))
895 (while
896 (let ((end (save-excursion
897 (if (re-search-forward "\n\\(diff\\|commit\\)\\>"
898 limit t)
899 (match-beginning 1)
900 limit))))
901 (let ((font-lock-keywords (if in-diff diff-font-lock-keywords
902 vc-git--log-view-long-font-lock-keywords)))
903 (font-lock-fontify-keywords-region (point) end))
904 (goto-char end)
905 (prog1 (< (point) limit)
906 (setq in-diff (eq ?d (char-after))))))
907 nil))
908
909(define-derived-mode vc-git-region-history-mode
910 vc-git-log-view-mode "Git-Region-History"
911 "Major mode to browse Git's \"log -p\" output."
912 (setq-local vc-git--log-view-long-font-lock-keywords
913 log-view-font-lock-keywords)
914 (setq-local font-lock-defaults
915 (cons 'vc-git-region-history-font-lock-keywords
916 (cdr font-lock-defaults))))
917
872(defvar log-view-message-re) 918(defvar log-view-message-re)
873(defvar log-view-file-re) 919(defvar log-view-file-re)
874(defvar log-view-font-lock-keywords) 920(defvar log-view-font-lock-keywords)
@@ -884,7 +930,7 @@ If LIMIT is non-nil, show no more than this many entries."
884 (if (not (eq vc-log-view-type 'long)) 930 (if (not (eq vc-log-view-type 'long))
885 (cadr vc-git-root-log-format) 931 (cadr vc-git-root-log-format)
886 "^commit *\\([0-9a-z]+\\)")) 932 "^commit *\\([0-9a-z]+\\)"))
887 ;; Allow expanding short log entries 933 ;; Allow expanding short log entries.
888 (when (eq vc-log-view-type 'short) 934 (when (eq vc-log-view-type 'short)
889 (setq truncate-lines t) 935 (setq truncate-lines t)
890 (set (make-local-variable 'log-view-expanded-log-entry-function) 936 (set (make-local-variable 'log-view-expanded-log-entry-function)
diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el
index 5491d67e700..b2cb4470da1 100644
--- a/lisp/vc/vc.el
+++ b/lisp/vc/vc.el
@@ -1,4 +1,4 @@
1;;; vc.el --- drive a version-control system from within Emacs -*- lexical-binding: t -*- 1;;; vc.el --- drive a version-control system from within Emacs -*- lexical-binding:t -*-
2 2
3;; Copyright (C) 1992-1998, 2000-2014 Free Software Foundation, Inc. 3;; Copyright (C) 1992-1998, 2000-2014 Free Software Foundation, Inc.
4 4
@@ -458,6 +458,15 @@
458;; If the backend supports annotating through copies and renames, 458;; If the backend supports annotating through copies and renames,
459;; and displays a file name and a revision, then return a cons 459;; and displays a file name and a revision, then return a cons
460;; (REVISION . FILENAME). 460;; (REVISION . FILENAME).
461;;
462;; - region-history (FILE BUFFER LFROM LTO)
463;;
464;; Insert into BUFFER the history (log comments and diffs) of the content of
465;; FILE between lines LFROM and LTO. This is typically done asynchronously.
466;;
467;; - region-history-mode ()
468;;
469;; Major mode to use for the output of `region-history'.
461 470
462;; TAG SYSTEM 471;; TAG SYSTEM
463;; 472;;
@@ -673,6 +682,7 @@
673 682
674(require 'vc-hooks) 683(require 'vc-hooks)
675(require 'vc-dispatcher) 684(require 'vc-dispatcher)
685(require 'cl-lib)
676 686
677(declare-function diff-setup-whitespace "diff-mode" ()) 687(declare-function diff-setup-whitespace "diff-mode" ())
678 688
@@ -2227,19 +2237,11 @@ earlier revisions. Show up to LIMIT entries (non-nil means unlimited)."
2227 ;; Don't switch to the output buffer before running the command, 2237 ;; Don't switch to the output buffer before running the command,
2228 ;; so that any buffer-local settings in the vc-controlled 2238 ;; so that any buffer-local settings in the vc-controlled
2229 ;; buffer can be accessed by the command. 2239 ;; buffer can be accessed by the command.
2230 (let ((dir-present nil) 2240 (let* ((dir-present (cl-some #'file-directory-p files))
2231 (vc-short-log nil) 2241 (shortlog (not (null (memq (if dir-present 'directory 'file)
2242 vc-log-short-style))))
2232 (buffer-name "*vc-change-log*") 2243 (buffer-name "*vc-change-log*")
2233 type) 2244 (type (if shortlog 'short 'long)))
2234 (dolist (file files)
2235 (when (file-directory-p file)
2236 (setq dir-present t)))
2237 (setq vc-short-log
2238 (not (null (if dir-present
2239 (memq 'directory vc-log-short-style)
2240 (memq 'file vc-log-short-style)))))
2241 (setq type (if vc-short-log 'short 'long))
2242 (let ((shortlog vc-short-log))
2243 (vc-log-internal-common 2245 (vc-log-internal-common
2244 backend buffer-name files type 2246 backend buffer-name files type
2245 (lambda (bk buf _type-arg files-arg) 2247 (lambda (bk buf _type-arg files-arg)
@@ -2252,7 +2254,7 @@ earlier revisions. Show up to LIMIT entries (non-nil means unlimited)."
2252 (vc-call-backend bk 'show-log-entry working-revision)) 2254 (vc-call-backend bk 'show-log-entry working-revision))
2253 (lambda (_ignore-auto _noconfirm) 2255 (lambda (_ignore-auto _noconfirm)
2254 (vc-print-log-internal backend files working-revision 2256 (vc-print-log-internal backend files working-revision
2255 is-start-revision limit)))))) 2257 is-start-revision limit)))))
2256 2258
2257(defvar vc-log-view-type nil 2259(defvar vc-log-view-type nil
2258 "Set this to differentiate the different types of logs.") 2260 "Set this to differentiate the different types of logs.")
@@ -2271,7 +2273,6 @@ earlier revisions. Show up to LIMIT entries (non-nil means unlimited)."
2271 (with-current-buffer (get-buffer-create buffer-name) 2273 (with-current-buffer (get-buffer-create buffer-name)
2272 (set (make-local-variable 'vc-log-view-type) type)) 2274 (set (make-local-variable 'vc-log-view-type) type))
2273 (setq retval (funcall backend-func backend buffer-name type files)) 2275 (setq retval (funcall backend-func backend buffer-name type files))
2274 (pop-to-buffer buffer-name)
2275 (let ((inhibit-read-only t)) 2276 (let ((inhibit-read-only t))
2276 ;; log-view-mode used to be called with inhibit-read-only bound 2277 ;; log-view-mode used to be called with inhibit-read-only bound
2277 ;; to t, so let's keep doing it, just in case. 2278 ;; to t, so let's keep doing it, just in case.
@@ -2280,6 +2281,9 @@ earlier revisions. Show up to LIMIT entries (non-nil means unlimited)."
2280 (set (make-local-variable 'log-view-vc-fileset) files) 2281 (set (make-local-variable 'log-view-vc-fileset) files)
2281 (set (make-local-variable 'revert-buffer-function) 2282 (set (make-local-variable 'revert-buffer-function)
2282 rev-buff-func)) 2283 rev-buff-func))
2284 ;; Display after setting up major-mode, so display-buffer-alist can know
2285 ;; the major-mode.
2286 (pop-to-buffer buffer-name)
2283 (vc-run-delayed 2287 (vc-run-delayed
2284 (let ((inhibit-read-only t)) 2288 (let ((inhibit-read-only t))
2285 (funcall setup-buttons-func backend files retval) 2289 (funcall setup-buttons-func backend files retval)
@@ -2387,6 +2391,29 @@ When called interactively with a prefix argument, prompt for REMOTE-LOCATION."
2387 'log-outgoing))) 2391 'log-outgoing)))
2388 2392
2389;;;###autoload 2393;;;###autoload
2394(defun vc-region-history (from to)
2395 "Show the history of the region FROM..TO."
2396 (interactive "r")
2397 (let* ((lfrom (line-number-at-pos from))
2398 (lto (line-number-at-pos to))
2399 (file buffer-file-name)
2400 (backend (vc-backend file))
2401 (buf (get-buffer-create "*VC-history*")))
2402 (with-current-buffer buf
2403 (setq-local vc-log-view-type 'long))
2404 (vc-call region-history file buf lfrom lto)
2405 (with-current-buffer buf
2406 (vc-call-backend backend 'region-history-mode)
2407 (set (make-local-variable 'log-view-vc-backend) backend)
2408 (set (make-local-variable 'log-view-vc-fileset) file)
2409 (set (make-local-variable 'revert-buffer-function)
2410 (lambda (_ignore-auto _noconfirm)
2411 (with-current-buffer buf
2412 (let ((inhibit-read-only t)) (erase-buffer)))
2413 (vc-call region-history file buf lfrom lto))))
2414 (display-buffer buf)))
2415
2416;;;###autoload
2390(defun vc-revert () 2417(defun vc-revert ()
2391 "Revert working copies of the selected fileset to their repository contents. 2418 "Revert working copies of the selected fileset to their repository contents.
2392This asks for confirmation if the buffer contents are not identical 2419This asks for confirmation if the buffer contents are not identical