withastro / astro

The web framework for content-driven websites. ⭐️ Star to support our work!
https://astro.build
Other
45.42k stars 2.37k forks source link

Emacs autosave files are not ignored #9887

Open FabriceSalvaire opened 7 months ago

FabriceSalvaire commented 7 months ago

Astro Info

Astro                    v4.2.6
Node                     v20.10.0
System                   Linux (x64)
Package Manager          npm
Output                   static
Adapter                  none
Integrations             @astrojs/mdx
@astrojs/sitemap
@astrojs/react

If this issue only occurs in one browser, which browser is a problem?

No response

Describe the Bug

Emacs editor generates FILENAME~ and #FILENAME# files.

It generates messages like

[WARN] Unsupported file type .../[...page].astro~ found. Prefix filename with an underscore (`_`) to ignore.

I tried

export default defineConfig({
  vite: {
    server: {
      watch: {
        ignored: ['**~', '**#']
      }
    }
  }
});

But it doesn't work. Not sure the regexp is right, I tried several possibilities...

What's the expected result?

Astro should ignore thoses files.

Link to Minimal Reproducible Example

irrelevant

Participation

FabriceSalvaire commented 7 months ago

I also got issues with a __TRASH__ directory... It is a horrible design to scan everything in the root directory. It is impossible to have unused files since npm build will throw zillion of errors !

FabriceSalvaire commented 7 months ago

Another issue with Emacs .#FILENAME

ENOENT: no such file or directory, stat '/home/fabrice/astro-test/blog/src/pages/blog/.#[...page].astro'
  Stack trace:
    at Object.statSync (node:fs:1676:25)
    at walk (file:///home/fabrice/astro-test/blog/node_modules/astro/dist/core/routing/manifest/create.js:241:9)
    at createRouteManifest (file:///home/fabrice/astro-test/blog/node_modules/astro/dist/core/routing/manifest/create.js:413:27)
    at async AstroBuilder.run (file:///home/fabrice/astro-test/blog/node_modules/astro/dist/core/build/index.js:167:23)
    at async build (file:///home/fabrice/astro-test/blog/node_modules/astro/dist/cli/build/index.js:20:3)

> ll /home/fabrice/astro-test/blog/src/pages/blog/.#\[...page\].astro 
... /home/fabrice/astro-test/blog/src/pages/blog/.#[...page].astro -> fabrice@isis.home.24461:1706615895
fabrice@isis:~/astro-test/blog>
bluwy commented 7 months ago

I guess Astro's pages detection could try and detect those special file names, and ignore them as pages. But do you know why emacs is generating them? It seems like an odd thing to do.

Princesseuh commented 7 months ago

They're backup files, Emacs store the last 9 versions of the file in ~ files and the #file# one is a temp version of the file currently operated on, when you save it overwrites the normal file with the content of this temp one (presumably in an effort to ensure atomic saves?)

Vim has a similar system, but no modern editors do, as far as I know at least.

jcayzac commented 1 month ago

@Princesseuh you could try (setq create-lockfiles nil) maybe?