summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Oliver <bzr@mavit.org.uk>2012-04-16 19:46:22 -0700
committerGlenn Morris <rgm@gnu.org>2012-04-16 19:46:22 -0700
commitfc72b15c777af496e9dcbc240f424135379ba955 (patch)
treeec1f137c47d4e9193d9dad8a2ffbd4e38743ff60
parent12e10e61a507c695f6b21f19accb6d6bb7e7e156 (diff)
downloademacs-fc72b15c777af496e9dcbc240f424135379ba955.tar.gz
emacs-fc72b15c777af496e9dcbc240f424135379ba955.tar.bz2
emacs-fc72b15c777af496e9dcbc240f424135379ba955.zip
Add perl-indent-parens-as-block option (tiny change)
* lisp/progmodes/perl-mode.el (perl-indent-parens-as-block): New option. (perl-calculate-indent): Respect it. Fixes: debbugs:11118
-rw-r--r--etc/NEWS5
-rw-r--r--lisp/ChangeLog6
-rw-r--r--lisp/progmodes/perl-mode.el15
3 files changed, 23 insertions, 3 deletions
diff --git a/etc/NEWS b/etc/NEWS
index 2ac4b187381..5c2bb83e2a3 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -70,7 +70,10 @@ channel keys found, if any.
** The `server-auth-key' variable can be used to set a permanent
shared key for Emacs Server.
-
+
+** In Perl mode, new option `perl-indent-parens-as-block' causes non-block
+closing brackets to be aligned with the line of the opening bracket.
+
** Obsolete packages:
*** mailpost.el
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 4a9aee338ae..90f48d2ab1e 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,9 @@
+2012-04-17 Peter Oliver <bzr@mavit.org.uk> (tiny change)
+
+ * progmodes/perl-mode.el (perl-indent-parens-as-block):
+ New option (bug#11118).
+ (perl-calculate-indent): Respect it.
+
2012-04-17 Glenn Morris <rgm@gnu.org>
* dired-aux.el (dired-mark-read-string): Doc fix.
diff --git a/lisp/progmodes/perl-mode.el b/lisp/progmodes/perl-mode.el
index cfca438a44b..9df9943cc00 100644
--- a/lisp/progmodes/perl-mode.el
+++ b/lisp/progmodes/perl-mode.el
@@ -506,6 +506,14 @@ 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."
+ :version "24.2"
+ :type 'boolean
+ :group 'perl)
+
(defcustom perl-tab-always-indent tab-always-indent
"Non-nil means TAB in Perl mode always indents the current line.
Otherwise it inserts a tab character if you type it past the first
@@ -848,7 +856,8 @@ Optional argument PARSE-START should be the position of `beginning-of-defun'."
(cond ((nth 3 state) 'noindent) ; 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)
@@ -892,7 +901,9 @@ Optional argument PARSE-START should be the position of `beginning-of-defun'."
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.