From d17552c72173eaa2e7db96ac0bf5c01e3eeb6272 Mon Sep 17 00:00:00 2001 From: toyboot4e Date: Fri, 4 Dec 2026 22:49:42 +0900 Subject: [PATCH 1/2] Don't use cl-some in go--is-go-asm Co-Authored-By: Claude Opus 5.5 --- go-mode.el | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/go-mode.el b/go-mode.el index b71b082d..b77fdf0c 100644 --- a/go-mode.el +++ b/go-mode.el @@ -3104,17 +3104,19 @@ This handles multi-line comments with a * prefix on each line." (defun go--is-go-asm () "Determine whether a file is (probably) a Go assembly file." (when (string-suffix-p ".s" (buffer-file-name)) - (let ((directory (file-name-directory (buffer-file-name)))) - (when directory - (cl-some (lambda (s) (or (string-suffix-p ".go" s) (string-suffix-p ".mod" s))) - (condition-case nil - ;; We only look at 8192 files, to avoid heavy I/O in - ;; case the user opens a .s file in a giant directory. - ;; If it weren't for that, we could set the count to 1 - ;; and use the 'match' argument of directory-files to - ;; look for the first '.go' file. - (directory-files directory nil nil t 8192) - (error nil))))))) + (let ((directory (file-name-directory (buffer-file-name)))) + (when directory + (catch 'found + (dolist (s (condition-case nil + ;; We only look at 8192 files, to avoid heavy I/O in + ;; case the user opens a .s file in a giant directory. + ;; If it weren't for that, we could set the count to 1 + ;; and use the 'match' argument of directory-files to + ;; look for the first '.go' file. + (directory-files directory nil nil t 8192) + (error nil))) + (when (or (string-suffix-p ".go" s) (string-suffix-p ".mod" s)) + (throw 'found t)))))))) (provide 'go-mode) From abec738338bb082bf7efb10750a56336ba97632f Mon Sep 17 00:00:00 2001 From: toyboot4e Date: Fri, 4 Dec 2026 22:49:42 +0900 Subject: [PATCH 2/2] Don't load go-mode on every file visit via go--is-go-asm Co-Authored-By: Claude Opus 5.5 --- go-mode.el | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/go-mode.el b/go-mode.el index b77fdf0c..a25c068d 100644 --- a/go-mode.el +++ b/go-mode.el @@ -3101,22 +3101,23 @@ This handles multi-line comments with a * prefix on each line." (add-to-list 'magic-mode-alist (cons #'go--is-go-asm #'go-asm-mode)) ;;;###autoload -(defun go--is-go-asm () - "Determine whether a file is (probably) a Go assembly file." - (when (string-suffix-p ".s" (buffer-file-name)) - (let ((directory (file-name-directory (buffer-file-name)))) - (when directory - (catch 'found - (dolist (s (condition-case nil - ;; We only look at 8192 files, to avoid heavy I/O in - ;; case the user opens a .s file in a giant directory. - ;; If it weren't for that, we could set the count to 1 - ;; and use the 'match' argument of directory-files to - ;; look for the first '.go' file. - (directory-files directory nil nil t 8192) - (error nil))) - (when (or (string-suffix-p ".go" s) (string-suffix-p ".mod" s)) - (throw 'found t)))))))) +(progn ;; Wrapped with `progn' so `magic-mode-alist' doesn't load go-mode. + (defun go--is-go-asm () + "Determine whether a file is (probably) a Go assembly file." + (when (string-suffix-p ".s" (buffer-file-name)) + (let ((directory (file-name-directory (buffer-file-name)))) + (when directory + (catch 'found + (dolist (s (condition-case nil + ;; We only look at 8192 files, to avoid heavy I/O in + ;; case the user opens a .s file in a giant directory. + ;; If it weren't for that, we could set the count to 1 + ;; and use the 'match' argument of directory-files to + ;; look for the first '.go' file. + (directory-files directory nil nil t 8192) + (error nil))) + (when (or (string-suffix-p ".go" s) (string-suffix-p ".mod" s)) + (throw 'found t))))))))) (provide 'go-mode)