8000 Inline `go--is-go-asm` to prevent `go-mode.el` loading by toyboot4e · Pull Request #456 · dominikh/go-mode.el · GitHub
[go: up one dir, main page]

Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 17 additions & 14 deletions go-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -3101,20 +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
(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)))))))
(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)

Expand Down
0