Thread: pgindent and tabs in comments
Apparently, pgindent replaces multiple spaces in comments by a tab (possibly subject to additional logic). An example among thousands: http://git.postgresql.org/gitweb?p=postgresql.git;a=blobdiff_plain;f=src/backend/access/gin/ginentrypage.c;h=c23415c0075b5ec52f08e8ef698f7b7ec2f97b19;hp=5cbbc7455519eba6c37be465784a02b350065716;hb=aa1e9bb51c102b239340992f2fcce138edb39d8a;hpb=03ee49a016e69e7594978352df6da4e0bbd7d04a (or just rgrep -F '.<TAB>' the tree to see more). This doesn't make any sense to me. Could this please be fixed, and if possible reverted sometime?
Peter Eisentraut wrote: > Apparently, pgindent replaces multiple spaces in comments by a tab > (possibly subject to additional logic). An example among thousands: > > http://git.postgresql.org/gitweb?p=postgresql.git;a=blobdiff_plain;f=src/backend/access/gin/ginentrypage.c;h=c23415c0075b5ec52f08e8ef698f7b7ec2f97b19;hp=5cbbc7455519eba6c37be465784a02b350065716;hb=aa1e9bb51c102b239340992f2fcce138edb39d8a;hpb=03ee49a016e69e7594978352df6da4e0bbd7d04a > > (or just rgrep -F '.<TAB>' the tree to see more). > > This doesn't make any sense to me. Could this please be fixed, and if > possible reverted sometime? Oh, that is an interesting example. What the code does is if there are several spaces and the next word is on a tab stop, the spaces are convered to tabs, except if we are in a string. This conversion is done by 'entab' which we distribute in src/tools. I am unclear how to fix this _except_ to remove all tabs if the line starts with '*', but that isn't foolproof, e.g.: *var = 12; -- Bruce Momjian <bruce@momjian.us> http://momjian.us EnterpriseDB http://enterprisedb.com
On tor, 2010-04-15 at 20:56 -0400, Bruce Momjian wrote: > Peter Eisentraut wrote: > > Apparently, pgindent replaces multiple spaces in comments by a tab > > (possibly subject to additional logic). An example among thousands: > > > > http://git.postgresql.org/gitweb?p=postgresql.git;a=blobdiff_plain;f=src/backend/access/gin/ginentrypage.c;h=c23415c0075b5ec52f08e8ef698f7b7ec2f97b19;hp=5cbbc7455519eba6c37be465784a02b350065716;hb=aa1e9bb51c102b239340992f2fcce138edb39d8a;hpb=03ee49a016e69e7594978352df6da4e0bbd7d04a > > > > (or just rgrep -F '.<TAB>' the tree to see more). > > > > This doesn't make any sense to me. Could this please be fixed, and if > > possible reverted sometime? > > Oh, that is an interesting example. What the code does is if there are > several spaces and the next word is on a tab stop, the spaces are > convered to tabs, except if we are in a string. This conversion is done > by 'entab' which we distribute in src/tools. I am unclear how to fix > this _except_ to remove all tabs if the line starts with '*', but that > isn't foolproof, e.g.: > > *var = 12; Yeah, that explains it. I don't have a good solution, unless entab wants to keep track when it's inside a comment.
Peter Eisentraut wrote: > On tor, 2010-04-15 at 20:56 -0400, Bruce Momjian wrote: > > Peter Eisentraut wrote: > > > Apparently, pgindent replaces multiple spaces in comments by a tab > > > (possibly subject to additional logic). An example among thousands: > > > > > > http://git.postgresql.org/gitweb?p=postgresql.git;a=blobdiff_plain;f=src/backend/access/gin/ginentrypage.c;h=c23415c0075b5ec52f08e8ef698f7b7ec2f97b19;hp=5cbbc7455519eba6c37be465784a02b350065716;hb=aa1e9bb51c102b239340992f2fcce138edb39d8a;hpb=03ee49a016e69e7594978352df6da4e0bbd7d04a > > > > > > (or just rgrep -F '.<TAB>' the tree to see more). > > > > > > This doesn't make any sense to me. Could this please be fixed, and if > > > possible reverted sometime? > > > > Oh, that is an interesting example. What the code does is if there are > > several spaces and the next word is on a tab stop, the spaces are > > convered to tabs, except if we are in a string. This conversion is done > > by 'entab' which we distribute in src/tools. I am unclear how to fix > > this _except_ to remove all tabs if the line starts with '*', but that > > isn't foolproof, e.g.: > > > > *var = 12; > > Yeah, that explains it. I don't have a good solution, unless entab > wants to keep track when it's inside a comment. I could add that code, but right now it isn't there. -- Bruce Momjian <bruce@momjian.us> http://momjian.us EnterpriseDB http://enterprisedb.com
On mån, 2010-04-19 at 21:25 -0400, Bruce Momjian wrote: > > > Oh, that is an interesting example. What the code does is if there are > > > several spaces and the next word is on a tab stop, the spaces are > > > convered to tabs, except if we are in a string. This conversion is done > > > by 'entab' which we distribute in src/tools. I am unclear how to fix > > > this _except_ to remove all tabs if the line starts with '*', but that > > > isn't foolproof, e.g.: > > > > > > *var = 12; > > > > Yeah, that explains it. I don't have a good solution, unless entab > > wants to keep track when it's inside a comment. > > I could add that code, but right now it isn't there. If you want to, I would appreciate it. But it's not high priority.