emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] externals/realgud 11c57cd 02/72: Add suffix file matching


From: Stefan Monnier
Subject: [elpa] externals/realgud 11c57cd 02/72: Add suffix file matching
Date: Fri, 26 Mar 2021 22:49:02 -0400 (EDT)

branch: externals/realgud
commit 11c57cd2ea898c2167ad6c7f80eb1807109d8260
Author: rocky <rocky@gnu.org>
Commit: rocky <rocky@gnu.org>

    Add suffix file matching
---
 NEWS                            |  1 +
 realgud/common/buffer/source.el |  2 +-
 realgud/common/file.el          | 24 +++++++++++++++---------
 3 files changed, 17 insertions(+), 10 deletions(-)

diff --git a/NEWS b/NEWS
new file mode 120000
index 0000000..7b97b99
--- /dev/null
+++ b/NEWS
@@ -0,0 +1 @@
+NEWS.md
\ No newline at end of file
diff --git a/realgud/common/buffer/source.el b/realgud/common/buffer/source.el
index 4cfb05b..108593f 100644
--- a/realgud/common/buffer/source.el
+++ b/realgud/common/buffer/source.el
@@ -1,4 +1,4 @@
-;;; Copyright (C) 2010, 2012-2015, 2017 Free Software Foundation, Inc
+;;; Copyright (C) 2010, 2012-2015, 2017, 2019 Free Software Foundation, Inc
 
 ;; Author: Rocky Bernstein <rocky@gnu.org>
 
diff --git a/realgud/common/file.el b/realgud/common/file.el
index c75c72d..ffaeb91 100644
--- a/realgud/common/file.el
+++ b/realgud/common/file.el
@@ -14,8 +14,7 @@
 
 ; Should realgud:file-loc-from-line be here or elsewhere?
 (require 'load-relative)
-(require 'compile) ;; for compilation-find-file
-(require 'seq) ;; for seq-find
+(require 'seq) ;; for seq-find seq-filter
 (require-relative-list '("helper" "loc") "realgud-")
 (require-relative-list '("buffer/command") "realgud-buffer-")
 
@@ -37,12 +36,8 @@
   :type 'function
   :group 'realgud)
 
-(defun realgud:find-file (marker filename directory &optional formats)
-  "A wrapper around compilation find-file. We set the prompt
-   to indicate we are looking for a source-code file."
-   (or formats (setq formats "%s"))
-   (let ((compilation-error "source-code file"))
-    (compilation-find-file marker filename directory formats)))
+(defun realgud--file-matching-suffix(paths suffix)
+  (seq-filter (lambda (x) (string-suffix-p suffix x)) paths))
 
 (defun realgud:file-line-count(filename)
   "Return the number of lines in file FILENAME, or nil FILENAME can't be
@@ -97,7 +92,8 @@ problem as best as we can determine."
         (remapped-filename
          (assoc filename filename-remap-alist))
         (mutex (realgud-cmdbuf-mutex cmdbuf))
-        )
+        (matching-file-list)
+        (buffer-files))
 
     ;;(with-mutex
     ;; mutex
@@ -116,6 +112,16 @@ problem as best as we can determine."
        ((realgud:file-ignore filename ignore-re-file-list)
         (message "tracking ignored for %s" filename))
 
+       ;; If we can find the filename, e.g. "src/code.c" as a suffix of file in
+       ;; the list of buffers seen, use that
+       ((and
+         (setq buffer-files
+            (with-current-buffer (marker-buffer cmd-marker)
+              (mapcar (lambda (buf) (buffer-file-name buf))
+                      (realgud-cmdbuf-info-srcbuf-list realgud-cmdbuf-info))))
+         (setq matching-file-list (realgud--file-matching-suffix buffer-files 
filename))
+         (car matching-file-list)))
+
        ;; Do we want to black-list this?
        ((y-or-n-p (format "Black-list file %s for location tracking?" 
filename))
         ;; FIXME: there has to be a simpler way to set ignore-file-list



reply via email to

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