aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/progmodes
diff options
context:
space:
mode:
authorJohn Wiegley2016-01-11 22:51:27 -0800
committerJohn Wiegley2016-01-11 22:51:27 -0800
commitc7bef6a4f033fa6b22906de0be6da54958d5b3c3 (patch)
tree3a0f34b340ad01de290f068530c27f35aba83724 /lisp/progmodes
parentf5d90b5fcf0251466055c7dbed6069c1850d802d (diff)
parent1f6898d0510cd15455f665c0f38451755a374243 (diff)
downloademacs-c7bef6a4f033fa6b22906de0be6da54958d5b3c3.tar.gz
emacs-c7bef6a4f033fa6b22906de0be6da54958d5b3c3.zip
Merge from origin/emacs-25
1f6898d test/automated/vc-hg.el: Support out-of-tree build 3adb56e Minor change in tramp-tests.el 2b535ba ; * etc/NEWS: Update the js.el entry. 76b518c * etc/HELLO: Add Armenian and Mongolian greetings. b51f1ef Java Mode: Fontify identifiers in the presence of annotations. 36b9539 Avoid an infloop when we run out of memory 2006752 Avoid unnecessary failures of auto-saving after fatal error eef6784 Simplify HAVE_MODULES use in mark_maybe_pointer 552694a Revert attempt to use 'noexcept' in typedef 6ad0d39 Update documentation of 'indirect-function' c6a5314 ; * etc/NEWS: Move entry of 'inhibit-point-motion-hooks'. 303141a Update documentation for obsoleting 'syntax-begin-function' 4e6f61c ; * etc/NEWS: Mark documented and not-to-be-documented entries. e667bbb Document new features if Eshell 9c4e4e0 ; * etc/NEWS: Update EUDC entries. 1089dc9 Handle too long commands in Tramp 684eb58 * .gitattributes: *.cur and *.pif are binary files too. d2c7fda * src/alloc.c (mark_maybe_pointer): HAVE_MODULES may be undefined bd3f53d * sh-script.el (sh-smie-sh-rules): Improve indentation inside $(...) 09b2b8a * src/alloc.c (mark_maybe_pointer): Also check wide-int's emacs_value cca0f93 ; Account for spaces before the filename c71e1e8 Use short date for 'hg annotate', and output the author f50027b Spelling fix c7dff67 ; * etc/NEWS: Fix the Xref entries that got separated. cc140bc Document user-level functions in project.el f8208b6 Document the user-level features of the Xref package b131fb8 * loading.texi: Add `define-type' entry for load-history db3c2a8 Improve doc strings and prompts in xref.el f6117ef Allow the use of `font-lock-extend-region-multiline' in CC Mode. 90fd798 Fix coding system for Tramp on OS X. e985a0e ; * etc/NEWS: Mark the 'check-expensive' entry not to be documented. 9dfcbf0 Update 'load-history' docs 207e191 Fix (error ...) error 457738f Correctly analyze brace arguments in templated C++ function declarations. d57724a * lisp/cedet/mode-local.el (describe-function-orig-buffer): Declare. 2a9532d * lisp/ffap.el (ffap-latex-mode): Avoid free variable. 1a6b084 * lisp/play/dunnet.el (dun-fix-screen): Avoid `end-of-buffer`. 8be046f Respect fontification region calculated by major mode. Fixes bug #22316. 4b37cba Improve documentation of Delete Selection mode a034dd3 Fix two project-find-file issues 30abf29 Clarify doc string of 'dired-current-directory' e990bb2 Use the face of preceding text for displaying the ellipsis 5810ac3 Suppress Chinese file name test for OSX in tramp-tests.el eeb710a ; * lisp/startup.el: Sentences end with two spaces. 428b3de * admin/admin.el (set-version): Also handle the NEWS file. 648de81 ; Add NEWS entry for project.el 671862f apropos-library: Skip obvious duplicates; don't error on generics 51668a5 ; Grammar fix ed41d11 Add project-find-file and project-or-external-find-file 056da45 ; Improve commentary in 'setup_for_ellipsis' 269d008 ; Improve docstring for `inhibit-startup-echo-area-message'
Diffstat (limited to 'lisp/progmodes')
-rw-r--r--lisp/progmodes/cc-defs.el46
-rw-r--r--lisp/progmodes/cc-engine.el40
-rw-r--r--lisp/progmodes/cc-fonts.el11
-rw-r--r--lisp/progmodes/cc-langs.el13
-rw-r--r--lisp/progmodes/cc-mode.el11
-rw-r--r--lisp/progmodes/project.el67
-rw-r--r--lisp/progmodes/sh-script.el6
-rw-r--r--lisp/progmodes/xref.el65
8 files changed, 178 insertions, 81 deletions
diff --git a/lisp/progmodes/cc-defs.el b/lisp/progmodes/cc-defs.el
index c42fbe7e51f..2056f3907b8 100644
--- a/lisp/progmodes/cc-defs.el
+++ b/lisp/progmodes/cc-defs.el
@@ -656,23 +656,35 @@ right side of it."
656;; Wrappers for common scan-lists cases, mainly because it's almost 656;; Wrappers for common scan-lists cases, mainly because it's almost
657;; impossible to get a feel for how that function works. 657;; impossible to get a feel for how that function works.
658 658
659(defmacro c-go-list-forward () 659(defmacro c-go-list-forward (&optional pos limit)
660 "Move backward across one balanced group of parentheses. 660 "Move forward across one balanced group of parentheses starting at POS or
661 661point. Return POINT when we succeed, NIL when we fail. In the latter case,
662Return POINT when we succeed, NIL when we fail. In the latter case, leave 662leave point unmoved.
663point unmoved." 663
664 `(c-safe (let ((endpos (scan-lists (point) 1 0))) 664A LIMIT for the search may be given. The start position is assumed to be
665 (goto-char endpos) 665before it."
666 endpos))) 666 (let ((res `(c-safe (goto-char (scan-lists ,(or pos `(point)) 1 0)) (point))))
667 667 (if limit
668(defmacro c-go-list-backward () 668 `(save-restriction
669 "Move backward across one balanced group of parentheses. 669 (if ,limit
670 670 (narrow-to-region (point-min) ,limit))
671Return POINT when we succeed, NIL when we fail. In the latter case, leave 671 ,res)
672point unmoved." 672 res)))
673 `(c-safe (let ((endpos (scan-lists (point) -1 0))) 673
674 (goto-char endpos) 674(defmacro c-go-list-backward (&optional pos limit)
675 endpos))) 675 "Move backward across one balanced group of parentheses starting at POS or
676point. Return POINT when we succeed, NIL when we fail. In the latter case,
677leave point unmoved.
678
679A LIMIT for the search may be given. The start position is assumed to be
680after it."
681 (let ((res `(c-safe (goto-char (scan-lists ,(or pos `(point)) -1 0)) (point))))
682 (if limit
683 `(save-restriction
684 (if ,limit
685 (narrow-to-region ,limit (point-max)))
686 ,res)
687 res)))
676 688
677(defmacro c-up-list-forward (&optional pos limit) 689(defmacro c-up-list-forward (&optional pos limit)
678 "Return the first position after the list sexp containing POS, 690 "Return the first position after the list sexp containing POS,
diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el
index 3301d415923..b08c555e34f 100644
--- a/lisp/progmodes/cc-engine.el
+++ b/lisp/progmodes/cc-engine.el
@@ -5688,8 +5688,8 @@ comment at the start of cc-engine.el for more info."
5688 (c-backward-token-2) 5688 (c-backward-token-2)
5689 (setq c-restricted-<>-arglists 5689 (setq c-restricted-<>-arglists
5690 (and (not (looking-at c-opt-<>-sexp-key)) 5690 (and (not (looking-at c-opt-<>-sexp-key))
5691 (progn (c-backward-syntactic-ws) ; to < or , 5691 (progn (c-backward-syntactic-ws) ; to ( or ,
5692 (and (memq (char-before) '(?< ?,)) 5692 (and (memq (char-before) '(?\( ?,)) ; what about <?
5693 (not (eq (c-get-char-property (point) 'c-type) 5693 (not (eq (c-get-char-property (point) 'c-type)
5694 'c-decl-arg-start))))))) 5694 'c-decl-arg-start)))))))
5695 (or (c-forward-<>-arglist nil) 5695 (or (c-forward-<>-arglist nil)
@@ -6641,16 +6641,22 @@ comment at the start of cc-engine.el for more info."
6641 res)) 6641 res))
6642 6642
6643(defun c-forward-annotation () 6643(defun c-forward-annotation ()
6644 ;; Used for Java code only at the moment. Assumes point is on the 6644 ;; Used for Java code only at the moment. Assumes point is on the @, moves
6645 ;; @, moves forward an annotation. returns nil if there is no 6645 ;; forward an annotation and returns t. Leaves point unmoved and returns
6646 ;; annotation at point. 6646 ;; nil if there is no annotation at point.
6647 (and (looking-at "@") 6647 (let ((pos (point)))
6648 (progn (forward-char) t) 6648 (or
6649 (c-forward-type) 6649 (and (looking-at "@")
6650 (progn (c-forward-syntactic-ws) t) 6650 (not (looking-at c-keywords-regexp))
6651 (if (looking-at "(") 6651 (progn (forward-char) t)
6652 (c-go-list-forward) 6652 (looking-at c-symbol-key)
6653 t))) 6653 (progn (goto-char (match-end 0))
6654 (c-forward-syntactic-ws)
6655 t)
6656 (if (looking-at "(")
6657 (c-go-list-forward)
6658 t))
6659 (progn (goto-char pos) nil))))
6654 6660
6655(defmacro c-pull-open-brace (ps) 6661(defmacro c-pull-open-brace (ps)
6656 ;; Pull the next open brace from PS (which has the form of paren-state), 6662 ;; Pull the next open brace from PS (which has the form of paren-state),
@@ -6959,9 +6965,8 @@ comment at the start of cc-engine.el for more info."
6959 (when (or (looking-at c-prefix-spec-kwds-re) ;FIXME!!! includes auto 6965 (when (or (looking-at c-prefix-spec-kwds-re) ;FIXME!!! includes auto
6960 (and (c-major-mode-is 'java-mode) 6966 (and (c-major-mode-is 'java-mode)
6961 (looking-at "@[A-Za-z0-9]+"))) 6967 (looking-at "@[A-Za-z0-9]+")))
6962 (save-match-data 6968 (if (save-match-data (looking-at c-typedef-key))
6963 (if (looking-at c-typedef-key) 6969 (setq at-typedef t))
6964 (setq at-typedef t)))
6965 (setq kwd-sym (c-keyword-sym (match-string 1))) 6970 (setq kwd-sym (c-keyword-sym (match-string 1)))
6966 (save-excursion 6971 (save-excursion
6967 (c-forward-keyword-clause 1) 6972 (c-forward-keyword-clause 1)
@@ -9106,6 +9111,11 @@ comment at the start of cc-engine.el for more info."
9106 (goto-char containing-sexp) 9111 (goto-char containing-sexp)
9107 (if (or (save-excursion 9112 (if (or (save-excursion
9108 (c-backward-syntactic-ws lim) 9113 (c-backward-syntactic-ws lim)
9114 (while (and (eq (char-before) ?>)
9115 (c-get-char-property (1- (point))
9116 'syntax-table)
9117 (c-go-list-backward nil lim))
9118 (c-backward-syntactic-ws lim))
9109 (and (> (point) (or lim (point-min))) 9119 (and (> (point) (or lim (point-min)))
9110 (c-on-identifier))) 9120 (c-on-identifier)))
9111 (and c-special-brace-lists 9121 (and c-special-brace-lists
diff --git a/lisp/progmodes/cc-fonts.el b/lisp/progmodes/cc-fonts.el
index f74e5cbf678..03e67a99515 100644
--- a/lisp/progmodes/cc-fonts.el
+++ b/lisp/progmodes/cc-fonts.el
@@ -1157,15 +1157,6 @@ casts and declarations are fontified. Used on level 2 and higher."
1157 (setq pos (point)))))) ; acts to make the `while' form continue. 1157 (setq pos (point)))))) ; acts to make the `while' form continue.
1158 nil) 1158 nil)
1159 1159
1160(defconst c-font-lock-maybe-decl-faces
1161 ;; List of faces that might be put at the start of a type when
1162 ;; `c-font-lock-declarations' runs. This needs to be evaluated to
1163 ;; ensure that face name aliases in Emacs are resolved.
1164 (list nil
1165 font-lock-type-face
1166 c-reference-face-name
1167 font-lock-keyword-face))
1168
1169(defun c-font-lock-declarations (limit) 1160(defun c-font-lock-declarations (limit)
1170 ;; Fontify all the declarations, casts and labels from the point to LIMIT. 1161 ;; Fontify all the declarations, casts and labels from the point to LIMIT.
1171 ;; Assumes that strings and comments have been fontified already. 1162 ;; Assumes that strings and comments have been fontified already.
@@ -1256,7 +1247,7 @@ casts and declarations are fontified. Used on level 2 and higher."
1256 (c-find-decl-spots 1247 (c-find-decl-spots
1257 limit 1248 limit
1258 c-decl-start-re 1249 c-decl-start-re
1259 c-font-lock-maybe-decl-faces 1250 (eval c-maybe-decl-faces)
1260 1251
1261 (lambda (match-pos inside-macro) 1252 (lambda (match-pos inside-macro)
1262 ;; Note to maintainers: don't use `limit' inside this lambda form; 1253 ;; Note to maintainers: don't use `limit' inside this lambda form;
diff --git a/lisp/progmodes/cc-langs.el b/lisp/progmodes/cc-langs.el
index 08d84fbb625..b52da3f662d 100644
--- a/lisp/progmodes/cc-langs.el
+++ b/lisp/progmodes/cc-langs.el
@@ -3251,6 +3251,19 @@ way."
3251 objc t) 3251 objc t)
3252(c-lang-defvar c-type-decl-end-used (c-lang-const c-type-decl-end-used)) 3252(c-lang-defvar c-type-decl-end-used (c-lang-const c-type-decl-end-used))
3253 3253
3254(c-lang-defconst c-maybe-decl-faces
3255 "List of faces that might be put at the start of a type when
3256`c-font-lock-declarations' runs. This must be evaluated (with `eval') at
3257runtime to get the actual list of faces. This ensures that face name
3258aliases in Emacs are resolved."
3259 t '(list nil
3260 font-lock-type-face
3261 c-reference-face-name
3262 font-lock-keyword-face)
3263 java (append (c-lang-const c-maybe-decl-faces)
3264 '(font-lock-preprocessor-face)))
3265(c-lang-defvar c-maybe-decl-faces (c-lang-const c-maybe-decl-faces))
3266
3254 3267
3255;;; Wrap up the `c-lang-defvar' system. 3268;;; Wrap up the `c-lang-defvar' system.
3256 3269
diff --git a/lisp/progmodes/cc-mode.el b/lisp/progmodes/cc-mode.el
index 644065911dd..738870b727a 100644
--- a/lisp/progmodes/cc-mode.el
+++ b/lisp/progmodes/cc-mode.el
@@ -1336,12 +1336,13 @@ This function is called from `c-common-init', once per mode initialization."
1336 . c-mark-function))) 1336 . c-mark-function)))
1337 1337
1338 ;; Prevent `font-lock-default-fontify-region' extending the region it will 1338 ;; Prevent `font-lock-default-fontify-region' extending the region it will
1339 ;; fontify to whole lines by removing `font-lock-extend-region-whole-lines' 1339 ;; fontify to whole lines by removing `font-lock-extend-region-wholelines'
1340 ;; (and, coincidentally, `font-lock-extend-region-multiline' (which we do 1340 ;; from `font-lock-extend-region-functions'. (Emacs only). This fixes
1341 ;; not need)) from `font-lock-extend-region-functions'. (Emacs only). This 1341 ;; Emacs bug #19669.
1342 ;; fixes Emacs bug #19669.
1343 (when (boundp 'font-lock-extend-region-functions) 1342 (when (boundp 'font-lock-extend-region-functions)
1344 (setq font-lock-extend-region-functions nil)) 1343 (setq font-lock-extend-region-functions
1344 (delq 'font-lock-extend-region-wholelines
1345 font-lock-extend-region-functions)))
1345 1346
1346 (make-local-variable 'font-lock-fontify-region-function) 1347 (make-local-variable 'font-lock-fontify-region-function)
1347 (setq font-lock-fontify-region-function 'c-font-lock-fontify-region) 1348 (setq font-lock-fontify-region-function 'c-font-lock-fontify-region)
diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index d77158761eb..fe28ed776b2 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -27,6 +27,11 @@
27;; current project, without having to know which package handles 27;; current project, without having to know which package handles
28;; detection of that project type, parsing its config files, etc. 28;; detection of that project type, parsing its config files, etc.
29;; 29;;
30;; NOTE: The project API is still experimental and can change in major,
31;; backward-incompatible ways. Everyone is encouraged to try it, and
32;; report to us any problems or use cases we hadn't anticipated, by
33;; sending an email to emacs-devel, or `M-x report-emacs-bug'.
34;;
30;; Infrastructure: 35;; Infrastructure:
31;; 36;;
32;; Function `project-current', to determine the current project 37;; Function `project-current', to determine the current project
@@ -45,10 +50,12 @@
45 50
46;;; TODO: 51;;; TODO:
47 52
48;; * Commands `project-find-file' and `project-or-external-find-file'. 53;; * Reliably cache the list of files in the project, probably using
49;; Currently blocked on adding a new completion style that would let 54;; filenotify.el (if supported) to invalidate. And avoiding caching
50;; the user enter just the base file name (or a part of it), and get 55;; if it's not available (manual cache invalidation is not nice).
51;; it expanded to the absolute file name. 56;;
57;; * Allow the backend to override the file-listing logic? Maybe also
58;; to delegate file name completion to an external tool.
52;; 59;;
53;; * Build tool related functionality. Start with a `project-build' 60;; * Build tool related functionality. Start with a `project-build'
54;; command, which should provide completions on tasks to run, and 61;; command, which should provide completions on tasks to run, and
@@ -251,13 +258,15 @@ DIRS must contain directory names."
251(defun project--value-in-dir (var dir) 258(defun project--value-in-dir (var dir)
252 (with-temp-buffer 259 (with-temp-buffer
253 (setq default-directory dir) 260 (setq default-directory dir)
254 (hack-dir-local-variables-non-file-buffer) 261 (let ((enable-local-variables :all))
262 (hack-dir-local-variables-non-file-buffer))
255 (symbol-value var))) 263 (symbol-value var)))
256 264
257(declare-function grep-read-files "grep") 265(declare-function grep-read-files "grep")
258(declare-function xref-collect-matches "xref") 266(declare-function xref-collect-matches "xref")
259(declare-function xref--show-xrefs "xref") 267(declare-function xref--show-xrefs "xref")
260(declare-function xref-backend-identifier-at-point "xref") 268(declare-function xref-backend-identifier-at-point "xref")
269(declare-function xref--find-ignores-arguments "xref")
261 270
262;;;###autoload 271;;;###autoload
263(defun project-find-regexp (regexp) 272(defun project-find-regexp (regexp)
@@ -302,5 +311,53 @@ pattern to search for."
302 (user-error "No matches for: %s" regexp)) 311 (user-error "No matches for: %s" regexp))
303 (xref--show-xrefs xrefs nil))) 312 (xref--show-xrefs xrefs nil)))
304 313
314;;;###autoload
315(defun project-find-file ()
316 "Visit a file in the current project's roots.
317
318This is like `find-file', but it limits the file-name completion
319candidates to the files within the current project roots."
320 (interactive)
321 (let* ((pr (project-current t))
322 (dirs (project-roots pr)))
323 (project--find-file-in dirs pr)))
324
325;;;###autoload
326(defun project-or-external-find-file ()
327 "Visit a file in the current project's roots or external roots.
328
329This is like `find-file', but it limits the file-name completion
330candidates to the files within the current project roots and external roots."
331 (interactive)
332 (let* ((pr (project-current t))
333 (dirs (append
334 (project-roots pr)
335 (project-external-roots pr))))
336 (project--find-file-in dirs pr)))
337
338;; FIXME: Uniquely abbreviate the roots?
339(defun project--find-file-in (dirs project)
340 (require 'xref)
341 (let* ((all-files
342 (cl-mapcan
343 (lambda (dir)
344 (let ((command
345 (format "%s %s %s -type f -print0"
346 find-program
347 dir
348 (xref--find-ignores-arguments
349 (project-ignores project dir)
350 (expand-file-name dir)))))
351 (split-string (shell-command-to-string command) "\0" t)))
352 dirs))
353 (table (lambda (string pred action)
354 (cond
355 ((eq action 'metadata)
356 '(metadata . ((category . project-file))))
357 (t
358 (complete-with-action action all-files string pred))))))
359 (find-file
360 (completing-read "Find file: " table nil t))))
361
305(provide 'project) 362(provide 'project)
306;;; project.el ends here 363;;; project.el ends here
diff --git a/lisp/progmodes/sh-script.el b/lisp/progmodes/sh-script.el
index 02d329d794d..7f89ab2762c 100644
--- a/lisp/progmodes/sh-script.el
+++ b/lisp/progmodes/sh-script.el
@@ -2115,7 +2115,11 @@ May return nil if the line should not be treated as continued."
2115 ;; sh-indent-after-done: aligned completely differently. 2115 ;; sh-indent-after-done: aligned completely differently.
2116 (`(:after . "in") (sh-var-value 'sh-indent-for-case-label)) 2116 (`(:after . "in") (sh-var-value 'sh-indent-for-case-label))
2117 ;; sh-indent-for-continuation: Line continuations are handled differently. 2117 ;; sh-indent-for-continuation: Line continuations are handled differently.
2118 (`(:after . ,(or `"(" `"{" `"[")) (sh-var-value 'sh-indent-after-open)) 2118 (`(:after . ,(or `"(" `"{" `"["))
2119 (if (not (looking-at ".[ \t]*[^\n \t#]"))
2120 (sh-var-value 'sh-indent-after-open)
2121 (goto-char (1- (match-end 0)))
2122 `(column . ,(current-column))))
2119 ;; sh-indent-after-function: we don't handle it differently. 2123 ;; sh-indent-after-function: we don't handle it differently.
2120 )) 2124 ))
2121 2125
diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el
index ae5ec61520d..fe39122d24f 100644
--- a/lisp/progmodes/xref.el
+++ b/lisp/progmodes/xref.el
@@ -208,7 +208,7 @@ LENGTH is the match length, in characters."
208 208
209(defvar xref-backend-functions nil 209(defvar xref-backend-functions nil
210 "Special hook to find the xref backend for the current context. 210 "Special hook to find the xref backend for the current context.
211Each functions on this hook is called in turn with no arguments 211Each function on this hook is called in turn with no arguments,
212and should return either nil to mean that it is not applicable, 212and should return either nil to mean that it is not applicable,
213or an xref backend, which is a value to be used to dispatch the 213or an xref backend, which is a value to be used to dispatch the
214generic functions.") 214generic functions.")
@@ -502,10 +502,14 @@ WINDOW controls how the buffer is displayed:
502 (xref--pop-to-location xref window))) 502 (xref--pop-to-location xref window)))
503 503
504(defun xref-query-replace (from to) 504(defun xref-query-replace (from to)
505 "Perform interactive replacement in all current matches." 505 "Perform interactive replacement of FROM with TO in all displayed xrefs.
506
507This command interactively replaces FROM with TO in the names of the
508references displayed in the current *xref* buffer."
506 (interactive 509 (interactive
507 (list (read-regexp "Query replace regexp in matches" ".*") 510 (let ((fr (read-regexp "Xref query-replace (regexp)" ".*")))
508 (read-regexp "Replace with: "))) 511 (list fr
512 (read-regexp (format "Xref query-replace (regexp) %s with: " fr)))))
509 (let (pairs item) 513 (let (pairs item)
510 (unwind-protect 514 (unwind-protect
511 (progn 515 (progn
@@ -762,12 +766,10 @@ Return an alist of the form ((FILENAME . (XREF ...)) ...)."
762With prefix argument or when there's no identifier at point, 766With prefix argument or when there's no identifier at point,
763prompt for it. 767prompt for it.
764 768
765If the backend has sufficient information to determine a unique 769If sufficient information is available to determine a unique
766definition for IDENTIFIER, it returns only that definition. If 770definition for IDENTIFIER, display it in the selected window.
767there are multiple possible definitions, it returns all of them. 771Otherwise, display the list of the possible definitions in a
768 772buffer where the user can select from the list."
769If the backend returns one definition, jump to it; otherwise,
770display the list in a buffer."
771 (interactive (list (xref--read-identifier "Find definitions of: "))) 773 (interactive (list (xref--read-identifier "Find definitions of: ")))
772 (xref--find-definitions identifier nil)) 774 (xref--find-definitions identifier nil))
773 775
@@ -876,7 +878,9 @@ IGNORES is a list of glob patterns."
876 grep-find-template t t)) 878 grep-find-template t t))
877 (grep-highlight-matches nil) 879 (grep-highlight-matches nil)
878 (command (xref--rgrep-command (xref--regexp-to-extended regexp) 880 (command (xref--rgrep-command (xref--regexp-to-extended regexp)
879 files dir ignores)) 881 files
882 (expand-file-name dir)
883 ignores))
880 (orig-buffers (buffer-list)) 884 (orig-buffers (buffer-list))
881 (buf (get-buffer-create " *xref-grep*")) 885 (buf (get-buffer-create " *xref-grep*"))
882 (grep-re (caar grep-regexp-alist)) 886 (grep-re (caar grep-regexp-alist))
@@ -912,23 +916,28 @@ IGNORES is a list of glob patterns."
912 " " 916 " "
913 (shell-quote-argument ")")) 917 (shell-quote-argument ")"))
914 dir 918 dir
915 (concat 919 (xref--find-ignores-arguments ignores dir)))
916 (shell-quote-argument "(") 920
917 " -path " 921(defun xref--find-ignores-arguments (ignores dir)
918 (mapconcat 922 ;; `shell-quote-argument' quotes the tilde as well.
919 (lambda (ignore) 923 (cl-assert (not (string-match-p "\\`~" dir)))
920 (when (string-match-p "/\\'" ignore) 924 (concat
921 (setq ignore (concat ignore "*"))) 925 (shell-quote-argument "(")
922 (if (string-match "\\`\\./" ignore) 926 " -path "
923 (setq ignore (replace-match dir t t ignore)) 927 (mapconcat
924 (unless (string-prefix-p "*" ignore) 928 (lambda (ignore)
925 (setq ignore (concat "*/" ignore)))) 929 (when (string-match-p "/\\'" ignore)
926 (shell-quote-argument ignore)) 930 (setq ignore (concat ignore "*")))
927 ignores 931 (if (string-match "\\`\\./" ignore)
928 " -o -path ") 932 (setq ignore (replace-match dir t t ignore))
929 " " 933 (unless (string-prefix-p "*" ignore)
930 (shell-quote-argument ")") 934 (setq ignore (concat "*/" ignore))))
931 " -prune -o "))) 935 (shell-quote-argument ignore))
936 ignores
937 " -o -path ")
938 " "
939 (shell-quote-argument ")")
940 " -prune -o "))
932 941
933(defun xref--regexp-to-extended (str) 942(defun xref--regexp-to-extended (str)
934 (replace-regexp-in-string 943 (replace-regexp-in-string