]> git.eshelyaron.com Git - emacs.git/commitdiff
Unbreak project-find-regexp in Emacs 26.3 (bug#42765)
authorDmitry Gutov <dgutov@yandex.ru>
Fri, 14 Aug 2020 07:20:04 +0000 (10:20 +0300)
committerDmitry Gutov <dgutov@yandex.ru>
Fri, 14 Aug 2020 14:21:55 +0000 (17:21 +0300)
* lisp/progmodes/project.el: Depend on xref.  Bump the version.

* lisp/progmodes/xref.el: Remove 'project' from the list of
dependencies.  Depending on Emacs 26.3 already ensures that some
version is available.  Bump the version.
(xref--process-file-region): Move from project.el with a rename.
Update the sole caller.
(xref-backend-references): Make compatible with old project.el.
Update the docstring.

lisp/progmodes/project.el
lisp/progmodes/xref.el

index b6161351f0bf1e814e26add316fe2a0d61db7aa0..8afd5ce7959344bfa738d58ecf79ee87d3a7b273 100644 (file)
@@ -1,8 +1,8 @@
 ;;; project.el --- Operations on the current project  -*- lexical-binding: t; -*-
 
 ;; Copyright (C) 2015-2020 Free Software Foundation, Inc.
-;; Version: 0.5.0
-;; Package-Requires: ((emacs "26.3"))
+;; Version: 0.5.1
+;; Package-Requires: ((emacs "26.3") (xref "1.0.2"))
 
 ;; This is a GNU ELPA :core package.  Avoid using functionality that
 ;; not compatible with the version of Emacs recorded above.
@@ -731,24 +731,6 @@ pattern to search for."
       (user-error "No matches for: %s" regexp))
     xrefs))
 
-(defun project--process-file-region (start end program
-                                     &optional buffer display
-                                     &rest args)
-  ;; FIXME: This branching shouldn't be necessary, but
-  ;; call-process-region *is* measurably faster, even for a program
-  ;; doing some actual work (for a period of time). Even though
-  ;; call-process-region also creates a temp file internally
-  ;; (http://lists.gnu.org/archive/html/emacs-devel/2019-01/msg00211.html).
-  (if (not (file-remote-p default-directory))
-      (apply #'call-process-region
-             start end program nil buffer display args)
-    (let ((infile (make-temp-file "ppfr")))
-      (unwind-protect
-          (progn
-            (write-region start end infile nil 'silent)
-            (apply #'process-file program infile buffer display args))
-        (delete-file infile)))))
-
 (defun project--read-regexp ()
   (let ((sym (thing-at-point 'symbol)))
     (read-regexp "Find regexp" (and sym (regexp-quote sym)))))
index 3e3a37f6da560507343222de829706aa535c2b3c..bbf899e70177bd773a45cab7db1a2b41cc4f1d11 100644 (file)
@@ -1,8 +1,8 @@
 ;;; xref.el --- Cross-referencing commands              -*-lexical-binding:t-*-
 
 ;; Copyright (C) 2014-2020 Free Software Foundation, Inc.
-;; Version: 1.0.1
-;; Package-Requires: ((emacs "26.3") (project "0.1.1"))
+;; Version: 1.0.2
+;; Package-Requires: ((emacs "26.3"))
 
 ;; This is a GNU ELPA :core package.  Avoid functionality that is not
 ;; compatible with the version of Emacs recorded above.
@@ -263,13 +263,16 @@ be found, return nil.
 
 The default implementation uses `semantic-symref-tool-alist' to
 find a search tool; by default, this uses \"find | grep\" in the
-`project-current' roots."
+current project's main and external roots."
   (mapcan
    (lambda (dir)
      (xref-references-in-directory identifier dir))
    (let ((pr (project-current t)))
      (cons
-      (project-root pr)
+      (if (fboundp 'project-root)
+          (project-root pr)
+        (with-no-warnings
+          (project-roots pr)))
       (project-external-roots pr)))))
 
 (cl-defgeneric xref-backend-apropos (backend pattern)
@@ -1281,13 +1284,13 @@ FILES must be a list of absolute file names."
         (insert (mapconcat #'identity files "\0"))
         (setq default-directory dir)
         (setq status
-              (project--process-file-region (point-min)
-                                            (point-max)
-                                            shell-file-name
-                                            output
-                                            nil
-                                            shell-command-switch
-                                            command)))
+              (xref--process-file-region (point-min)
+                                         (point-max)
+                                         shell-file-name
+                                         output
+                                         nil
+                                         shell-command-switch
+                                         command)))
       (goto-char (point-min))
       (when (and (/= (point-min) (point-max))
                  (not (looking-at grep-re))
@@ -1302,6 +1305,24 @@ FILES must be a list of absolute file names."
               hits)))
     (xref--convert-hits (nreverse hits) regexp)))
 
+(defun xref--process-file-region ( start end program
+                                   &optional buffer display
+                                   &rest args)
+  ;; FIXME: This branching shouldn't be necessary, but
+  ;; call-process-region *is* measurably faster, even for a program
+  ;; doing some actual work (for a period of time). Even though
+  ;; call-process-region also creates a temp file internally
+  ;; (http://lists.gnu.org/archive/html/emacs-devel/2019-01/msg00211.html).
+  (if (not (file-remote-p default-directory))
+      (apply #'call-process-region
+             start end program nil buffer display args)
+    (let ((infile (make-temp-file "ppfr")))
+      (unwind-protect
+          (progn
+            (write-region start end infile nil 'silent)
+            (apply #'process-file program infile buffer display args))
+        (delete-file infile)))))
+
 (defun xref--rgrep-command (regexp files dir ignores)
   (require 'find-dired)      ; for `find-name-arg'
   (defvar grep-find-template)