all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: jj.retorre@gmail.com (Jean-Jacques Rétorré)
To: help-gnu-emacs@gnu.org
Subject: Re: How to get the ~ functionality of vi
Date: Fri, 27 May 2016 06:28:23 +0200	[thread overview]
Message-ID: <87pos8p1js.fsf@elfie.nowhere.com> (raw)
In-Reply-To: 86h9dkfghn.fsf@student.uu.se

ven. 27 mai 2016,  Emanuel Berg <embe8573@student.uu.se> disait :

> Cecil Westerhof <Cecil@decebal.nl> writes:
>
>> In vi you can use ~ to flip the case of
>> a character. Does Emacs has something
>> like that?
>
> Try this:
>
>     (defun flip-case ()
>       (interactive)
>       (let ((c (string-to-char (thing-at-point 'char t))))
>         (delete-char 1)
>         (cond ((and (>= c ?A) (<= c ?Z)) (insert-char (downcase c)))
>               ((and (>= c ?a) (<= c ?z)) (insert-char (upcase   c)))
>               (t                         (insert-char c)))) )
>     (global-set-key "\C-cf" #'flip-case)

That won't work for accented chars.
Probably this should :

(defun flip-case ()
  (interactive)
  (let ((c (string-to-char (thing-at-point 'char t))))
    (delete-char 1)
    (insert-char
        (if (eq c (upcase c))
         (downcase c)
         (upcase c))) ) )

--
JJR.


  reply	other threads:[~2016-05-27  4:28 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-26 22:36 How to get the ~ functionality of vi Cecil Westerhof
2016-05-27  1:15 ` Emanuel Berg
2016-05-27  4:28   ` Jean-Jacques Rétorré [this message]
2016-05-27  8:54     ` Cecil Westerhof
2016-05-27 11:33       ` Thorsten Bonow
2016-05-27 19:41         ` Emanuel Berg
2016-06-02 16:14         ` Kaushal Modi
     [not found]         ` <mailman.703.1464884068.1216.help-gnu-emacs@gnu.org>
2016-06-02 17:15           ` Emanuel Berg
2016-06-02 17:28             ` Kaushal Modi
     [not found]             ` <mailman.715.1464888555.1216.help-gnu-emacs@gnu.org>
2016-06-02 20:39               ` Emanuel Berg
2016-06-02 21:00                 ` Kaushal Modi
2016-06-03  5:07                   ` Marcin Borkowski
     [not found]                 ` <mailman.730.1464901264.1216.help-gnu-emacs@gnu.org>
2016-06-02 21:07                   ` Emanuel Berg
2016-06-03  9:21                     ` Joost Kremers
2016-06-03 10:51                       ` Emanuel Berg
2016-05-27 19:37       ` Emanuel Berg
2016-05-27 19:37       ` Emanuel Berg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87pos8p1js.fsf@elfie.nowhere.com \
    --to=jj.retorre@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.