]> git.eshelyaron.com Git - emacs.git/commitdiff
elisp-mode.el: Fix handling of deleted files main
authorEshel Yaron <me@eshelyaron.com>
Sun, 29 Jun 2025 08:29:45 +0000 (10:29 +0200)
committerEshel Yaron <me@eshelyaron.com>
Sun, 29 Jun 2025 08:29:45 +0000 (10:29 +0200)
lisp/progmodes/elisp-mode.el

index 7dbbfae2abee123e077347e1bf8327d31518469f..2c7cc6bc96c56e263781f933033c444d42da2b36 100644 (file)
@@ -1239,11 +1239,7 @@ confidence."
                  (symbol-type '(symbol-type symbol-type-definition))
                  (function '(defun function macro special-form major-mode)))))
           (require 'project)
-          (dolist-with-progress-reporter
-              (file
-               (seq-filter
-                (lambda (file) (string= (file-name-extension file) "el"))
-                (project-files (project-current))))
+          (dolist-with-progress-reporter (file (elisp-project-files))
               "Scanning for references"
             (let (all lla)
               (pcase-dolist (`(,type ,beg ,len . ,_) (gethash identifier (elisp-sym-name-index file)))
@@ -1304,12 +1300,7 @@ confidence."
            (symbol-type '(symbol-type symbol-type-definition))
            (function '(defun function macro special-form major-mode)))))
     (require 'project)
-    (dolist-with-progress-reporter
-        (file
-         (seq-filter
-          (lambda (file) (string= (file-name-extension file) "el"))
-          (project-files (project-current))))
-        "Scanning for references"
+    (dolist-with-progress-reporter (file (elisp-project-files)) "Scanning for references"
       (let (hits)
         (pcase-dolist (`(,type ,beg ,len . ,_) (gethash str (elisp-sym-name-index file)))
           (when (or (null types) (memq type types))
@@ -1318,6 +1309,13 @@ confidence."
         (when hits (push (cons file hits) res))))
     (nreverse res)))
 
+(defun elisp-project-files ()
+  (seq-filter
+   (lambda (file)
+     (and (string= (file-name-extension file) "el")
+          (not (string-prefix-p ".#" (file-name-base file)))))
+   (project-files (project-current))))
+
 (defun elisp-make-xref (beg len)
   (let* ((beg-end (save-excursion
                     (goto-char beg)
@@ -2885,21 +2883,26 @@ of TARGET."
 
 (defvar elisp-sym-name-index-cache (make-hash-table :test #'equal))
 
+(defconst elisp--dummy-hash-table (make-hash-table :test #'equal))
+
 (defun elisp-sym-name-index (file)
   (if-let ((buf (get-file-buffer file))
            ((buffer-modified-p buf)))
       (with-current-buffer buf (elisp-sym-name-index-1 file))
     (let ((cached (gethash file elisp-sym-name-index-cache))
           (modtime (file-attribute-modification-time (file-attributes file))))
-      (cdr
-       (if (time-less-p (or (car cached) 0) modtime)
-           (puthash file (cons modtime
-                               (with-work-buffer
-                                 (setq lexical-binding t)
-                                 (insert-file-contents file)
-                                 (elisp-sym-name-index-1 file)))
-                    elisp-sym-name-index-cache)
-         cached)))))
+      (if modtime
+          (cdr
+           (if (time-less-p (or (car cached) 0) modtime)
+               (puthash file (cons modtime
+                                   (with-work-buffer
+                                     (setq lexical-binding t)
+                                     (insert-file-contents file)
+                                     (elisp-sym-name-index-1 file)))
+                        elisp-sym-name-index-cache)
+             cached))
+        ;; File does not exists.
+        elisp--dummy-hash-table))))
 
 (defun elisp-sym-name-index-1 (source)
   (let ((all (make-hash-table :test #'equal))