summaryrefslogtreecommitdiff
path: root/lisp/progmodes/delphi.el
diff options
context:
space:
mode:
authorSimon South <ssouth@slowcomputing.org>2009-09-11 02:28:50 +0000
committerSimon South <ssouth@slowcomputing.org>2009-09-11 02:28:50 +0000
commit07db58574f8d53a51e849aa6943cdbb91db6761f (patch)
treea66241bf7207c6dfcecceaebff0d4a900546f94a /lisp/progmodes/delphi.el
parent66d77eda77b4a92e0e1f9782e895ab0d98ba59bc (diff)
downloademacs-07db58574f8d53a51e849aa6943cdbb91db6761f.tar.gz
emacs-07db58574f8d53a51e849aa6943cdbb91db6761f.tar.bz2
emacs-07db58574f8d53a51e849aa6943cdbb91db6761f.zip
(delphi-tab): Indent region when Transient Mark mode is enabled and
region is active; otherwise indent or insert TAB as usual. (delphi-mode): Update description of TAB-key binding.
Diffstat (limited to 'lisp/progmodes/delphi.el')
-rw-r--r--lisp/progmodes/delphi.el26
1 files changed, 18 insertions, 8 deletions
diff --git a/lisp/progmodes/delphi.el b/lisp/progmodes/delphi.el
index 4c721fc622e..c5a38607b38 100644
--- a/lisp/progmodes/delphi.el
+++ b/lisp/progmodes/delphi.el
@@ -1652,14 +1652,23 @@ before the indent, the point is moved to the indent."
(defun delphi-tab ()
- "Indent the current line or insert a TAB, depending on the value of
-`delphi-tab-always-indents' and the current line position."
+ "Indent the region, when Transient Mark mode is enabled and the region is
+active. Otherwise, indent the current line or insert a TAB, depending on the
+value of `delphi-tab-always-indents' and the current line position."
(interactive)
- (if (or delphi-tab-always-indents ; We are always indenting
- ;; Or we are before the first non-space character on the line.
- (save-excursion (skip-chars-backward delphi-space-chars) (bolp)))
- (delphi-indent-line)
- (insert "\t")))
+ (cond ((use-region-p)
+ ;; If Transient Mark mode is enabled and the region is active, indent
+ ;; the entire region.
+ (indent-region (region-beginning) (region-end)))
+ ((or delphi-tab-always-indents
+ (save-excursion (skip-chars-backward delphi-space-chars) (bolp)))
+ ;; Otherwise, if we are configured always to indent (regardless of the
+ ;; point's position in the line) or we are before the first non-space
+ ;; character on the line, indent the line.
+ (delphi-indent-line))
+ (t
+ ;; Otherwise, insert a tab character.
+ (insert "\t"))))
(defun delphi-is-directory (path)
@@ -1935,7 +1944,8 @@ This is ok since we do our own keyword/comment/string face coloring.")
;;;###autoload
(defun delphi-mode (&optional skip-initial-parsing)
"Major mode for editing Delphi code. \\<delphi-mode-map>
-\\[delphi-tab]\t- Indents the current line for Delphi code.
+\\[delphi-tab]\t- Indents the current line (or region, if Transient Mark mode
+\t is enabled and the region is active) of Delphi code.
\\[delphi-find-unit]\t- Search for a Delphi source file.
\\[delphi-fill-comment]\t- Fill the current comment.
\\[delphi-new-comment-line]\t- If in a // comment, do a new comment line.