diff options
| author | Glenn Morris | 2019-12-27 07:50:16 -0800 |
|---|---|---|
| committer | Glenn Morris | 2019-12-27 07:50:16 -0800 |
| commit | 01a0e17c8015a91aef17ef52eefb788c60477a4f (patch) | |
| tree | a5449c4a24fabbcb4dd8f08add663b0b78ad6ae7 | |
| parent | 7808453387c93a18fbfa2e6ea9e4413a8e949323 (diff) | |
| parent | 3f2788d4acd53fbb3e3b9106530169643fa8948c (diff) | |
| download | emacs-01a0e17c8015a91aef17ef52eefb788c60477a4f.tar.gz emacs-01a0e17c8015a91aef17ef52eefb788c60477a4f.zip | |
Merge from origin/emacs-27
3f2788d4ac (origin/emacs-27) project--vc-list-files: Recurse into sub...
f0da3aa83e Merge branch 'emacs-27' of git.savannah.gnu.org:/srv/git/e...
3b199614cc Minor improvements of buffer documentation
e1e0a7a751 xref--collect-matches: Speed up on remote
219b91eb2c ; project--find-regexp-in-files: Avoid prepending remote-i...
| -rw-r--r-- | doc/emacs/buffers.texi | 4 | ||||
| -rw-r--r-- | lisp/progmodes/project.el | 53 | ||||
| -rw-r--r-- | lisp/progmodes/xref.el | 7 |
3 files changed, 53 insertions, 11 deletions
diff --git a/doc/emacs/buffers.texi b/doc/emacs/buffers.texi index 7b4e070d1b9..fc2ee6f638d 100644 --- a/doc/emacs/buffers.texi +++ b/doc/emacs/buffers.texi | |||
| @@ -13,6 +13,10 @@ the directory listing. If you send a message with @kbd{C-x m}, a | |||
| 13 | buffer is used to hold the text of the message. When you ask for a | 13 | buffer is used to hold the text of the message. When you ask for a |
| 14 | command's documentation, that appears in a buffer named @file{*Help*}. | 14 | command's documentation, that appears in a buffer named @file{*Help*}. |
| 15 | 15 | ||
| 16 | Buffers exist as long as they are in use, and are deleted | ||
| 17 | (``killed'') when no longer needed, either by you (@pxref{Kill | ||
| 18 | Buffer}) or by Emacs (e.g., when you exit Emacs, @pxref{Exiting}). | ||
| 19 | |||
| 16 | Each buffer has a unique name, which can be of any length. When a | 20 | Each buffer has a unique name, which can be of any length. When a |
| 17 | buffer is displayed in a window, its name is shown in the mode line | 21 | buffer is displayed in a window, its name is shown in the mode line |
| 18 | (@pxref{Mode Line}). The distinction between upper and lower case | 22 | (@pxref{Mode Line}). The distinction between upper and lower case |
diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el index e21600ffe09..74c2bf91c41 100644 --- a/lisp/progmodes/project.el +++ b/lisp/progmodes/project.el | |||
| @@ -262,8 +262,15 @@ backend implementation of `project-external-roots'.") | |||
| 262 | 262 | ||
| 263 | (defun project-try-vc (dir) | 263 | (defun project-try-vc (dir) |
| 264 | (let* ((backend (ignore-errors (vc-responsible-backend dir))) | 264 | (let* ((backend (ignore-errors (vc-responsible-backend dir))) |
| 265 | (root (and backend (ignore-errors | 265 | (root |
| 266 | (vc-call-backend backend 'root dir))))) | 266 | (pcase backend |
| 267 | ('Git | ||
| 268 | ;; Don't stop at submodule boundary. | ||
| 269 | (or (vc-file-getprop dir 'project-git-root) | ||
| 270 | (vc-file-setprop dir 'project-git-root | ||
| 271 | (vc-find-root dir ".git/")))) | ||
| 272 | ('nil nil) | ||
| 273 | (_ (ignore-errors (vc-call-backend backend 'root dir)))))) | ||
| 267 | (and root (cons 'vc root)))) | 274 | (and root (cons 'vc root)))) |
| 268 | 275 | ||
| 269 | (cl-defmethod project-roots ((project (head vc))) | 276 | (cl-defmethod project-roots ((project (head vc))) |
| @@ -303,7 +310,8 @@ backend implementation of `project-external-roots'.") | |||
| 303 | (pcase backend | 310 | (pcase backend |
| 304 | (`Git | 311 | (`Git |
| 305 | (let ((default-directory (expand-file-name (file-name-as-directory dir))) | 312 | (let ((default-directory (expand-file-name (file-name-as-directory dir))) |
| 306 | (args '("-z"))) | 313 | (args '("-z")) |
| 314 | files) | ||
| 307 | ;; Include unregistered. | 315 | ;; Include unregistered. |
| 308 | (setq args (append args '("-c" "-o" "--exclude-standard"))) | 316 | (setq args (append args '("-c" "-o" "--exclude-standard"))) |
| 309 | (when extra-ignores | 317 | (when extra-ignores |
| @@ -315,11 +323,26 @@ backend implementation of `project-external-roots'.") | |||
| 315 | (format ":!/:%s" (substring i 2)) | 323 | (format ":!/:%s" (substring i 2)) |
| 316 | (format ":!:%s" i))) | 324 | (format ":!:%s" i))) |
| 317 | extra-ignores))))) | 325 | extra-ignores))))) |
| 318 | (mapcar | 326 | (setq files |
| 319 | (lambda (file) (concat default-directory file)) | 327 | (mapcar |
| 320 | (split-string | 328 | (lambda (file) (concat default-directory file)) |
| 321 | (apply #'vc-git--run-command-string nil "ls-files" args) | 329 | (split-string |
| 322 | "\0" t)))) | 330 | (apply #'vc-git--run-command-string nil "ls-files" args) |
| 331 | "\0" t))) | ||
| 332 | ;; Unfortunately, 'ls-files --recurse-submodules' conflicts with '-o'. | ||
| 333 | (let* ((submodules (project--git-submodules)) | ||
| 334 | (sub-files | ||
| 335 | (mapcar | ||
| 336 | (lambda (module) | ||
| 337 | (when (file-directory-p module) | ||
| 338 | (project--vc-list-files | ||
| 339 | (concat default-directory module) | ||
| 340 | backend | ||
| 341 | extra-ignores))) | ||
| 342 | submodules))) | ||
| 343 | (setq files | ||
| 344 | (apply #'nconc files sub-files))) | ||
| 345 | files)) | ||
| 323 | (`Hg | 346 | (`Hg |
| 324 | (let ((default-directory (expand-file-name (file-name-as-directory dir))) | 347 | (let ((default-directory (expand-file-name (file-name-as-directory dir))) |
| 325 | args) | 348 | args) |
| @@ -337,6 +360,18 @@ backend implementation of `project-external-roots'.") | |||
| 337 | (lambda (s) (concat default-directory s)) | 360 | (lambda (s) (concat default-directory s)) |
| 338 | (split-string (buffer-string) "\0" t))))))) | 361 | (split-string (buffer-string) "\0" t))))))) |
| 339 | 362 | ||
| 363 | (defun project--git-submodules () | ||
| 364 | ;; 'git submodule foreach' is much slower. | ||
| 365 | (condition-case nil | ||
| 366 | (with-temp-buffer | ||
| 367 | (insert-file-contents ".gitmodules") | ||
| 368 | (let (res) | ||
| 369 | (goto-char (point-min)) | ||
| 370 | (while (re-search-forward "path *= *\\(.+\\)" nil t) | ||
| 371 | (push (match-string 1) res)) | ||
| 372 | (nreverse res))) | ||
| 373 | (file-missing nil))) | ||
| 374 | |||
| 340 | (cl-defmethod project-ignores ((project (head vc)) dir) | 375 | (cl-defmethod project-ignores ((project (head vc)) dir) |
| 341 | (let* ((root (cdr project)) | 376 | (let* ((root (cdr project)) |
| 342 | backend) | 377 | backend) |
| @@ -485,7 +520,7 @@ pattern to search for." | |||
| 485 | (buffer-substring (point-min) (line-end-position)))) | 520 | (buffer-substring (point-min) (line-end-position)))) |
| 486 | (while (re-search-forward grep-re nil t) | 521 | (while (re-search-forward grep-re nil t) |
| 487 | (push (list (string-to-number (match-string line-group)) | 522 | (push (list (string-to-number (match-string line-group)) |
| 488 | (concat remote-id (match-string file-group)) | 523 | (match-string file-group) |
| 489 | (buffer-substring-no-properties (point) (line-end-position))) | 524 | (buffer-substring-no-properties (point) (line-end-position))) |
| 490 | hits))) | 525 | hits))) |
| 491 | (setq xrefs (xref--convert-hits (nreverse hits) regexp)) | 526 | (setq xrefs (xref--convert-hits (nreverse hits) regexp)) |
diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el index 13a1600594f..bbd3940be4f 100644 --- a/lisp/progmodes/xref.el +++ b/lisp/progmodes/xref.el | |||
| @@ -1291,8 +1291,11 @@ Such as the current syntax table and the applied syntax properties." | |||
| 1291 | 1291 | ||
| 1292 | (defun xref--collect-matches (hit regexp tmp-buffer) | 1292 | (defun xref--collect-matches (hit regexp tmp-buffer) |
| 1293 | (pcase-let* ((`(,line ,file ,text) hit) | 1293 | (pcase-let* ((`(,line ,file ,text) hit) |
| 1294 | (file (and file (concat (file-remote-p default-directory) file))) | 1294 | (remote-id (file-remote-p default-directory)) |
| 1295 | (buf (xref--find-buffer-visiting file)) | 1295 | (file (and file (concat remote-id file))) |
| 1296 | (buf (unless remote-id | ||
| 1297 | ;; find-buffer-visiting is slow on remote. | ||
| 1298 | (xref--find-buffer-visiting file))) | ||
| 1296 | (syntax-needed (xref--regexp-syntax-dependent-p regexp))) | 1299 | (syntax-needed (xref--regexp-syntax-dependent-p regexp))) |
| 1297 | (if buf | 1300 | (if buf |
| 1298 | (with-current-buffer buf | 1301 | (with-current-buffer buf |