mirror of
https://github.com/zyedidia/micro.git
synced 2026-03-22 00:37:12 +09:00
Added option to automatically save files with sucmd
This commit is contained in:
@@ -994,7 +994,12 @@ func (v *View) saveToFile(filename string) {
|
||||
err := v.Buf.SaveAs(filename)
|
||||
if err != nil {
|
||||
if strings.HasSuffix(err.Error(), "permission denied") {
|
||||
choice, _ := messenger.YesNoPrompt("Permission denied. Do you want to save this file using sudo? (y,n)")
|
||||
var choice bool
|
||||
if globalSettings["autosu"].(bool) {
|
||||
choice = true
|
||||
} else {
|
||||
choice, _ = messenger.YesNoPrompt("Permission denied. Do you want to save this file using sudo? (y,n)")
|
||||
}
|
||||
if choice {
|
||||
err = v.Buf.SaveAsWithSudo(filename)
|
||||
if err != nil {
|
||||
|
||||
@@ -236,6 +236,7 @@ func DefaultGlobalSettings() map[string]interface{} {
|
||||
"splitright": true,
|
||||
"statusline": true,
|
||||
"sucmd": "sudo",
|
||||
"autosu": false,
|
||||
"syntax": true,
|
||||
"tabmovement": false,
|
||||
"tabsize": float64(4),
|
||||
|
||||
@@ -210,6 +210,10 @@ Here are the options that you can set:
|
||||
|
||||
default value: `sudo`
|
||||
|
||||
* `autosu`: defines whether super user saving should be used automatically.
|
||||
|
||||
default value: `false`
|
||||
|
||||
* `tabmovement`: navigate spaces at the beginning of lines as if they are tabs
|
||||
(e.g. move over 4 spaces at once). This option only does anything if
|
||||
`tabstospaces` is on.
|
||||
|
||||
Reference in New Issue
Block a user