Ignore emacs temp files
authorAlexandre Bourget <alex@bourget.cc>
Mon, 11 Jul 2016 00:01:45 +0000 (20:01 -0400)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Mon, 11 Jul 2016 00:01:45 +0000 (02:01 +0200)
commands/hugo.go
source/content_directory_test.go

index d91d75c4e4f19cc9ec7deac362888ee61339c1a4..d1b82d80460ddbc4254440c745e74940020c2fec 100644 (file)
@@ -745,17 +745,20 @@ func NewWatcher(port int) error {
 
                                for _, ev := range evs {
                                        ext := filepath.Ext(ev.Name)
+                                       baseName := filepath.Base(ev.Name)
                                        istemp := strings.HasSuffix(ext, "~") ||
                                                (ext == ".swp") || // vim
                                                (ext == ".swx") || // vim
                                                (ext == ".tmp") || // generic temp file
                                                (ext == ".DS_Store") || // OSX Thumbnail
-                                               filepath.Base(ev.Name) == "4913" || // vim
+                                               baseName == "4913" || // vim
                                                strings.HasPrefix(ext, ".goutputstream") || // gnome
                                                strings.HasSuffix(ext, "jb_old___") || // intelliJ
                                                strings.HasSuffix(ext, "jb_tmp___") || // intelliJ
                                                strings.HasSuffix(ext, "jb_bak___") || // intelliJ
-                                               strings.HasPrefix(ext, ".sb-") // byword
+                                               strings.HasPrefix(ext, ".sb-") || // byword
+                                               strings.HasPrefix(baseName, ".#") || // emacs
+                                               strings.HasPrefix(baseName, "#") // emacs
                                        if istemp {
                                                continue
                                        }
index 839da5193cf65ea8d7af64d876b7ea87b95548d0..107ca983783d7fbd0339f3f32e7e1e326ea0889a 100644 (file)
@@ -43,6 +43,8 @@ func TestIgnoreDotFilesAndDirectories(t *testing.T) {
                {"foobar/foo.html", false, []string{"\\.md$", "\\.boo$"}},
                {"foobar/foo.md", true, []string{"^foo"}},
                {"foobar/foo.md", false, []string{"*", "\\.md$", "\\.boo$"}},
+               {"foobar/.#content.md", true, []string{"/\\.#"}},
+               {".#foobar.md", true, []string{"^\\.#"}},
        }
 
        for _, test := range tests {