* advance char
@ 2013-06-06 8:16 Andreas Röhler
2013-06-06 9:01 ` Thorsten Jolitz
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Andreas Röhler @ 2013-06-06 8:16 UTC (permalink / raw)
To: help-gnu-emacs@gnu.org List
Hi,
I'm looking for a command, which would replace character at point by its successor in alphabet.
I.e. make B from A, C from B etc.
Pretty sure it exists somewhere.
TIA,
Andreas
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: advance char
2013-06-06 8:16 advance char Andreas Röhler
@ 2013-06-06 9:01 ` Thorsten Jolitz
2013-06-06 9:09 ` Jambunathan K
2013-06-06 9:25 ` Teemu Likonen
2 siblings, 0 replies; 7+ messages in thread
From: Thorsten Jolitz @ 2013-06-06 9:01 UTC (permalink / raw)
To: help-gnu-emacs
Andreas Röhler <andreas.roehler@easy-emacs.de> writes:
Hi,
> I'm looking for a command, which would replace character at point by
> its successor in alphabet.
>
> I.e. make B from A, C from B etc.
>
> Pretty sure it exists somewhere.
not sure if this helps, but
,---------------------------
| (integerp ?a)
| t
|
| (characterp ?a)
| t
|
| (format "%s %s %s" ?a?b?c)
| "97 98 99"
`---------------------------
so
,--------
| (1+ ?a)
`--------
might do the job if you find a way to make Emacs to make Emacs print a
character as String (its char representation, not its integer
representation.
This does not work:
,---------------------------
| (number-to-string (1+ ?a))
| "98"
`---------------------------
--
cheers,
Thorsten
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: advance char
2013-06-06 8:16 advance char Andreas Röhler
2013-06-06 9:01 ` Thorsten Jolitz
@ 2013-06-06 9:09 ` Jambunathan K
2013-06-06 9:25 ` Teemu Likonen
2 siblings, 0 replies; 7+ messages in thread
From: Jambunathan K @ 2013-06-06 9:09 UTC (permalink / raw)
To: Andreas Röhler; +Cc: help-gnu-emacs@gnu.org List
Andreas Röhler <andreas.roehler@easy-emacs.de> writes:
> Hi,
>
> I'm looking for a command, which would replace character at point by its successor in alphabet.
>
> I.e. make B from A, C from B etc.
>
> Pretty sure it exists somewhere.
C-M-% . RET \,(char-to-string (1+ (string-to-char \&))) RET
See last few paragraphs of (info "(emacs) Regexp Replace")
>
> TIA,
>
> Andreas
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: advance char
2013-06-06 8:16 advance char Andreas Röhler
2013-06-06 9:01 ` Thorsten Jolitz
2013-06-06 9:09 ` Jambunathan K
@ 2013-06-06 9:25 ` Teemu Likonen
2013-06-06 11:14 ` Andreas Röhler
2 siblings, 1 reply; 7+ messages in thread
From: Teemu Likonen @ 2013-06-06 9:25 UTC (permalink / raw)
To: Andreas Röhler; +Cc: help-gnu-emacs
[-- Attachment #1: Type: text/plain, Size: 457 bytes --]
Andreas Röhler [2013-06-06 10:16:22 +02:00] wrote:
> I'm looking for a command, which would replace character at point by
> its successor in alphabet.
>
> I.e. make B from A, C from B etc.
"Successor in alphabet" may vary between languages but if successor in
character codes suits you, it's very simple:
(defun shift-char-after ()
(interactive)
(save-excursion
(insert (1+ (char-after)))
(delete-char 1)))
[-- Attachment #2: Type: application/pgp-signature, Size: 835 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: advance char
2013-06-06 9:25 ` Teemu Likonen
@ 2013-06-06 11:14 ` Andreas Röhler
2013-06-06 13:01 ` Stefan Monnier
0 siblings, 1 reply; 7+ messages in thread
From: Andreas Röhler @ 2013-06-06 11:14 UTC (permalink / raw)
To: help-gnu-emacs@gnu.org List
Am 06.06.2013 11:25, schrieb Teemu Likonen:
> Andreas Röhler [2013-06-06 10:16:22 +02:00] wrote:
>
>> I'm looking for a command, which would replace character at point by
>> its successor in alphabet.
>>
>> I.e. make B from A, C from B etc.
>
> "Successor in alphabet" may vary between languages but if successor in
> character codes suits you, it's very simple:
>
> (defun shift-char-after ()
> (interactive)
> (save-excursion
> (insert (1+ (char-after)))
> (delete-char 1)))
>
Thanks all responding!
BTW suggest to take shift-char into simple.el
Andreas
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: advance char
2013-06-06 11:14 ` Andreas Röhler
@ 2013-06-06 13:01 ` Stefan Monnier
2013-06-06 14:33 ` Andreas Röhler
0 siblings, 1 reply; 7+ messages in thread
From: Stefan Monnier @ 2013-06-06 13:01 UTC (permalink / raw)
To: help-gnu-emacs
> BTW suggest to take shift-char into simple.el
It's the first time I see someone need it, in my almost 20 years of
hacking on Emacs. So, adding it to simple.el sounds like a really
outlandish proposition.
Stefan
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: advance char
2013-06-06 13:01 ` Stefan Monnier
@ 2013-06-06 14:33 ` Andreas Röhler
0 siblings, 0 replies; 7+ messages in thread
From: Andreas Röhler @ 2013-06-06 14:33 UTC (permalink / raw)
To: help-gnu-emacs
Am 06.06.2013 15:01, schrieb Stefan Monnier:
>> BTW suggest to take shift-char into simple.el
>
> It's the first time I see someone need it, in my almost 20 years of
> hacking on Emacs. So, adding it to simple.el sounds like a really
> outlandish proposition.
>
>
> Stefan
>
>
>
Needed a couple of function/regexp pairs which where named right-down the alphabet, up/downcased again and so on.
For the latter command `reverse-chars' exists already:
(defun reverse-chars (&optional arg)
"Reverse reciproke chars as \"[\" to \"]\", upcase or downcase,
Switch `\"' with `''
If over a number, add ARG to it.
With negative arg, substract from number.
[ ... ]
;;;;;;;
People interested in this and related basic stuff might have a look into misc-utils.el
at
https://launchpad.net/s-x-emacs-werkstatt/
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2013-06-06 14:33 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-06 8:16 advance char Andreas Röhler
2013-06-06 9:01 ` Thorsten Jolitz
2013-06-06 9:09 ` Jambunathan K
2013-06-06 9:25 ` Teemu Likonen
2013-06-06 11:14 ` Andreas Röhler
2013-06-06 13:01 ` Stefan Monnier
2013-06-06 14:33 ` Andreas Röhler
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).