unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#11118: New option perl-indent-parens-as-block
@ 2012-03-28 20:56 Peter Oliver
  2012-03-29 18:56 ` bug#11118: Patch Peter Oliver
  0 siblings, 1 reply; 4+ messages in thread
From: Peter Oliver @ 2012-03-28 20:56 UTC (permalink / raw)
  To: 11118

[-- Attachment #1: Type: text/plain, Size: 558 bytes --]

At present, perl-mode aligns non-block closing brackets with the contents
of the brackets, thus:

my @list = (
    'item one',
    'item two',
    'item three',
    );

Now, cperl-mode features on option, cperl-indent-parens-as-block, that
causes the closing bracket to be aligned with the line of the opening
bracket, as follows:

my @list = (
    'item one',
    'item two',
    'item three',
);

I personally find the latter behaviour easier to follow, and would like
perl-mode to be able to do the same thing.

A patch is on the way...

-- 
Peter Oliver

[-- Attachment #2: Type: text/html, Size: 704 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#11118: Patch
  2012-03-28 20:56 bug#11118: New option perl-indent-parens-as-block Peter Oliver
@ 2012-03-29 18:56 ` Peter Oliver
  2012-03-30  3:34   ` Stefan Monnier
  0 siblings, 1 reply; 4+ messages in thread
From: Peter Oliver @ 2012-03-29 18:56 UTC (permalink / raw)
  To: 11118


[-- Attachment #1.1: Type: text/plain, Size: 1 bytes --]



[-- Attachment #1.2: Type: text/html, Size: 5 bytes --]

[-- Attachment #2: emacs-perl-indent-parens-as-block.diff --]
[-- Type: application/octet-stream, Size: 2562 bytes --]

=== modified file 'etc/NEWS'
--- etc/NEWS	2012-03-27 20:24:48 +0000
+++ etc/NEWS	2012-03-28 21:12:42 +0000
@@ -784,6 +784,11 @@
 If `nxml-bind-meta-tab-to-complete-flag' is non-nil (the default),
 this performs tag completion.
 
+** Perl mode
+
+*** There is a new option, perl-indent-parens-as-block, which causes
+non-block closing brackets to be aligned with the line of the opening bracket.
+
 ---
 ** Prolog mode has been completely revamped, with lots of additional
 functionality such as more intelligent indentation, electricity, support for

