Re: mg(1) tell make-backup-files is on by default

2019-11-08 Thread Sebastian Benoit
Solene Rapenne(sol...@perso.pw) on 2019.11.08 18:39:20 +0100:
> Someone on reddit had issue with this config file, there was no backup
> file, in file directory or in ~/.mg.d
> 
> make-backup-files
> backup-to-home-directory
> 
> in fact, having "make-backup-files" disables backups.
> 
> 
> I've looked at the mg logic for backup files and I could sort that the
> default make-backup-files value is 0
> 
> /funmap.c: {makebkfile, "make-backup-files", 0},

No, that 0 is not the default. The line defines a command
'make-backup-files' (that can be given in the config file, but also with
"Meta-x make-backup-files"). The 0 indicates to the command parser that
this command does not take a argument, i.e. is a "toggle". When the command
is given, the makebkfile() is called.

> but in file.c there is a statement with a default to TRUE
> 
>  * Save the contents of the current buffer back into its associated
>  * file.
>   */
>   static int  makebackup = TRUE;
> 
> 
> I don't really get the logic here, nor when the configuration file and
> that TRUE variable get in touch.

in the file.c function makebkfile() which modifies the static variable
makebackup.

So yes, the default is TRUE and the command make-backup-files changes the
variable makebackup in makebkfile():

makebackup = !makebackup;

> What I propose is to update the manual that make-backup-files is true by
> default, so toggling it disable backups.

I think that is the correct sollution. ok benno@
 
> Index: mg.1
> ===
> RCS file: /data/cvs/src/usr.bin/mg/mg.1,v
> retrieving revision 1.117
> diff -u -p -r1.117 mg.1
> --- mg.1  2 Jul 2019 16:25:39 -   1.117
> +++ mg.1  8 Nov 2019 17:16:47 -
> @@ -688,6 +688,7 @@ Bind a key mapping in the local (topmost
>  Unbind a key mapping in the local (topmost) mode.
>  .It make-backup-files
>  Toggle generation of backup files.
> +Enabled by default.
>  .It make-directory
>  Prompt the user for a path or directory name which is then created.
>  .It mark-paragraph
> 



mg(1) tell make-backup-files is on by default

2019-11-08 Thread Solene Rapenne
Someone on reddit had issue with this config file, there was no backup
file, in file directory or in ~/.mg.d

make-backup-files
backup-to-home-directory

in fact, having "make-backup-files" disables backups.


I've looked at the mg logic for backup files and I could sort that the
default make-backup-files value is 0

/funmap.c: {makebkfile, "make-backup-files", 0},

but in file.c there is a statement with a default to TRUE

 * Save the contents of the current buffer back into its associated
 * file.
  */
  static int  makebackup = TRUE;


I don't really get the logic here, nor when the configuration file and
that TRUE variable get in touch.

What I propose is to update the manual that make-backup-files is true by
default, so toggling it disable backups.


Index: mg.1
===
RCS file: /data/cvs/src/usr.bin/mg/mg.1,v
retrieving revision 1.117
diff -u -p -r1.117 mg.1
--- mg.12 Jul 2019 16:25:39 -   1.117
+++ mg.18 Nov 2019 17:16:47 -
@@ -688,6 +688,7 @@ Bind a key mapping in the local (topmost
 Unbind a key mapping in the local (topmost) mode.
 .It make-backup-files
 Toggle generation of backup files.
+Enabled by default.
 .It make-directory
 Prompt the user for a path or directory name which is then created.
 .It mark-paragraph