Lists: | pgsql-hackers |
---|
From: | Peter Eisentraut <peter_e(at)gmx(dot)net> |
---|---|
To: | pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | emacs configuration for new perltidy settings |
Date: | 2012-07-11 21:35:26 |
Message-ID: | 1342042526.2712.21.camel@vanquo.pezone.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
This might be useful for some people. Here is an emacs configuration
for perl-mode that is compatible with the new perltidy settings. Note
that the default perl-mode settings produce indentation that will be
completely shredded by the new perltidy settings.
(defun pgsql-perl-style ()
"Perl style adjusted for PostgreSQL project"
(interactive)
(setq tab-width 4)
(setq perl-indent-level 4)
(setq perl-continued-statement-offset 4)
(setq perl-continued-brace-offset 4)
(setq perl-brace-offset 0)
(setq perl-brace-imaginary-offset 0)
(setq perl-label-offset -2))
(add-hook 'perl-mode-hook
(lambda ()
(if (string-match "postgresql" buffer-file-name)
(pgsql-perl-style))))
From: | Dimitri Fontaine <dimitri(at)2ndQuadrant(dot)fr> |
---|---|
To: | Peter Eisentraut <peter_e(at)gmx(dot)net> |
Cc: | pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: emacs configuration for new perltidy settings |
Date: | 2012-08-27 11:57:10 |
Message-ID: | m2txvok0o9.fsf@2ndQuadrant.fr |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
Peter Eisentraut <peter_e(at)gmx(dot)net> writes:
> This might be useful for some people. Here is an emacs configuration
> for perl-mode that is compatible with the new perltidy settings. Note
> that the default perl-mode settings produce indentation that will be
> completely shredded by the new perltidy settings.
Thanks!
--
Dimitri Fontaine
http://2ndQuadrant.fr PostgreSQL : Expertise, Formation et Support
From: | Michael Paquier <michael(dot)paquier(at)gmail(dot)com> |
---|---|
To: | Peter Eisentraut <peter_e(at)gmx(dot)net> |
Cc: | pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: emacs configuration for new perltidy settings |
Date: | 2012-08-28 05:46:21 |
Message-ID: | CAB7nPqT=CgFR0aiyZKihwi_j-7deZxZt66FDfBxurWV7YUW=OQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
On Thu, Jul 12, 2012 at 6:35 AM, Peter Eisentraut <peter_e(at)gmx(dot)net> wrote:
> This might be useful for some people. Here is an emacs configuration
> for perl-mode that is compatible with the new perltidy settings. Note
> that the default perl-mode settings produce indentation that will be
> completely shredded by the new perltidy settings.
>
> (defun pgsql-perl-style ()
> "Perl style adjusted for PostgreSQL project"
> (interactive)
> (setq tab-width 4)
> (setq perl-indent-level 4)
> (setq perl-continued-statement-offset 4)
> (setq perl-continued-brace-offset 4)
> (setq perl-brace-offset 0)
> (setq perl-brace-imaginary-offset 0)
> (setq perl-label-offset -2))
>
> (add-hook 'perl-mode-hook
> (lambda ()
> (if (string-match "postgresql" buffer-file-name)
> (pgsql-perl-style))))
>
Cool thanks!
Very helpful.
--
Michael Paquier
http://michael.otacoo.com
From: | Bruce Momjian <bruce(at)momjian(dot)us> |
---|---|
To: | Peter Eisentraut <peter_e(at)gmx(dot)net> |
Cc: | pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: emacs configuration for new perltidy settings |
Date: | 2012-08-31 01:41:19 |
Message-ID: | 20120831014119.GH32350@momjian.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
On Thu, Jul 12, 2012 at 12:35:26AM +0300, Peter Eisentraut wrote:
> This might be useful for some people. Here is an emacs configuration
> for perl-mode that is compatible with the new perltidy settings. Note
> that the default perl-mode settings produce indentation that will be
> completely shredded by the new perltidy settings.
>
> (defun pgsql-perl-style ()
> "Perl style adjusted for PostgreSQL project"
> (interactive)
> (setq tab-width 4)
> (setq perl-indent-level 4)
> (setq perl-continued-statement-offset 4)
> (setq perl-continued-brace-offset 4)
> (setq perl-brace-offset 0)
> (setq perl-brace-imaginary-offset 0)
> (setq perl-label-offset -2))
>
> (add-hook 'perl-mode-hook
> (lambda ()
> (if (string-match "postgresql" buffer-file-name)
> (pgsql-perl-style))))
Added to src/tools/editors/emacs.samples; applied patch attached.
--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com
+ It's impossible for everything to be true. +
Attachment | Content-Type | Size |
---|---|---|
perl.diff | text/x-diff | 1.4 KB |
From: | Noah Misch <noah(at)leadboat(dot)com> |
---|---|
To: | Peter Eisentraut <peter_e(at)gmx(dot)net> |
Cc: | pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: emacs configuration for new perltidy settings |
Date: | 2019-01-03 05:53:55 |
Message-ID: | 20190103055355.GB267595@gust.leadboat.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
On Thu, Jul 12, 2012 at 12:35:26AM +0300, Peter Eisentraut wrote:
> This might be useful for some people. Here is an emacs configuration
> for perl-mode that is compatible with the new perltidy settings. Note
> that the default perl-mode settings produce indentation that will be
> completely shredded by the new perltidy settings.
>
> (defun pgsql-perl-style ()
> "Perl style adjusted for PostgreSQL project"
> (interactive)
> (setq tab-width 4)
> (setq perl-indent-level 4)
> (setq perl-continued-statement-offset 4)
> (setq perl-continued-brace-offset 4)
(Later, commit 56fb890 changed perl-continued-statement-offset to 2.) This
indents braces (perltidy aligns the brace with "if", but perl-mode adds
perl-continued-statement-offset + perl-continued-brace-offset = 6 columns):
if (-s "src/backend/snowball/stopwords/$lang.stop")
{
$stop = ", StopWords=$lang";
}
If I run perltidy on 60d9979, then run perl-mode indent, the diff between the
perltidy run and perl-mode indent run is:
129 files changed, 8468 insertions(+), 8468 deletions(-)
If I add (perl-continued-brace-offset . -2):
119 files changed, 3515 insertions(+), 3515 deletions(-)
If I add (perl-indent-continued-arguments . 4) as well:
86 files changed, 2626 insertions(+), 2626 deletions(-)
If I add (perl-indent-parens-as-block . t) as well:
65 files changed, 2373 insertions(+), 2373 deletions(-)
That's with GNU Emacs 24.5.1. Versions 24.3.1 and 21.4.1 show similar trends,
though 21.4.1 predates perl-indent-continued-arguments and
perl-indent-parens-as-block.
I'm attaching the patch to make it so, along with a patch that illustrates my
testing method. "sh reindent-perl.sh" will test emacs.samples using your
Emacs installation. (I don't plan to push the testing patch.)
Attachment | Content-Type | Size |
---|---|---|
perl-mode-indent-v1.patch | text/x-diff | 1.2 KB |
test-perl-mode-indent-v1.patch | text/x-diff | 2.4 KB |
From: | Andrew Dunstan <andrew(dot)dunstan(at)2ndquadrant(dot)com> |
---|---|
To: | Noah Misch <noah(at)leadboat(dot)com>, Peter Eisentraut <peter_e(at)gmx(dot)net> |
Cc: | pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: emacs configuration for new perltidy settings |
Date: | 2019-01-08 13:17:43 |
Message-ID: | 6c5e6da6-5c15-47ff-296f-610fcc977cfd@2ndQuadrant.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
On 1/3/19 12:53 AM, Noah Misch wrote:
> On Thu, Jul 12, 2012 at 12:35:26AM +0300, Peter Eisentraut wrote:
>> This might be useful for some people. Here is an emacs configuration
>> for perl-mode that is compatible with the new perltidy settings. Note
>> that the default perl-mode settings produce indentation that will be
>> completely shredded by the new perltidy settings.
>>
>> (defun pgsql-perl-style ()
>> "Perl style adjusted for PostgreSQL project"
>> (interactive)
>> (setq tab-width 4)
>> (setq perl-indent-level 4)
>> (setq perl-continued-statement-offset 4)
>> (setq perl-continued-brace-offset 4)
> (Later, commit 56fb890 changed perl-continued-statement-offset to 2.) This
> indents braces (perltidy aligns the brace with "if", but perl-mode adds
> perl-continued-statement-offset + perl-continued-brace-offset = 6 columns):
>
> if (-s "src/backend/snowball/stopwords/$lang.stop")
> {
> $stop = ", StopWords=$lang";
> }
>
> If I run perltidy on 60d9979, then run perl-mode indent, the diff between the
> perltidy run and perl-mode indent run is:
> 129 files changed, 8468 insertions(+), 8468 deletions(-)
> If I add (perl-continued-brace-offset . -2):
> 119 files changed, 3515 insertions(+), 3515 deletions(-)
> If I add (perl-indent-continued-arguments . 4) as well:
> 86 files changed, 2626 insertions(+), 2626 deletions(-)
> If I add (perl-indent-parens-as-block . t) as well:
> 65 files changed, 2373 insertions(+), 2373 deletions(-)
>
> That's with GNU Emacs 24.5.1. Versions 24.3.1 and 21.4.1 show similar trends,
> though 21.4.1 predates perl-indent-continued-arguments and
> perl-indent-parens-as-block.
>
> I'm attaching the patch to make it so, along with a patch that illustrates my
> testing method. "sh reindent-perl.sh" will test emacs.samples using your
> Emacs installation. (I don't plan to push the testing patch.)
Sounds good. What do the remaining diffs look like?
cheers
andrew
--
Andrew Dunstan https://www.2ndQuadrant.com
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
From: | Noah Misch <noah(at)leadboat(dot)com> |
---|---|
To: | Andrew Dunstan <andrew(dot)dunstan(at)2ndquadrant(dot)com> |
Cc: | Peter Eisentraut <peter_e(at)gmx(dot)net>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: emacs configuration for new perltidy settings |
Date: | 2019-01-09 01:44:30 |
Message-ID: | 20190109014430.GB3738862@rfd.leadboat.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
On Tue, Jan 08, 2019 at 08:17:43AM -0500, Andrew Dunstan wrote:
> On 1/3/19 12:53 AM, Noah Misch wrote:
> > If I run perltidy on 60d9979, then run perl-mode indent, the diff between the
> > perltidy run and perl-mode indent run is:
> > 129 files changed, 8468 insertions(+), 8468 deletions(-)
> > If I add (perl-continued-brace-offset . -2):
> > 119 files changed, 3515 insertions(+), 3515 deletions(-)
> > If I add (perl-indent-continued-arguments . 4) as well:
> > 86 files changed, 2626 insertions(+), 2626 deletions(-)
> > If I add (perl-indent-parens-as-block . t) as well:
> > 65 files changed, 2373 insertions(+), 2373 deletions(-)
> Sounds good. What do the remaining diffs look like?
I've attached them. Most involve statement continuation in some form. For
example, src/backend/utils/mb/Unicode has numerous instances where perl-mode
indents hashref-constructor curly braces as though they were code blocks.
Other diff lines involve labels. Others are in string literals.
Attachment | Content-Type | Size |
---|---|---|
perltidy-to-perl-mode-indent.diff | text/plain | 263.2 KB |
From: | Andrew Dunstan <andrew(dot)dunstan(at)2ndquadrant(dot)com> |
---|---|
To: | Noah Misch <noah(at)leadboat(dot)com> |
Cc: | Peter Eisentraut <peter_e(at)gmx(dot)net>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: emacs configuration for new perltidy settings |
Date: | 2019-01-09 13:57:01 |
Message-ID: | 8406a21c-3488-5d9d-7119-f4b6e54af5ac@2ndQuadrant.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
On 1/8/19 8:44 PM, Noah Misch wrote:
> On Tue, Jan 08, 2019 at 08:17:43AM -0500, Andrew Dunstan wrote:
>> On 1/3/19 12:53 AM, Noah Misch wrote:
>>> If I run perltidy on 60d9979, then run perl-mode indent, the diff between the
>>> perltidy run and perl-mode indent run is:
>>> 129 files changed, 8468 insertions(+), 8468 deletions(-)
>>> If I add (perl-continued-brace-offset . -2):
>>> 119 files changed, 3515 insertions(+), 3515 deletions(-)
>>> If I add (perl-indent-continued-arguments . 4) as well:
>>> 86 files changed, 2626 insertions(+), 2626 deletions(-)
>>> If I add (perl-indent-parens-as-block . t) as well:
>>> 65 files changed, 2373 insertions(+), 2373 deletions(-)
>> Sounds good. What do the remaining diffs look like?
> I've attached them. Most involve statement continuation in some form. For
> example, src/backend/utils/mb/Unicode has numerous instances where perl-mode
> indents hashref-constructor curly braces as though they were code blocks.
> Other diff lines involve labels. Others are in string literals.
On a very quick glance I notice some things that looked just wrong, and
some that were at best dubious. It's a pity that we can't get closer to
what perltidy does, but +1 for applying your changes.
cheers
andrew
--
Andrew Dunstan https://www.2ndQuadrant.com
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services