=== modified file 'lisp/ChangeLog'
--- lisp/ChangeLog	2012-03-29 14:00:00 +0000
+++ lisp/ChangeLog	2012-03-29 18:46:19 +0000
@@ -1,3 +1,9 @@
+2012-03-28  Peter Oliver  <bzr@mavit.org.uk>
+
+	* progmodes/perl-mode.el (perl-indent-parens-as-block): New option
+	to align non-block closing brackets with the opening line
+	(bug#11118).
+
 2012-03-28  Sam Steingold  <sds@gnu.org>
 
 	* calendar/calendar.el (calendar-exit): Use `quit-windows-on'

=== modified file 'lisp/progmodes/perl-mode.el'
--- lisp/progmodes/perl-mode.el	2012-03-15 03:09:26 +0000
+++ lisp/progmodes/perl-mode.el	2012-03-28 20:28:08 +0000
@@ -510,6 +510,12 @@
 If nil, continued arguments are aligned with the first argument."
   :type '(choice integer (const nil))
   :group 'perl)
+(defcustom perl-indent-parens-as-block nil
+  "*Non-nil means that non-block ()-, {}- and []-groups are indented as blocks.
+The closing bracket is aligned with the line of the opening
+bracket, not the contents of the brackets."
+  :type 'boolean
+  :group 'perl)
 
 (defcustom perl-tab-always-indent tab-always-indent
   "Non-nil means TAB in Perl mode always indents the current line.
@@ -852,7 +858,8 @@
       (cond ((nth 3 state) state)	; In a quoted string?
 	    ((null containing-sexp)	; Line is at top level.
 	     (skip-chars-forward " \t\f")
-	     (if (= (following-char) ?{)
+	     (if (memq (following-char)
+		       (if perl-indent-parens-as-block '(?\{ ?\( ?\[) '(?\{)))
 		 0  ; move to beginning of line if it starts a function body
 	       ;; indent a little if this is a continuation line
 	       (perl-backward-to-noncomment)
@@ -896,7 +903,9 @@
 			  0 perl-continued-statement-offset)
 		      (current-column)
 		      (if (save-excursion (goto-char indent-point)
-					  (looking-at "[ \t]*{"))
+					  (looking-at 
+					   (if perl-indent-parens-as-block
+					       "[ \t]*[{(\[]" "[ \t]*{")))
 			  perl-continued-brace-offset 0)))
 	       ;; This line starts a new statement.
 	       ;; Position at last unclosed open.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#11118: Patch
  2012-03-29 18:56 ` bug#11118: Patch Peter Oliver
@ 2012-03-30  3:34   ` Stefan Monnier
  2012-04-17  2:48     ` Glenn Morris
  0 siblings, 1 reply; 4+ messages in thread
From: Stefan Monnier @ 2012-03-30  3:34 UTC (permalink / raw)
  To: Peter Oliver; +Cc: 11118

tags 11118 pending
thanks

The patch looks very good.  We can't install it just now because we're
in feature freeze, so we'll keep it for when the trunk opens again for
new features.
Thank you,


        Stefan


>>>>> "Peter" == Peter Oliver <p.d.oliver@mavit.org.uk> writes:

> === modified file 'etc/NEWS'
> --- etc/NEWS	2012-03-27 20:24:48 +0000
> +++ etc/NEWS	2012-03-28 21:12:42 +0000
> @@ -784,6 +784,11 @@
>  If `nxml-bind-meta-tab-to-complete-flag' is non-nil (the default),
>  this performs tag completion.
 
> +** Perl mode
> +
> +*** There is a new option, perl-indent-parens-as-block, which causes
> +non-block closing brackets to be aligned with the line of the opening bracket.
> +
>  ---
>  ** Prolog mode has been completely revamped, with lots of additional
>  functionality such as more intelligent indentation, electricity, support for

> === modified file 'lisp/ChangeLog'
> --- lisp/ChangeLog	2012-03-29 14:00:00 +0000
> +++ lisp/ChangeLog	2012-03-29 18:46:19 +0000
> @@ -1,3 +1,9 @@
> +2012-03-28  Peter Oliver  <bzr@mavit.org.uk>
> +
> +	* progmodes/perl-mode.el (perl-indent-parens-as-block): New option
> +	to align non-block closing brackets with the opening line
> +	(bug#11118).
> +
>  2012-03-28  Sam Steingold  <sds@gnu.org>
 
>  	* calendar/calendar.el (calendar-exit): Use `quit-windows-on'

> === modified file 'lisp/progmodes/perl-mode.el'
> --- lisp/progmodes/perl-mode.el	2012-03-15 03:09:26 +0000
> +++ lisp/progmodes/perl-mode.el	2012-03-28 20:28:08 +0000
> @@ -510,6 +510,12 @@
>  If nil, continued arguments are aligned with the first argument."
>    :type '(choice integer (const nil))
>    :group 'perl)
> +(defcustom perl-indent-parens-as-block nil
> +  "*Non-nil means that non-block ()-, {}- and []-groups are indented as blocks.
> +The closing bracket is aligned with the line of the opening
> +bracket, not the contents of the brackets."
> +  :type 'boolean
> +  :group 'perl)
 
>  (defcustom perl-tab-always-indent tab-always-indent
>    "Non-nil means TAB in Perl mode always indents the current line.
> @@ -852,7 +858,8 @@
>        (cond ((nth 3 state) state)	; In a quoted string?
>  	    ((null containing-sexp)	; Line is at top level.
>  	     (skip-chars-forward " \t\f")
> -	     (if (= (following-char) ?{)
> +	     (if (memq (following-char)
> +		       (if perl-indent-parens-as-block '(?\{ ?\( ?\[) '(?\{)))
>  		 0  ; move to beginning of line if it starts a function body
>  	       ;; indent a little if this is a continuation line
>  	       (perl-backward-to-noncomment)
> @@ -896,7 +903,9 @@
>  			  0 perl-continued-statement-offset)
>  		      (current-column)
>  		      (if (save-excursion (goto-char indent-point)
> -					  (looking-at "[ \t]*{"))
> +					  (looking-at 
> +					   (if perl-indent-parens-as-block
> +					       "[ \t]*[{(\[]" "[ \t]*{")))
>  			  perl-continued-brace-offset 0)))
>  	       ;; This line starts a new statement.
>  	       ;; Position at last unclosed open.






^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#11118: Patch
  2012-03-30  3:34   ` Stefan Monnier
@ 2012-04-17  2:48     ` Glenn Morris
  0 siblings, 0 replies; 4+ messages in thread
From: Glenn Morris @ 2012-04-17  2:48 UTC (permalink / raw)
  To: 11118-done

Version: 24.2

Thanks; applied to trunk, so expect it in 24.2.
Thanks especially for including ChangeLog and NEWS entries.
The only thing you forgot was the :version tag. :)

BTW, we would need an FSF copyright assignment to accept any further
patches from you. It's straightforward to do - let me know off-list if
you want.





^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-04-17  2:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-28 20:56 bug#11118: New option perl-indent-parens-as-block Peter Oliver
2012-03-29 18:56 ` bug#11118: Patch Peter Oliver
2012-03-30  3:34   ` Stefan Monnier
2012-04-17  2:48     ` Glenn Morris

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).