]> git.lizzy.rs Git - micro.git/commitdiff
Remove local settings
authorZachary Yedidia <zyedidia@gmail.com>
Sun, 4 Aug 2019 00:12:23 +0000 (17:12 -0700)
committerZachary Yedidia <zyedidia@gmail.com>
Wed, 25 Dec 2019 22:05:11 +0000 (17:05 -0500)
cmd/micro/micro.go
internal/action/bufpane.go
internal/action/command.go
internal/action/infocomplete.go
internal/buffer/buffer.go
internal/config/plugin.go
internal/config/rtfiles.go
internal/config/settings.go
internal/display/bufwindow.go
internal/util/util.go

index 62a41b42d4c1fe06f78b4c280f5b4c68f77dde24..635358ffc24bb75ec6b2bd86ec303b262fae0135 100644 (file)
@@ -201,12 +201,6 @@ func main() {
        action.InitTabs(b)
        action.InitGlobals()
 
-       for _, s := range config.LocalSettings {
-               if _, ok := config.GlobalSettings[s]; ok {
-                       delete(config.GlobalSettings, s)
-               }
-       }
-
        // Here is the event loop which runs in a separate thread
        go func() {
                events = make(chan tcell.Event)
index e39f2b90e14410af1e6e37222e8b39d3b91de4a0..a5c8530c9c9b246b1ed7b3c2c764fadca0354eeb 100644 (file)
@@ -1,7 +1,6 @@
 package action
 
 import (
-       "log"
        "strings"
        "time"
 
@@ -296,7 +295,6 @@ func (h *BufPane) DoKeyEvent(e Event) bool {
                        return false
                }
                rel := action(h)
-               log.Println("calling on", estr)
                if h.PluginCB("on"+estr) && rel {
                        h.Relocate()
                }
index 3bbe935984ba50a28aa75194b0d6912afccad822..c4fe0db8828d39338010bc982e32e01f06ec2ba9 100644 (file)
@@ -3,7 +3,6 @@ package action
 import (
        "errors"
        "fmt"
-       "log"
        "os"
        "path/filepath"
        "regexp"
@@ -271,9 +270,7 @@ func ReloadConfig() {
                screen.TermMessage(err)
        }
 
-       log.Println("RELOAD CONFIG", len(buffer.OpenBuffers))
        for _, b := range buffer.OpenBuffers {
-               log.Println("UPDATE RULES")
                b.UpdateRules()
        }
 }
@@ -450,7 +447,7 @@ func (h *BufPane) ResetCmd(args []string) {
        option := args[0]
 
        defaultGlobals := config.DefaultGlobalSettings()
-       defaultLocals := config.DefaultLocalSettings()
+       defaultLocals := config.DefaultCommonSettings()
 
        if _, ok := defaultGlobals[option]; ok {
                SetGlobalOptionNative(option, defaultGlobals[option])
index 9179b63b5e8fc433cb7c98b09b80597e7085a477..15a175dad04d306ce663aecbe0255aa026177c39 100644 (file)
@@ -92,17 +92,16 @@ func OptionComplete(b *buffer.Buffer) ([]string, []string) {
        input, argstart := buffer.GetArg(b)
 
        var suggestions []string
-       localSettings := config.DefaultLocalSettings()
        for option := range config.GlobalSettings {
                if strings.HasPrefix(option, input) {
                        suggestions = append(suggestions, option)
                }
        }
-       for option := range localSettings {
-               if strings.HasPrefix(option, input) && !contains(suggestions, option) {
-                       suggestions = append(suggestions, option)
-               }
-       }
+       // for option := range localSettings {
+       //      if strings.HasPrefix(option, input) && !contains(suggestions, option) {
+       //              suggestions = append(suggestions, option)
+       //      }
+       // }
 
        sort.Strings(suggestions)
        completions := make([]string, len(suggestions))
@@ -122,19 +121,19 @@ func OptionValueComplete(b *buffer.Buffer) ([]string, []string) {
        completeValue := false
        args := bytes.Split(l, []byte{' '})
        if len(args) >= 2 {
-               localSettings := config.DefaultLocalSettings()
+               // localSettings := config.DefaultLocalSettings()
                for option := range config.GlobalSettings {
                        if option == string(args[len(args)-2]) {
                                completeValue = true
                                break
                        }
                }
-               for option := range localSettings {
-                       if option == string(args[len(args)-2]) {
-                               completeValue = true
-                               break
-                       }
-               }
+               // for option := range localSettings {
+               //      if option == string(args[len(args)-2]) {
+               //              completeValue = true
+               //              break
+               //      }
+               // }
        }
        if !completeValue {
                return OptionComplete(b)
@@ -144,18 +143,18 @@ func OptionValueComplete(b *buffer.Buffer) ([]string, []string) {
 
        inputOpt = strings.TrimSpace(inputOpt)
        var suggestions []string
-       localSettings := config.DefaultLocalSettings()
+       // localSettings := config.DefaultLocalSettings()
        var optionVal interface{}
        for k, option := range config.GlobalSettings {
                if k == inputOpt {
                        optionVal = option
                }
        }
-       for k, option := range localSettings {
-               if k == inputOpt {
-                       optionVal = option
-               }
-       }
+       // for k, option := range localSettings {
+       //      if k == inputOpt {
+       //              optionVal = option
+       //      }
+       // }
 
        switch optionVal.(type) {
        case bool:
index 9082db3b8f5ed5a1ff3a13dcbcd55fc6bb635a55..5767445f006d50cd19faa17c29cbc45780d9e55f 100644 (file)
@@ -6,7 +6,6 @@ import (
        "errors"
        "io"
        "io/ioutil"
-       "log"
        "os"
        "path/filepath"
        "strconv"
@@ -163,7 +162,7 @@ func NewBuffer(r io.Reader, size int64, path string, startcursor Loc, btype BufT
 
        b := new(Buffer)
 
-       b.Settings = config.DefaultLocalSettings()
+       b.Settings = config.DefaultCommonSettings()
        for k, v := range config.GlobalSettings {
                if _, ok := b.Settings[k]; ok {
                        b.Settings[k] = v
@@ -294,7 +293,6 @@ func (b *Buffer) SetName(s string) {
 
 func (b *Buffer) Insert(start Loc, text string) {
        if !b.Type.Readonly {
-               log.Println("INSERT", start, text)
                b.EventHandler.cursors = b.cursors
                b.EventHandler.active = b.curCursor
                b.EventHandler.Insert(start, text)
index e3f2e42bb073f35ee9fad1adca5c2a29c1803ce2..40a526e9fa1347d3cde1448d89b421cbda546967 100644 (file)
@@ -2,7 +2,6 @@ package config
 
 import (
        "errors"
-       "log"
 
        lua "github.com/yuin/gopher-lua"
        ulua "github.com/zyedidia/micro/internal/lua"
@@ -102,7 +101,6 @@ func (p *Plugin) Load() error {
 
 func (p *Plugin) Call(fn string, args ...lua.LValue) (lua.LValue, error) {
        plug := ulua.L.GetGlobal(p.Name)
-       log.Println(p.Name, fn, plug)
        luafn := ulua.L.GetField(plug, fn)
        if luafn == lua.LNil {
                return nil, ErrNoSuchFunction
index 520c74b3ba1a6295fb67623a57696d2f2c14555a..d31b412333c830d9f337d0ed6739425e2589c3f2 100644 (file)
@@ -2,7 +2,6 @@ package config
 
 import (
        "io/ioutil"
-       "log"
        "os"
        "path"
        "path/filepath"
@@ -138,7 +137,6 @@ func InitRuntimeFiles() {
        // Search ConfigDir for plugin-scripts
        plugdir := filepath.Join(ConfigDir, "plugins")
        files, _ := ioutil.ReadDir(plugdir)
-       log.Println("reading", plugdir)
        for _, d := range files {
                if d.IsDir() {
                        srcs, _ := ioutil.ReadDir(filepath.Join(plugdir, d.Name()))
index 7a7df05a72f7d2f7ebe51a04597e0a61b08416a5..a6234032e0bee1112760c3e3e229a7187539af67 100644 (file)
@@ -129,10 +129,6 @@ func RegisterCommonOption(name string, defaultvalue interface{}) error {
        return nil
 }
 
-func RegisterLocalOption(name string, defaultvalue interface{}) {
-       defaultLocalSettings[name] = defaultvalue
-}
-
 func RegisterGlobalOption(name string, defaultvalue interface{}) error {
        if v, ok := GlobalSettings[name]; !ok {
                defaultGlobalSettings[name] = defaultvalue
@@ -162,11 +158,13 @@ var defaultCommonSettings = map[string]interface{}{
        "eofnewline":     false,
        "fastdirty":      true,
        "fileformat":     "unix",
+       "filetype":       "unknown",
        "ignorecase":     false,
        "indentchar":     " ",
        "keepautoindent": false,
        "matchbrace":     false,
        "matchbraceleft": false,
+       "readonly":       false,
        "rmtrailingws":   false,
        "ruler":          true,
        "savecursor":     false,
@@ -199,6 +197,16 @@ func GetInfoBarOffset() int {
        return offset
 }
 
+// DefaultCommonSettings returns the default global settings for micro
+// Note that colorscheme is a global only option
+func DefaultCommonSettings() map[string]interface{} {
+       commonsettings := make(map[string]interface{})
+       for k, v := range defaultCommonSettings {
+               commonsettings[k] = v
+       }
+       return commonsettings
+}
+
 var defaultGlobalSettings = map[string]interface{}{
        "colorscheme": "default",
        "infobar":     true,
@@ -222,29 +230,8 @@ func DefaultGlobalSettings() map[string]interface{} {
        return globalsettings
 }
 
-// LocalSettings is a list of the local only settings
-var LocalSettings = []string{"filetype", "readonly"}
-
-var defaultLocalSettings = map[string]interface{}{
-       "filetype": "unknown",
-       "readonly": false,
-}
-
-// DefaultLocalSettings returns the default local settings
-// Note that filetype is a local only option
-func DefaultLocalSettings() map[string]interface{} {
-       localsettings := make(map[string]interface{})
-       for k, v := range defaultCommonSettings {
-               localsettings[k] = v
-       }
-       for k, v := range defaultLocalSettings {
-               localsettings[k] = v
-       }
-       return localsettings
-}
-
 // DefaultAllSettings returns a map of all settings and their
-// default values (both local and global settings)
+// default values (both common and global settings)
 func DefaultAllSettings() map[string]interface{} {
        allsettings := make(map[string]interface{})
        for k, v := range defaultCommonSettings {
@@ -253,9 +240,6 @@ func DefaultAllSettings() map[string]interface{} {
        for k, v := range defaultGlobalSettings {
                allsettings[k] = v
        }
-       for k, v := range defaultLocalSettings {
-               allsettings[k] = v
-       }
        return allsettings
 }
 
index 685c1a16f5cff1cc7045850dd9870d1227d64958..85719689e0f8bfb0aade88299551c6ae3a0692ee 100644 (file)
@@ -1,7 +1,6 @@
 package display
 
 import (
-       "log"
        "strconv"
        "unicode/utf8"
 
@@ -150,27 +149,21 @@ func (w *BufWindow) Relocate() bool {
        ret := false
        activeC := w.Buf.GetActiveCursor()
        cy := activeC.Y
-       log.Println("RELOCATE", w.StartLine, cy, height)
        scrollmargin := int(b.Settings["scrollmargin"].(float64))
        if cy < w.StartLine+scrollmargin && cy > scrollmargin-1 {
-               log.Println("a")
                w.StartLine = cy - scrollmargin
                ret = true
        } else if cy < w.StartLine {
-               log.Println("b")
                w.StartLine = cy
                ret = true
        }
        if cy > w.StartLine+height-1-scrollmargin && cy < b.LinesNum()-scrollmargin {
-               log.Println("c")
                w.StartLine = cy - height + 1 + scrollmargin
                ret = true
        } else if cy >= b.LinesNum()-scrollmargin && cy >= height {
-               log.Println("d")
                w.StartLine = b.LinesNum() - height
                ret = true
        }
-       log.Println("RELOCATE DONE", w.StartLine)
 
        // horizontal relocation (scrolling)
        if !b.Settings["softwrap"].(bool) {
@@ -363,7 +356,6 @@ func (w *BufWindow) showCursor(x, y int, main bool) {
 
 // displayBuffer draws the buffer being shown in this window on the screen.Screen
 func (w *BufWindow) displayBuffer() {
-       log.Println("STARTLINE", w.StartLine)
        b := w.Buf
 
        hasMessage := len(b.Messages) > 0
index 280c6caed6da547126126852478acc98c2b13de5..bfbe43b1b98b7f32a7f0368570966b7338f6442f 100644 (file)
@@ -3,7 +3,6 @@ package util
 import (
        "errors"
        "fmt"
-       "log"
        "os"
        "os/user"
        "path/filepath"
@@ -205,7 +204,6 @@ func FSize(f *os.File) int64 {
 // IsWordChar returns whether or not the string is a 'word character'
 // Word characters are defined as numbers, letters, or '_'
 func IsWordChar(r rune) bool {
-       log.Println("IsWordChar")
        return unicode.IsLetter(r) || unicode.IsNumber(r) || r == '_'
 }