+2012-09-08 Jambunathan K <kjambunathan@gmail.com>
+
+ * regs.texi (Text Registers): `C-x r +' can now be used instead of
+ M-x append-to-register. New option `register-separator'.
+ (Number Registers): Mention that `C-x r +' is polymorphic.
+
2012-09-07 Chong Yidong <cyd@gnu.org>
* windows.texi (Window Choice): Don't mention obsolete
2012-08-24 Michael Albinus <michael.albinus@gmx.de>
- * cmdargs.texi (General Variables): Setting
- $DBUS_SESSION_BUS_ADDRESS to a dummy value suppresses connections
- to the D-Bus session bus. (Bug#12112)
+ * cmdargs.texi (General Variables):
+ Setting $DBUS_SESSION_BUS_ADDRESS to a dummy value suppresses
+ connections to the D-Bus session bus. (Bug#12112)
2012-08-14 Eli Zaretskii <eliz@gnu.org>
Insert text from register @var{r} (@code{insert-register}).
@item M-x append-to-register @key{RET} @var{r}
Append region to text in register @var{r}.
+
+@kindex C-x r +
+When register @var{r} contains text, you can use @kbd{C-x r +}
+(@code{increment-register}) to append to that register. Note that
+command @kbd{C-x r +} behaves differently if @var{r} contains a
+number. @xref{Number Registers}.
+
@item M-x prepend-to-register @key{RET} @var{r}
Prepend region to text in register @var{r}.
@end table
the region text to the text in the register instead of
@emph{appending} it.
+@vindex register-separator
+ When you are collecting text using @code{append-to-register} and
+@code{prepend-to-register}, you may want to separate individual
+collected pieces using a separator. In that case, configure a
+@code{register-separator} and store the separator text in to that
+register. For example, to get double newlines as text separator
+during the collection process, you can use the following setting.
+
+@example
+(setq register-separator ?+)
+(set-register register-separator "\n\n")
+@end example
+
@kindex C-x r i
@findex insert-register
@kbd{C-x r i @var{r}} inserts in the buffer the text from register
@item C-u @var{number} C-x r + @var{r}
@kindex C-x r +
@findex increment-register
-Increment the number in register @var{r} by @var{number}
-(@code{increment-register}).
+If @var{r} contains a number, increment the number in that register by
+@var{number}. Note that command @kbd{C-x r +}
+(@code{increment-register}) behaves differently if @var{r} contains
+text. @xref{Text Registers}.
@item C-x r i @var{r}
Insert the number from register @var{r} into the buffer.
@end table
delete-trailing-whitespace command should delete trailing lines at the
end of the buffer. It defaults to t.
++++
+** `C-x r +' is now overloaded to invoke `append-to-register.
++++
+** New option `separator-register'. Separator register stores
+separator text for use with M-x append-to-register and M-x
+prepend-to-register. See manual for details.
+
** Search changes
*** Global `M-s _' starts a symbol (identifier) incremental search,
+2012-09-08 Jambunathan K <kjambunathan@gmail.com>
+
+ * register.el (register): New group.
+ (register-separator): New user option.
+ (increment-register): Route it to `append-to-register', if
+ register contains text. Implication is that `C-x r +' can now be
+ used for appending to a text register (bug#12217).
+ (append-to-register, prepend-to-register): Add separator based on
+ `register-separator.
+
2012-09-08 Alan Mackenzie <acm@muc.de>
AWK Mode: make auto-newline work when there's "==" in the pattern.
* progmodes/cc-cmds.el (c-point-syntax): Handle virtual semicolons
correctly.
- * progmodes/cc-engine.el (c-guess-basic-syntax CASE 5A.3): Test
- more rigorously for "=" token.
+ * progmodes/cc-engine.el (c-guess-basic-syntax CASE 5A.3):
+ Test more rigorously for "=" token.
2012-09-08 Dmitry Gutov <dgutov@yandex.ru>
- * progmodes/ruby-mode.el (ruby-match-expression-expansion): Only
- fail when reached LIMIT.
+ * progmodes/ruby-mode.el (ruby-match-expression-expansion):
+ Only fail when reached LIMIT.
2012-09-08 Chong Yidong <cyd@gnu.org>
A list of the form (FRAME-CONFIGURATION POSITION)
represents a saved frame configuration plus a saved value of point.")
+(defgroup register nil
+ "Register commands."
+ :group 'convenience
+ :version "24.2.50")
+
+(defcustom separator-register nil
+ "Use contents of this register to separate collected text.
+
+When collecting text with
+`append-to-register' (resp. `prepend-to-register') contents of
+this register is added to the beginning (resp. end) of the marked
+text."
+ :group 'register
+ :type '(choice (const :tag "None" nil)
+ (character :tag "Use register" :value ?+)))
+
(defun get-register (register)
"Return contents of Emacs register named REGISTER, or nil if none."
(cdr (assq register register-alist)))
(string-to-number (match-string 0)))
0))))
-(defun increment-register (number register)
- "Add NUMBER to the contents of register REGISTER.
-Interactively, NUMBER is the prefix arg."
- (interactive "p\ncIncrement register: ")
- (or (numberp (get-register register))
- (error "Register does not contain a number"))
- (set-register register (+ number (get-register register))))
+(defun increment-register (prefix register)
+ "Augment contents of REGISTER.
+Interactively, PREFIX is in raw form.
+
+If REGISTER contains a number, add `prefix-numeric-value' of
+PREFIX to it.
+
+If REGISTER is empty or if it contains text, call
+`append-to-register' with `delete-flag' set to PREFIX."
+ (interactive "P\ncIncrement register: ")
+ (let ((register-val (get-register register)))
+ (cond
+ ((numberp register-val)
+ (let ((number (prefix-numeric-value prefix)))
+ (set-register register (+ number register-val))))
+ ((or (not register-val) (stringp register-val))
+ (append-to-register register (region-beginning) (region-end) prefix))
+ (t (error "Register does not contain a number or text")))))
(defun view-register (register)
"Display what is contained in register named REGISTER.
START and END are buffer positions indicating what to append."
(interactive "cAppend to register: \nr\nP")
(let ((reg (get-register register))
- (text (filter-buffer-substring start end)))
+ (text (filter-buffer-substring start end))
+ (separator (and separator-register (get-register separator-register))))
(set-register
register (cond ((not reg) text)
- ((stringp reg) (concat reg text))
+ ((stringp reg) (concat reg separator text))
(t (error "Register does not contain text")))))
(cond (delete-flag
(delete-region start end))
START and END are buffer positions indicating what to prepend."
(interactive "cPrepend to register: \nr\nP")
(let ((reg (get-register register))
- (text (filter-buffer-substring start end)))
+ (text (filter-buffer-substring start end))
+ (separator (and separator-register (get-register separator-register))))
(set-register
register (cond ((not reg) text)
- ((stringp reg) (concat text reg))
+ ((stringp reg) (concat text separator reg))
(t (error "Register does not contain text")))))
(cond (delete-flag
(delete-region start end))