emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] trunk r115659: Tweak C-x TAB behavior changes, and update


From: Chong Yidong
Subject: [Emacs-diffs] trunk r115659: Tweak C-x TAB behavior changes, and update docs.
Date: Sat, 21 Dec 2013 08:37:21 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 115659
revision-id: address@hidden
parent: address@hidden
committer: Chong Yidong <address@hidden>
branch nick: trunk
timestamp: Sat 2013-12-21 16:37:08 +0800
message:
  Tweak C-x TAB behavior changes, and update docs.
  
  * lisp/indent.el (indent-rigidly-map): Add docstring, and move commands
  into named functions.
  (indent-rigidly-left, indent-rigidly-right)
  (indent-rigidly-left-to-tab-stop)
  (indent-rigidly-right-to-tab-stop): New functions.  Decide on
  indentation direction based on bidi direction, and accumulate
  sequential commands in a single undo boundary.
  (indent-rigidly--pop-undo): New utility function.
  
  * doc/emacs/indent.texi (Indentation Commands): Document C-x TAB changes.
  
  * doc/lispref/text.texi (Region Indent): Note the new interactive
  behavior of indent-rigidly.
modified:
  doc/emacs/ChangeLog            changelog-20091113204419-o5vbwnq5f7feedwu-6227
  doc/emacs/indent.texi          
indent.texi-20091113204419-o5vbwnq5f7feedwu-6257
  doc/lispref/ChangeLog          changelog-20091113204419-o5vbwnq5f7feedwu-6155
  doc/lispref/text.texi          text.texi-20091113204419-o5vbwnq5f7feedwu-6215
  lisp/ChangeLog                 changelog-20091113204419-o5vbwnq5f7feedwu-1432
  lisp/indent.el                 indent.el-20091113204419-o5vbwnq5f7feedwu-230
=== modified file 'doc/emacs/ChangeLog'
--- a/doc/emacs/ChangeLog       2013-12-20 16:03:12 +0000
+++ b/doc/emacs/ChangeLog       2013-12-21 08:37:08 +0000
@@ -1,3 +1,7 @@
+2013-12-21  Chong Yidong  <address@hidden>
+
+       * indent.texi (Indentation Commands): Document C-x TAB changes.
+
 2013-12-20  Tassilo Horn  <address@hidden>
 
        * rmail.texi: Document `S-SPC' as alternative to scrolling down

=== modified file 'doc/emacs/indent.texi'
--- a/doc/emacs/indent.texi     2013-12-20 14:56:23 +0000
+++ b/doc/emacs/indent.texi     2013-12-21 08:37:08 +0000
@@ -127,14 +127,26 @@
 @kindex C-x TAB
 @findex indent-rigidly
 @cindex remove indentation
-Shift each line in the region by a fixed distance, to the right or
-left (@code{indent-rigidly}).  The distance to move is determined by
-the numeric argument (positive to move rightward, negative to move
-leftward).
-
-This command can be used to remove all indentation from the lines in
-the region, by invoking it with a large negative argument,
-e.g., @kbd{C-u -1000 C-x @key{TAB}}.
+This command is used to change the indentation of all lines that begin
+in the region, moving the affected lines as a ``rigid'' unit.
+
+If called with no argument, the command activates a transient mode for
+adjusting the indentation of the affected lines interactively.  While
+this transient mode is active, typing @key{LEFT} or @key{RIGHT}
+indents leftward and rightward, respectively, by one space.  You can
+also type @address@hidden or @address@hidden to indent leftward
+or rightward to the next tab stop (@pxref{Tab Stops}).  Typing any
+other key disables the transient mode, and resumes normal editing.
+
+If called with a prefix argument @var{n}, this command indents the
+lines forward by @var{n} spaces (without enabling the transient mode).
+Negative values of @var{n} indent backward, so you can remove all
+indentation from the lines in the region using a large negative
+argument, like this:
+
address@hidden
+C-u -999 C-x @key{TAB}
address@hidden smallexample
 @end table
 
 @node Tab Stops

=== modified file 'doc/lispref/ChangeLog'
--- a/doc/lispref/ChangeLog     2013-12-20 18:41:31 +0000
+++ b/doc/lispref/ChangeLog     2013-12-21 08:37:08 +0000
@@ -1,3 +1,8 @@
+2013-12-21  Chong Yidong  <address@hidden>
+
+       * text.texi (Region Indent): Note the new interactive behavior of
+       indent-rigidly.
+
 2013-12-20  Tassilo Horn  <address@hidden>
 
        * numbers.texi (numbers): Document that =, <, <=, >, >= now accept

=== modified file 'doc/lispref/text.texi'
--- a/doc/lispref/text.texi     2013-12-20 07:12:04 +0000
+++ b/doc/lispref/text.texi     2013-12-21 08:37:08 +0000
@@ -2344,21 +2344,19 @@
 @end defvar
 
 @deffn Command indent-rigidly start end count
-This command indents all lines starting between @var{start}
+This function indents all lines starting between @var{start}
 (inclusive) and @var{end} (exclusive) sideways by @var{count} columns.
 This ``preserves the shape'' of the affected region, moving it as a
-rigid unit.  Consequently, this command is useful not only for indenting
-regions of unindented text, but also for indenting regions of formatted
-code.
-
-For example, if @var{count} is 3, this command adds 3 columns of
-indentation to each of the lines beginning in the region specified.
-
address@hidden FIXME: I suggest using message-indent-citation as the example, or
address@hidden just remove this paragraph.  --xfq
-In Mail mode, @kbd{C-c C-y} (@code{mail-yank-original}) uses
address@hidden to indent the text copied from the message being
-replied to.
+rigid unit.
+
+This is useful not only for indenting regions of unindented text, but
+also for indenting regions of formatted code.  For example, if
address@hidden is 3, this command adds 3 columns of indentation to every
+line that begins in the specified region.
+
+If called interactively with no prefix argument, this command invokes
+a transient mode for adjusting indentation rigidly.  @xref{Indentation
+Commands,,, emacs, The GNU Emacs Manual}.
 @end deffn
 
 @deffn Command indent-code-rigidly start end columns &optional nochange-regexp

=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2013-12-20 23:06:17 +0000
+++ b/lisp/ChangeLog    2013-12-21 08:37:08 +0000
@@ -1,3 +1,14 @@
+2013-12-21  Chong Yidong  <address@hidden>
+
+       * indent.el (indent-rigidly-map): Add docstring, and move commands
+       into named functions.
+       (indent-rigidly-left, indent-rigidly-right)
+       (indent-rigidly-left-to-tab-stop)
+       (indent-rigidly-right-to-tab-stop): New functions.  Decide on
+       indentation direction based on bidi direction, and accumulate
+       sequential commands in a single undo boundary.
+       (indent-rigidly--pop-undo): New utility function.
+
 2013-12-20  Juanma Barranquero  <address@hidden>
 
        * faces.el (read-face-name): Require crm.el when using crm-separator.

=== modified file 'lisp/indent.el'
--- a/lisp/indent.el    2013-12-13 01:54:09 +0000
+++ b/lisp/indent.el    2013-12-21 08:37:08 +0000
@@ -169,31 +169,28 @@
 
 (defvar indent-rigidly-map
   (let ((map (make-sparse-keymap)))
-    (define-key map [left]
-      (lambda (beg end) (interactive "r") (indent-rigidly beg end -1)))
-
-    (define-key map [right]
-      (lambda (beg end) (interactive "r") (indent-rigidly beg end 1)))
-
-    (define-key map [S-right]
-      (lambda (beg end) (interactive "r")
-        (let* ((current (indent-rigidly--current-indentation beg end))
-               (next (indent--next-tab-stop current)))
-          (indent-rigidly beg end (- next current)))))
-
-    (define-key map [S-left]
-      (lambda (beg end) (interactive "r")
-        (let* ((current (indent-rigidly--current-indentation beg end))
-               (next (indent--next-tab-stop current 'prev)))
-          (indent-rigidly beg end (- next current)))))
-    map))
+    (define-key map [left]  'indent-rigidly-left)
+    (define-key map [right] 'indent-rigidly-right)
+    (define-key map [S-left]  'indent-rigidly-left-to-tab-stop)
+    (define-key map [S-right] 'indent-rigidly-right-to-tab-stop)
+    map)
+  "Transient keymap for adjusting indentation interactively.
+It is activated by calling `indent-rigidly' interactively.")
 
 (defun indent-rigidly (start end arg &optional interactive)
-  "Indent all lines starting in the region sideways by ARG columns.
-Called from a program, takes three arguments, START, END and ARG.
-You can remove all indentation from a region by giving a large negative ARG.
-If used interactively and no prefix argument is given, use a transient
-mode that lets you move the text with cursor keys."
+  "Indent all lines starting in the region.
+If called interactively with no prefix argument, activate a
+transient mode in which the indentation can be adjusted interactively
+by typing \\<indent-rigidly-map>\\[indent-rigidly-left], 
\\[indent-rigidly-right], \\[indent-rigidly-left-to-tab-stop], or 
\\[indent-rigidly-right-to-tab-stop].
+Typing any other key deactivates the transient mode.
+
+If called from a program, or interactively with prefix ARG,
+indent all lines starting in the region forward by ARG columns.
+If called from a program, START and END specify the beginning and
+end of the text to act on, in place of the region.
+
+Negative values of ARG indent backward, so you can remove all
+indentation by specifying a large negative ARG."
   (interactive "r\nP\np")
   (if (and (not arg) interactive)
       (progn
@@ -217,6 +214,48 @@
         (forward-line 1))
       (move-marker end nil))))
 
