Commit 0979429b authored by Jambunathan K's avatar Jambunathan K Committed by Stefan Monnier

* lisp/register.el (increment-register): Route it to `append-to-register',

if register contains text so that `C-x r +' can now be
used for appending to a text register.
(register): New group.
(register-separator): New user option.
(append-to-register, prepend-to-register): Add separator based on
`register-separator.
* doc/emacs/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.

Fixes: debbugs:12217
parent ace2989a
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
......@@ -10,9 +16,9 @@
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>
......
......@@ -92,6 +92,13 @@ Copy region into register @var{r} (@code{copy-to-register}).
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
......@@ -116,6 +123,19 @@ region after appending it to the register. The command
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
......@@ -191,8 +211,10 @@ Store @var{number} into register @var{r} (@code{number-to-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
......
......@@ -182,6 +182,13 @@ just removing them, as done by `yank-excluded-properties'.
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>
......
......@@ -76,6 +76,22 @@ A list of the form (WINDOW-CONFIGURATION POSITION)
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)))
......@@ -192,13 +208,24 @@ Interactively, NUMBER is the prefix arg (none means nil)."
(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.
......@@ -349,10 +376,11 @@ Called from program, takes four args: REGISTER, START, END and DELETE-FLAG.
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))
......@@ -366,10 +394,11 @@ Called from program, takes four args: REGISTER, START, END and DELETE-FLAG.
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))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment