emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 3194639: Unbreak project-find-regexp in Emacs 26.3 (bug#42765)


From: Dmitry Gutov
Subject: master 3194639: Unbreak project-find-regexp in Emacs 26.3 (bug#42765)
Date: Fri, 14 Aug 2020 10:22:10 -0400 (EDT)

branch: master
commit 319463920ca8829dcdfa6c0c8c1c8ff15091f6f0
Author: Dmitry Gutov <dgutov@yandex.ru>
Commit: Dmitry Gutov <dgutov@yandex.ru>

    Unbreak project-find-regexp in Emacs 26.3 (bug#42765)
    
    * 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 | 22 ++--------------------
 lisp/progmodes/xref.el    | 43 ++++++++++++++++++++++++++++++++-----------
 2 files changed, 34 insertions(+), 31 deletions(-)

diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index b616135..8afd5ce 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -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)))))
diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el
index 3e3a37f..bbf899e 100644
--- a/lisp/progmodes/xref.el
+++ b/lisp/progmodes/xref.el
@@ -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)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]