+(defun indent-rigidly--pop-undo ()
+  (and (memq last-command '(indent-rigidly-left indent-rigidly-right
+                           indent-rigidly-left-to-tab-stop
+                           indent-rigidly-right-to-tab-stop))
+       (consp buffer-undo-list)
+       (eq (car buffer-undo-list) nil)
+       (pop buffer-undo-list)))
+
+(defun indent-rigidly-left (beg end)
+  "Indent all lines between BEG and END leftward by one space."
+  (interactive "r")
+  (indent-rigidly--pop-undo)
+  (indent-rigidly
+   beg end
+   (if (eq (current-bidi-paragraph-direction) 'right-to-left) 1 -1)))
+
+(defun indent-rigidly-right (beg end)
+  "Indent all lines between BEG and END rightward by one space."
+  (interactive "r")
+  (indent-rigidly--pop-undo)
+  (indent-rigidly
+   beg end
+   (if (eq (current-bidi-paragraph-direction) 'right-to-left) -1 1)))
+
+(defun indent-rigidly-left-to-tab-stop (beg end)
+  "Indent all lines between BEG and END leftward to a tab stop."
+  (interactive "r")
+  (indent-rigidly--pop-undo)
+  (let* ((current (indent-rigidly--current-indentation beg end))
+        (rtl (eq (current-bidi-paragraph-direction) 'right-to-left))
+        (next (indent--next-tab-stop current (if rtl nil 'prev))))
+    (indent-rigidly beg end (- next current))))
+
+(defun indent-rigidly-right-to-tab-stop (beg end)
+  "Indent all lines between BEG and END rightward to a tab stop."
+  (interactive "r")
+  (indent-rigidly--pop-undo)
+  (let* ((current (indent-rigidly--current-indentation beg end))
+        (rtl (eq (current-bidi-paragraph-direction) 'right-to-left))
+        (next (indent--next-tab-stop current (if rtl 'prev))))
+    (indent-rigidly beg end (- next current))))
+
 (defun indent-line-to (column)
   "Indent current line to COLUMN.
 This function removes or adds spaces and tabs at beginning of line


reply via email to

[Prev in Thread] Current Thread [Next in Thread]